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

[core][autoscaler] Fix env variable overwrite not able to be used if command itself uses the env #37675

Merged
merged 3 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion python/ray/autoscaler/_private/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def with_envs(cmds: List[str], kv: Dict[str, str]) -> str:
for cmd in cmds:
kv_str = ""
for k, v in kv.items():
kv_str += f"{k}={v} "
kv_str += f"export {k}={v}; "
rickyyx marked this conversation as resolved.
Show resolved Hide resolved

out_cmds.append(f"{kv_str}{cmd}")
return out_cmds
Expand Down
10 changes: 5 additions & 5 deletions python/ray/tests/test_autoscaler_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ def test_with_envs():
assert with_envs(
["echo $RAY_HEAD_IP", "ray start"], {"RAY_HEAD_IP": "127.0.0.0"}
) == [
"RAY_HEAD_IP=127.0.0.0 echo $RAY_HEAD_IP",
"RAY_HEAD_IP=127.0.0.0 ray start",
"export RAY_HEAD_IP=127.0.0.0; echo $RAY_HEAD_IP",
"export RAY_HEAD_IP=127.0.0.0; ray start",
]

assert with_head_node_ip(["echo $RAY_HEAD_IP"], "127.0.0.0") == [
"RAY_HEAD_IP=127.0.0.0 echo $RAY_HEAD_IP"
"export RAY_HEAD_IP=127.0.0.0; echo $RAY_HEAD_IP"
]

assert (
"RAY_HEAD_IP=456"
"export RAY_HEAD_IP=456"
in with_envs(
["echo $RAY_CLOUD_ID"], {"RAY_CLOUD_ID": "123", "RAY_HEAD_IP": "456"}
)[0]
)
assert (
"RAY_CLOUD_ID=123"
"export RAY_CLOUD_ID=123"
in with_envs(
["echo $RAY_CLOUD_ID"], {"RAY_CLOUD_ID": "123", "RAY_HEAD_IP": "456"}
)[0]
Expand Down
Loading