Repository navigation
refactor(data): split the Harbor run commands out of the task CLI module - #5230
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD
The legacy Harbor CLI compatibility shim misses package-style imports, breaking an existing import form. The preparation/CLI split and migrated call sites otherwise appear consistent.
Completed inspection of all changed files and directly affected callers, contracts, and tests. Static review only; tests and import-linter were not executed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
de1a350 to
6203c80
Compare
c487097 to
3c6a4b1
Compare
3c6a4b1 to
d536899
Compare
d536899 to
c96617e
Compare
c96617e to
168d2b2
Compare
yaoyu-33
left a comment
There was a problem hiding this comment.
Summary
This PR splits the Harbor task module from #5229 in two:
- Taskset preparation stays in
nemo_gym/data/tasks/harbor/prepare.py, as a rename. run_target,validate_target, their override readers and the run-summary helpers move unchanged intonemo_gym/cli/eval.py.
As a result, data/ no longer imports cli/ or the rollout collector, and three import-linter exceptions go away.
Verdict: HOLD for one item. Dropping ORACLE_AGENT from nemo_gym.data breaks the Harbor environment server and the Harbor oracle agent at import (see the inline comment). The fix is two lines that #5231 already has. With them, the split looks ready to us.
What we checked at 4ed3ff2
- Split: all 74 top-level statements of the old module are AST-identical in their new homes (43 kept, 31 moved), with none lost or duplicated. Every global name the moved code reads resolves to the same object as before.
- CLI:
--helpoutput is byte-identical before and after forgym,gym eval run,gym dataset validate,gym dataset pulland their siblings, and argument parsing and dispatch match on 8 argv. A localgym dataset validateandgym eval runsmoke run (servers faked) writes identical files. - Import layering:
lint-imports(import-linter 2.15) keeps the contract with 10 exceptions, down from 13, and there is no new import-time cycle. - Old paths:
nemo_gym.tasks.harbor.cliis the same module asprepare, and every name in the recorded import surface resolves to the same object, with one warning at the caller. The earlier package-style import thread is fixed. - Tests: head and base fail the same environment-only set. No assertion was weakened and no patch was dropped.
PR hygiene
- [PROCESS] #5166 asks each split PR to list the patch targets that stop taking effect. The body states the rule, and the 53
MOVED_NAMESentries at_moved_paths.py:544-598are the list. Two groups behave differently, which may be worth a line in the release notes:- No effect: a patch through
nemo_gym.tasks.harbor.cliofrun_target,validate_target, the*_from_overridesreaders,write_run_summary,summarize_validationorbuild_options_from_overridesstill succeeds, but it no longer reaches the run commands. - Partial effect:
cli/eval.pybindsprepare_target,resolve_agent,resolve_sandbox_configandbuild_runby value, so an old-path patch of them reaches onlyprepare.py's own callers.
- No effect: a patch through
Optional
- In tests that drive
run_target/validate_target, themonkeypatch.setattr(harbor_cli, ...)twins forprepare_target,resolve_agentandresolve_sandbox_configare never read. Examples aretest_harbor_image_build.py:706andtest_harbor_tasks.py:4034. Replacing them with failing fakes leaves the tests green. Dropping them would keep "patch where the name is looked up" literal; this is not a blocker.
CI at 4ed3ff2
Unit tests / Server suiteshards 0 and 1 fail on theORACLE_AGENTImportError, inenvironment_servers/harborandresponses_api_agents/harbor_oracle_agentrespectively.Nemo_CICD_Testand theServer suiteroll-up follow from them.Harness conformance (non-blocking)/ kilocode fails themodel_errorscenario, the same failure seen across this stack.
Items for other PRs in the stack
- #5167:
moved_names_getattrhas no__dir__, sodir()on an old split module drops the moved names, althoughhasattrstill finds them.- A pytest
monkeypatch.setattr(old_module, moved_name)followed byundo()writes the real object into the old module's__dict__. After that, patches of the new module no longer show through the old path. migrate_imports.pyrewritesimport nemo_gym.tasks.harbor.cli as harbor_clibut leavesharbor_cli.run_targetattribute accesses going through the deprecated getter.
- #5229:
fern/docs.ymlredirects thenemo_gym/taskspackage page but not the per-modulenemo_gym/tasks/harbor/<module>reference pages.
|
Replies to the summary, as of
|
Rename only, with no content changes: data/tasks/harbor/cli.py becomes data/tasks/harbor/prepare.py. data/tasks/harbor/prepare.py keeps finding, pulling, and preparing a taskset and building its run config. The commands that run and validate it, `gym eval run` and `gym dataset validate` for Harbor targets, move unchanged to cli/eval.py with the override readers and summary writing they use, so the data package no longer imports the CLI or the rollout collector. Three contract exceptions go away. Record the module move in MOVED_MODULES and the split names in MOVED_NAMES. Rewrite in-repo references with scripts/migrate_imports.py, including those to the module's path in the previous PR. Point test patches and calls at the module that now looks each name up: names that moved are patched and called on nemo_gym.cli.eval, and names that stayed but are also read by the moved commands are patched on both modules. Redirect the old library reference page in fern/docs.yml. Regenerate the public API of each layout package that exists here from what non-test code outside nemo_gym imports, and point code outside nemo_gym, tests included, at nemo_gym.<package>. Signed-off-by: Ananth Subramaniam <[email protected]>
What and why
Splits the Harbor task CLI module that #5229 moved into
data/. It held two things: finding, pulling, and preparing a taskset, which belongs with the task data, and thegym eval runandgym dataset validatecommands for Harbor targets, which run the rollout collector and belong with the CLI. The data package imported the CLI and the rollout collector for the second half; after this PR it imports neither.Where this PR sits
The stack lands bottom-up; each PR's base is the branch of the PR before it, so each diff shows only that PR's change.
What moves
flowchart LR subgraph H["tasks/harbor/cli.py today"] P["Find, pull, and prepare a taskset;<br/>build its run config"] R["run_target, validate_target,<br/>override readers, run summary"] end P --> P2["data/tasks/harbor/prepare.py"] R --> R2["cli/eval.py"] R2 -->|"imports"| P2 classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937 class P2,R2 thisprepare.pyis a git rename of the module, so its history follows it. The run commands are appended tocli/eval.pyunchanged.cli/eval.pyimports the preparation steps it calls fromprepare.py, a downward import. Nothing indata/importscli/any more, so the contract drops its three exceptions for this module; 10 remain.What stays importable from the old paths
nemo_gym.tasks.harbor.cliis the same module object asnemo_gym.data.tasks.harbor.prepare.cli/eval.pyresolves at the old path with one warning, through a__getattr__onprepare.py.nemo_gym.tasks.harbor.cli, is nownemo_gym.data.tasks.harbor.prepare, so a patch through either path lands onprepare.py:cli/eval.pysucceeds but no longer reaches them. That coversrun_target,validate_target, the override readers (compose_overlay_from_overrides,compose_platform_from_overrides,gpu_sandbox_provider_from_overrides,gpu_shared_storage_from_overrides,gpu_volume_sources_from_overrides,pairing_override_from_overrides,registry_credentials_from_overrides,sandbox_provider_from_overrides,shared_storage_from_overrides,volume_sources_from_overrides), and the helpers the run commands call, such aswrite_run_summary,summarize_validationandbuild_options_from_overrides. Patch them onnemo_gym.cli.eval.cli/eval.pyimportsprepare_target,resolve_agent,resolve_sandbox_configandbuild_runby name. A patch of them onprepare.pyreaches onlyprepare.py's own callers, so to change what the run commands call, patch them onnemo_gym.cli.eval.nemo_gym.cli.eval. Their extra patches ofprepare_target,resolve_agentandresolve_sandbox_configonprepare.pywere removed: each test still passed with the patched value replaced by a function that fails when called, so none was ever read.How to review
One commit. Its changes:
data/tasks/harbor/cli.pybecomesdata/tasks/harbor/prepare.py.MOVED_MODULESandMOVED_NAMESentries, in-repo references rewritten byscripts/migrate_imports.py(including references to the module's path from refactor(data): move the task data modules into nemo_gym/data #5229, which never ships), the test patches described above, the contract exceptions, and a docs redirect.prepare.py's docstring now describes preparation only and points tonemo_gym.cli.eval.run_targetandvalidate_target; its references to the override readers namenemo_gym.cli.eval, andprepare_builds.pyandvalidation_report.pyname their callers instead ofcli.py.nemo_gym/imports from a package's public API resolves on the package. It catches a name dropped from a public API, which otherwise surfaces only when a server suite loads the server: it fails withORACLE_AGENTremoved fromnemo_gym.data.tasks.harbor, naming both Harbor environment server files that import it.The Harbor tests stay where they are; several read fixtures by path and drive the environment server too.
History of split files
The repository squash-merges, so this PR lands as one commit. Whole-module moves still show as renames. A split file does not: its old path stays with less in it, so the new file starts its own history.
git blame -C -C <new file>follows the moved lines back to the old file, andgit log --followdoes not.Public API
Every layout package that exists after this PR has a lazy public API in its
__init__.py: the names code outsidenemo_gym/imports from it (servers and their tests, benchmarks, scripts, and code samples in docs and skills), plus every name it already exported, each served from the submodule that defines it on first use. Code outsidenemo_gym/and its tests (servers and their tests, benchmarks, scripts, and docs) imports those names fromnemo_gym.<package>, so later moves inside a package leave it alone. Code insidenemo_gym/, and the library's tests undertests/, import from the module that defines each name, so the import-linter contract sees every dependency and a test reads what it patches. A patch target names the module the code under test looks the name up in.AGENTS.mdstates the rule.Validation
pytest -n 16 tests/unit_tests, also with-W errorfor the old Harbor CLI path and names. The only failures are environment-specific and unrelated to the move: this machine's hostname resolves to127.0.1.1, which the sandbox host check refuses (the Harbor run summary tests and the benchmark listing test), and two Docker PTY tests.lint-imports.pre-commit runon the changed files.Rollout evidence: N/A. The code moves unchanged;
gym eval runandgym dataset validatebehave as before.Compatibility
nemo_gym.cli.eval.from nemo_gym.tasks.harbor import cligives the preparation module, asimport nemo_gym.tasks.harbor.clidoes. The Harbor package's public API (refactor(data): move the task data modules into nemo_gym/data #5229) falls back to the moved-path entries for a name it does not export, so it serves the moved submodule whichever parent loads first.python scripts/migrate_imports.py <paths>.Issue
Part of #5166.