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

Drop old pass-config env and volume in generate command #2074

Merged
merged 2 commits into from
Apr 5, 2021
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.D/2074.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed handling jobs with `--pass-config` in `neuro job generate-run-command`.
8 changes: 6 additions & 2 deletions neuro-cli/src/neuro_cli/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
(
Expand All @@ -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():
Expand Down
7 changes: 7 additions & 0 deletions neuro-cli/tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down