Skip to content

Commit 722c63e

Browse files
Teq2412claude
andcommitted
test(slime): merge the two _build_runtime_env tests
Both tests exercise the same method on the same code path; the only difference was whether WANDB_* env vars were set. Merged into one test covering both the always-present keys and the opt-in wandb forwarding. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent efcad5d commit 722c63e

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

tests/test_slime_runner.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,24 @@
1717
)
1818

1919

20-
def test_build_runtime_env_has_required_keys():
21-
"""PYTHONPATH (for megatron) and CUDA_DEVICE_MAX_CONNECTIONS (for Megatron TP)
22-
are required — they mirror train.sh's inline python snippet and breaking them
23-
breaks every downstream Ray worker."""
20+
def test_build_runtime_env_required_keys_and_wandb_opt_in():
21+
"""PYTHONPATH + CUDA_DEVICE_MAX_CONNECTIONS are always present; wandb keys
22+
are opt-in, forwarded only when set in the parent env."""
2423
runner = SlimeRunner(**REQUIRED_KWARGS, megatron_dir="/opt/megatron")
2524

2625
with patch.dict("os.environ", {}, clear=True):
27-
env = runner._build_runtime_env()
28-
29-
assert env == {
26+
env_no_wandb = runner._build_runtime_env()
27+
assert env_no_wandb == {
3028
"env_vars": {
3129
"PYTHONPATH": "/opt/megatron",
3230
"CUDA_DEVICE_MAX_CONNECTIONS": "1",
3331
}
3432
}
3533

36-
37-
def test_build_runtime_env_forwards_wandb_when_set():
38-
"""Wandb keys are opt-in: absent from env → not in runtime_env."""
39-
runner = SlimeRunner(**REQUIRED_KWARGS)
40-
4134
with patch.dict("os.environ", {"WANDB_API_KEY": "abc", "WANDB_ENTITY": "me"}, clear=True):
42-
env = runner._build_runtime_env()
43-
44-
assert env["env_vars"]["WANDB_API_KEY"] == "abc"
45-
assert env["env_vars"]["WANDB_ENTITY"] == "me"
35+
env_with_wandb = runner._build_runtime_env()
36+
assert env_with_wandb["env_vars"]["WANDB_API_KEY"] == "abc"
37+
assert env_with_wandb["env_vars"]["WANDB_ENTITY"] == "me"
4638

4739

4840
def test_from_yaml_round_trips(tmp_path: Path):

0 commit comments

Comments
 (0)