From a9054d081e5cefc5ca1f2d718ef58cb51c528f73 Mon Sep 17 00:00:00 2001 From: Roman Skurikhin Date: Fri, 2 Apr 2021 17:03:15 +0300 Subject: [PATCH 1/2] Drop old pass-config env and volume in generate command --- neuro-cli/src/neuro_cli/job.py | 8 ++++++-- neuro-cli/tests/unit/test_job.py | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/neuro-cli/src/neuro_cli/job.py b/neuro-cli/src/neuro_cli/job.py index ccc48009c..a4e7dd7e8 100644 --- a/neuro-cli/src/neuro_cli/job.py +++ b/neuro-cli/src/neuro_cli/job.py @@ -1190,7 +1190,9 @@ async def _force_disk_id(disk_uri: URL) -> URL: # TODO: remove this and upload_and_map_config function old_env_name = "NEURO_STEAL_CONFIG" if old_env_name in env_dict: - raise ValueError(f"{env_name} is already set to {env_dict[env_name]}") + raise ValueError( + f"{old_env_name} is already set to {env_dict[old_env_name]}" + ) env_var, secret_volume = await upload_and_map_config(root) env_dict[old_env_name] = env_var @@ -1384,6 +1386,8 @@ def _job_to_cli_args(job: JobDescription) -> List[str]: if job.description: res += ["--description", shlex.quote(job.description)] for volume in job.container.volumes: + if volume.container_path == "/var/storage/.neuro" and job.pass_config: + continue res += [ "--volume", ( @@ -1403,7 +1407,7 @@ def _job_to_cli_args(job: JobDescription) -> List[str]: if job.container.working_dir: res += ["--workdir", job.container.working_dir] for env_name, env_value in job.container.env.items(): - if env_name == PASS_CONFIG_ENV_NAME and job.pass_config: + if env_name in (PASS_CONFIG_ENV_NAME, "NEURO_STEAL_CONFIG") and job.pass_config: continue # Do not specify value for pass config env variable res += ["--env", f"{env_name}={env_value}"] for env_name, secret_uri in job.container.secret_env.items(): diff --git a/neuro-cli/tests/unit/test_job.py b/neuro-cli/tests/unit/test_job.py index 862f5943c..d73494d3d 100644 --- a/neuro-cli/tests/unit/test_job.py +++ b/neuro-cli/tests/unit/test_job.py @@ -323,7 +323,14 @@ def test_job_to_args_drop_env_when_pass_config() -> None: resources=Resources(16, 0.1, 0, None, True, None, None), env={ "NEURO_PASSED_CONFIG": "base64 data here", + "NEURO_STEAL_CONFIG": "path here", }, + volumes=[ + Volume( + storage_uri=URL("storage:.neuro"), + container_path="/var/storage/.neuro", + ) + ], ), scheduler_enabled=False, pass_config=True, From 887ee825030116c4ce8d7ef964ca7fa857b72890 Mon Sep 17 00:00:00 2001 From: Roman Skurikhin Date: Fri, 2 Apr 2021 17:09:18 +0300 Subject: [PATCH 2/2] Add changelog --- CHANGELOG.D/2074.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGELOG.D/2074.bugfix diff --git a/CHANGELOG.D/2074.bugfix b/CHANGELOG.D/2074.bugfix new file mode 100644 index 000000000..03b85886e --- /dev/null +++ b/CHANGELOG.D/2074.bugfix @@ -0,0 +1 @@ +Fixed handling jobs with `--pass-config` in `neuro job generate-run-command`.