From 4e97a019e076f01e1af9ef5757498ca8997774cc Mon Sep 17 00:00:00 2001 From: rickyyx Date: Sat, 22 Jul 2023 03:18:14 +0000 Subject: [PATCH 1/3] init Signed-off-by: rickyyx --- python/ray/autoscaler/_private/util.py | 2 +- python/ray/tests/test_autoscaler_util.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/ray/autoscaler/_private/util.py b/python/ray/autoscaler/_private/util.py index 20fb5198610c..b7ffe900a7d7 100644 --- a/python/ray/autoscaler/_private/util.py +++ b/python/ray/autoscaler/_private/util.py @@ -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}; " out_cmds.append(f"{kv_str}{cmd}") return out_cmds diff --git a/python/ray/tests/test_autoscaler_util.py b/python/ray/tests/test_autoscaler_util.py index af35fbc418ad..c8b05f130ad3 100644 --- a/python/ray/tests/test_autoscaler_util.py +++ b/python/ray/tests/test_autoscaler_util.py @@ -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] From 120483f713ae405c297ceba8b243406680d1c5f7 Mon Sep 17 00:00:00 2001 From: rickyyx Date: Sat, 22 Jul 2023 03:50:00 +0000 Subject: [PATCH 2/3] comments Signed-off-by: rickyyx --- python/ray/autoscaler/_private/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/ray/autoscaler/_private/util.py b/python/ray/autoscaler/_private/util.py index b7ffe900a7d7..3afbffc078a3 100644 --- a/python/ray/autoscaler/_private/util.py +++ b/python/ray/autoscaler/_private/util.py @@ -395,12 +395,14 @@ def with_envs(cmds: List[str], kv: Dict[str, str]) -> str: Example: with_envs(["echo $FOO"], {"FOO": "BAR"}) - -> ["FOO=BAR echo $FOO"] + -> ["export FOO=BAR; echo $FOO"] """ out_cmds = [] for cmd in cmds: kv_str = "" for k, v in kv.items(): + # We will need to do export here so that it works correctly with + # shell if the cmd args uses the argument. kv_str += f"export {k}={v}; " out_cmds.append(f"{kv_str}{cmd}") From ee3af9f699a169ed8e7d8147b977b0af32adf7fd Mon Sep 17 00:00:00 2001 From: scv119 Date: Fri, 21 Jul 2023 22:50:10 -0700 Subject: [PATCH 3/3] lint --- python/ray/autoscaler/_private/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/ray/autoscaler/_private/util.py b/python/ray/autoscaler/_private/util.py index 3afbffc078a3..9eeafd938252 100644 --- a/python/ray/autoscaler/_private/util.py +++ b/python/ray/autoscaler/_private/util.py @@ -401,8 +401,8 @@ def with_envs(cmds: List[str], kv: Dict[str, str]) -> str: for cmd in cmds: kv_str = "" for k, v in kv.items(): - # We will need to do export here so that it works correctly with - # shell if the cmd args uses the argument. + # We will need to do export here so that it works correctly with + # shell if the cmd args uses the argument. kv_str += f"export {k}={v}; " out_cmds.append(f"{kv_str}{cmd}")