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?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point - I thought by default we are getting the /nail/bulkdata mount from the host, but I cant actually see where that is happening - these changes are to configure_and_run_docker_container - which calls run_docker_container which then calls os.execlpe("paasta_docker_wrapper", *docker_run_cmd, merged_env) which is defined here but none of these seem to include system_volumes from /etc/paasta/volumes.json so i'm actually unsure why spark-run is mounting the bulkdata volume at all currently

@nemacysts / @chi-yelp do you have any ideas where the /nail/bulkdata mount is happening? Or is there any way I can test this like I did with #3893 in the paasta playground

Copy link
Contributor

@chi-yelp chi-yelp Dec 18, 2024

Choose a reason for hiding this comment

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

hmm I checked using the following command and it seems /nail/bulkdata isn't mounted:

./.tox/py38-linux/bin/paasta spark-run --aws-profile=dev --cmd bash

Copy link
Member Author

Choose a reason for hiding this comment

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

so volumes are found from the instance config here which is then passed to spark conf here and then later referenced here

Meaning it is important that I check if /nail/bulkdata is in the list of volumes before adding it. And the command @chi-yelp shared is not mounting bulkdata because its not specifying a service / instance that uses bulkdata - @chi-yelp was that command run on my branch?

)

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