fix(test_scenario): stop apply_params_set writing NUM_NODES into cmd_args - #1007
fix(test_scenario): stop apply_params_set writing NUM_NODES into cmd_args#1007AmirF194 wants to merge 1 commit into
Conversation
…args TestRun.param_space adds a "NUM_NODES" key to the action space whenever num_nodes is swept. apply_params_set has an explicit branch that assigns that value to new_tr.num_nodes, but the generic per-key loop above it also matches "NUM_NODES" and calls setattr(tdef.cmd_args, "NUM_NODES", value). Since CmdArgs uses ConfigDict(extra="allow"), that setattr does not raise: it silently creates a phantom NUM_NODES field on cmd_args that persists into cmd_args.model_dump() and any report reading it back. Skip "NUM_NODES" in the generic loop since the explicit branch below already owns it. Strengthens test_params_set, which exercised every num_nodes sweep shape but never asserted the field was absent from cmd_args. Fixes NVIDIA#943 Signed-off-by: Amir Fathi <amirfathi.me@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughThe change keeps ChangesNUM_NODES parameter handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This change prevents the internal NUM_NODES sweep parameter from being persisted as an unintended command argument while preserving node-count assignment; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
TestRun.param_space(src/cloudai/_core/test_scenario.py) adds a"NUM_NODES"key to theaction space whenever
num_nodesis a sweep list.apply_params_setthen does two thingswith that key: a generic per-key loop applies every action key to
tdef.cmd_argsviasetattr, and an explicit branch right after separately assigns it tonew_tr.num_nodes.Both fire on
"NUM_NODES". BecauseCmdArgsisConfigDict(extra="allow"), the genericloop's
setattr(tdef.cmd_args, "NUM_NODES", value)does not raise: it silently creates aphantom
NUM_NODESfield oncmd_argsthat shows up incmd_args.model_dump()and in anypersisted
TestRunDetailsdump, even though the workload itself never declared or acceptedthat field.
new_tr.num_nodesis still set correctly by the explicit branch, so the actualjob dispatch is unaffected, only the recorded/reported config is wrong.
Fix: skip
"NUM_NODES"in the generic loop, since the explicit branch already owns it.Test Plan
tests/test_cloudaigym.py::test_params_setexercised everynum_nodessweep shape(
1,[1, 2],[3]) already, but never asserted the field was absent fromcmd_args.Added that assertion; confirmed it fails on
main(AssertionError: 'NUM_NODES' in {...}) and passes with this change.uv run pytest(Python 3.14): full suite green except two pre-existing failures intests/test_base_installer.py::TestPrepareOutputDirunrelated to this change (they asserta chmod-000 directory is unwritable, which does not hold when the test runs as root).
uv run pytest -m ci_only,--dead-fixtures, andcoverage report --include='tests/*' --fail-under=97.00(98.92% here) all pass.uv run pre-commit run --files src/cloudai/_core/test_scenario.py tests/test_cloudaigym.py(pyright, ruff, vulture, import-linter, taplo) passes; controlled the same command on
pristine
mainfirst to confirm a clean baseline.