Skip to content

Commit cfa33b9

Browse files
greptile fixes
1 parent 120a3c5 commit cfa33b9

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

src/cloudai/workloads/megatron_bridge/megatron_bridge.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ class MegatronBridgeCmdArgs(CmdArgs):
8686
@classmethod
8787
def validate_hf_token(cls, v: Optional[str]) -> Optional[str]:
8888
token = (v or "").strip()
89-
return token or None
89+
if not token:
90+
raise ValueError("cmd_args.hf_token is required. Please set it to your literal HF token string.")
91+
return token
9092

9193

9294
class MegatronBridgeTestDefinition(TestDefinition):

src/cloudai/workloads/megatron_bridge/slurm_command_gen_strategy.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,6 @@ def _wrap_launcher_for_job_id_and_quiet_output(self, launcher_cmd: str) -> str:
152152
def _build_launcher_parts( # noqa: C901
153153
self, args: MegatronBridgeCmdArgs, tdef: MegatronBridgeTestDefinition, repo_path: Path, launcher_py: Path
154154
) -> list[str]:
155-
if not args.hf_token or args.hf_token.strip() == "" or args.hf_token.strip() == "REPLACE_ME_WITH_HF_TOKEN":
156-
raise RuntimeError(
157-
"HuggingFace token is required. Please set cmd_args.hf_token to a real token string "
158-
"(not 'REPLACE_ME_WITH_HF_TOKEN') in your local test TOML."
159-
)
160-
161155
fields_set = args.model_fields_set
162156
force_fields = {
163157
"model_name",

tests/slurm_command_gen_strategy/test_megatron_bridge_slurm_command_gen_strategy.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,9 @@ def cmd_gen(self, slurm_system: SlurmSystem, test_run: TestRun) -> MegatronBridg
7676
slurm_system.default_partition = "gb300"
7777
return MegatronBridgeSlurmCommandGenStrategy(slurm_system, test_run)
7878

79-
def test_hf_token_placeholder_is_rejected_at_runtime(self, slurm_system: SlurmSystem, test_run: TestRun) -> None:
80-
tdef = cast(MegatronBridgeTestDefinition, test_run.test)
81-
tdef.cmd_args.hf_token = "REPLACE_ME_WITH_HF_TOKEN"
82-
slurm_system.account = "acct"
83-
slurm_system.default_partition = "gb300"
84-
cmd_gen = MegatronBridgeSlurmCommandGenStrategy(slurm_system, test_run)
85-
with pytest.raises(RuntimeError, match=r"hf_token"):
86-
cmd_gen.gen_exec_command()
79+
def test_hf_token_empty_is_rejected_by_schema(self) -> None:
80+
with pytest.raises(Exception, match=r"hf_token"):
81+
MegatronBridgeCmdArgs.model_validate({"hf_token": ""})
8782

8883
def test_defaults_not_emitted_when_not_set_in_toml(self, slurm_system: SlurmSystem, tmp_path: Path) -> None:
8984
sqsh = tmp_path / "img.sqsh"

tests/test_test_definitions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ def test_all_tests(toml_file: Path):
8888
with toml_file.open("r") as f:
8989
toml_dict = toml.load(f)
9090

91+
if toml_dict.get("test_template_name") == "MegatronBridge":
92+
cmd_args = toml_dict.get("cmd_args", {}) or {}
93+
if cmd_args.get("hf_token", None) == "":
94+
pytest.skip("MegatronBridge example config requires user to set cmd_args.hf_token.")
95+
9196
registry = Registry()
9297
template_name = toml_dict["test_template_name"]
9398
assert template_name in registry.test_definitions_map, f"Unknown test template: {template_name}"

0 commit comments

Comments
 (0)