Skip to content

Commit cf5268f

Browse files
kiukchungfacebook-github-bot
authored andcommitted
(bugfix)(torchx/runner) properly remove TORCHX_ prefix from env var before setting scheduler_params
Summary: kwargs to `create_scheduler()` scheduler factory method can be specified via the env var `TORCHX_{ARGUMENT_NAME}=arg_value`. For example: `TORCHX_TIER=prod` would call the factory method as `create_scheduler(session_name, tier="prod")`. Python's `str.strip("torchx_")` doesn't remove the prefix `torchx_` but rather strips any characters `t`, `o`, `r`, `c`, `h`, `x`, `_` from the front and back of the string. Change to using `str.removeprefix("torchx_")` which does what we intended it to. Reviewed By: ethanbwaite Differential Revision: D79473894
1 parent ae55901 commit cf5268f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

torchx/runner/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def __init__(
129129
def _get_scheduler_params_from_env(self) -> Dict[str, str]:
130130
scheduler_params = {}
131131
for key, value in os.environ.items():
132-
lower_case_key = key.lower()
133-
if lower_case_key.startswith("torchx_"):
134-
scheduler_params[lower_case_key.strip("torchx_")] = value
132+
key = key.lower()
133+
if key.startswith("torchx_"):
134+
scheduler_params[key.removeprefix("torchx_")] = value
135135
return scheduler_params
136136

137137
def __enter__(self) -> "Self":

0 commit comments

Comments
 (0)