Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uses bulkdata argument to paasta spark run #3995

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions paasta_tools/cli/cmds/spark_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@ def add_subparser(subparsers):
default=False,
)

list_parser.add_argument(
"--uses-bulkdata",
help="Mount /nail/bulkdata in the container",
action="store_true",
default=False,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not set the default to true for now, then roll out my change to add the flag everywhere, and then set the default to false?

)

aws_group = list_parser.add_argument_group(
title="AWS credentials options",
description="If --aws-credentials-yaml is specified, it overrides all "
Expand Down Expand Up @@ -785,6 +792,9 @@ def configure_and_run_docker_container(
else:
raise UnsupportedClusterManagerException(cluster_manager)

if args.uses_bulkdata:
volumes.append("/nail/bulkdata:/nail/bulkdata:ro")

volumes.append("%s:rw" % args.work_dir)
volumes.append("/nail/home:/nail/home:rw")

Expand Down
10 changes: 10 additions & 0 deletions tests/cli/test_cmds_spark_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ class TestConfigureAndRunDockerContainer:
"fake_dir",
)

@pytest.mark.parametrize("uses_bulkdata", [True, False])
@pytest.mark.parametrize(
["cluster_manager", "spark_args_volumes", "expected_volumes"],
[
Expand Down Expand Up @@ -468,6 +469,7 @@ def test_configure_and_run_docker_container(
cluster_manager,
spark_args_volumes,
expected_volumes,
uses_bulkdata,
):
mock_get_username.return_value = "fake_user"
spark_conf = {
Expand All @@ -494,6 +496,7 @@ def test_configure_and_run_docker_container(
args.tronfig = None
args.job_id = None
args.use_service_auth_token = False
args.uses_bulkdata = uses_bulkdata
with mock.patch.object(
self.instance_config, "get_env_dictionary", return_value={"env1": "val1"}
):
Expand All @@ -512,10 +515,15 @@ def test_configure_and_run_docker_container(
spark_config_dict=spark_conf,
is_mrjob=args.mrjob,
)
if uses_bulkdata:
bullkdata_volumes = ["/nail/bulkdata:/nail/bulkdata:ro"]
else:
bullkdata_volumes = []
mock_run_docker_container.assert_called_once_with(
container_name="fake_app",
volumes=(
expected_volumes
+ bullkdata_volumes
+ [
"/fake_dir:/spark_driver:rw",
"/nail/home:/nail/home:rw",
Expand Down Expand Up @@ -609,6 +617,7 @@ def test_configure_and_run_docker_driver_resource_limits_config(
args.docker_memory_limit = "4g"
args.docker_shm_size = "1g"
args.use_service_auth_token = False
args.uses_bulkdata = False
with mock.patch.object(
self.instance_config, "get_env_dictionary", return_value={"env1": "val1"}
):
Expand Down Expand Up @@ -724,6 +733,7 @@ def test_configure_and_run_docker_driver_resource_limits(
args.docker_memory_limit = False
args.docker_shm_size = False
args.use_service_auth_token = False
args.uses_bulkdata = False
with mock.patch.object(
self.instance_config, "get_env_dictionary", return_value={"env1": "val1"}
):
Expand Down