Skip to content

fix(test_scenario): stop apply_params_set writing NUM_NODES into cmd_args - #1007

Open
AmirF194 wants to merge 1 commit into
NVIDIA:mainfrom
AmirF194:fix/943-num-nodes-phantom-cmd-args-field
Open

fix(test_scenario): stop apply_params_set writing NUM_NODES into cmd_args#1007
AmirF194 wants to merge 1 commit into
NVIDIA:mainfrom
AmirF194:fix/943-num-nodes-phantom-cmd-args-field

Conversation

@AmirF194

Copy link
Copy Markdown

Summary

TestRun.param_space (src/cloudai/_core/test_scenario.py) adds a "NUM_NODES" key to the
action space whenever num_nodes is a sweep list. apply_params_set then does two things
with that key: a generic per-key loop applies every action key to tdef.cmd_args via
setattr, and an explicit branch right after separately assigns it to new_tr.num_nodes.
Both fire on "NUM_NODES". Because CmdArgs is ConfigDict(extra="allow"), the generic
loop's setattr(tdef.cmd_args, "NUM_NODES", value) does not raise: it silently creates a
phantom NUM_NODES field on cmd_args that shows up in cmd_args.model_dump() and in any
persisted TestRunDetails dump, even though the workload itself never declared or accepted
that field. new_tr.num_nodes is still set correctly by the explicit branch, so the actual
job 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_set exercised every num_nodes sweep shape
    (1, [1, 2], [3]) already, but never asserted the field was absent from cmd_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 in
    tests/test_base_installer.py::TestPrepareOutputDir unrelated to this change (they assert
    a chmod-000 directory is unwritable, which does not hold when the test runs as root).
  • uv run pytest -m ci_only, --dead-fixtures, and coverage 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 main first to confirm a clean baseline.

…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>
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: c6833655-f355-44e9-bc5e-96ccdbebebf9

📥 Commits

Reviewing files that changed from the base of the PR and between 3369e5d and 5baee53.

📒 Files selected for processing (2)
  • src/cloudai/_core/test_scenario.py
  • tests/test_cloudaigym.py

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Walkthrough

The change keeps NUM_NODES outside command arguments and applies it to TestRun.num_nodes. A test verifies both behaviors.

Changes

NUM_NODES parameter handling

Layer / File(s) Summary
Apply and validate NUM_NODES
src/cloudai/_core/test_scenario.py, tests/test_cloudaigym.py
TestRun.apply_params_set skips command-argument assignment for NUM_NODES. The test confirms that the node count is updated without serializing NUM_NODES into command arguments.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 5baee

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: jj10306

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: preventing NUM_NODES from being written into cmd_args.
Description check ✅ Passed The description accurately explains the NUM_NODES defect, the fix, the test coverage, and validation results.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant