Skip to content

refactor(data): split the Harbor run commands out of the task CLI module - #5230

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/layout-harbor-cli
Nov 3, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/layout-harbor-cli

Conversation

@ananthsub

@ananthsub ananthsub commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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 the gym eval run and gym dataset validate commands 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.

flowchart LR
  compat["#5167<br/>Old import paths<br/>keep working"]
  linter["#5168<br/>import-linter<br/>layer contract"]
  prep["#5169<br/>Remove path and<br/>name couplings"]
  config["#5189<br/>Move config/"]
  utils["#5195<br/>Move utils/"]
  core["#5203<br/>Move core/"]
  client["#5206<br/>Move client/,<br/>start telemetry/"]
  trajectory["#5209<br/>Move trajectory/"]
  verification["#5210<br/>Move verification/"]
  metrics["#5211<br/>Move metrics/"]
  artifacts["#5212<br/>Move artifacts/"]
  srmods["#5214<br/>Move server_runtime/<br/>modules"]
  su["#5215<br/>Split server_utils"]
  model["#5224<br/>Move models/<br/>modules"]
  modelbase["#5225<br/>Split model<br/>call capture"]
  agents["#5228<br/>Move agents/"]
  data["#5229<br/>Move data/"]
  harbor["#5230<br/>Split the<br/>Harbor task CLI"]
  rollouts["#5231<br/>Move rollouts/"]
  rsplit["#5232<br/>Split the<br/>rollout collector"]
  testing["#5233<br/>Dissolve testing/"]
  orch["#5234<br/>Move orchestration/<br/>modules"]
  sup["#5235<br/>Split the<br/>server supervisor"]
  eval["#5244<br/>Move eval/"]
  env["#5298<br/>Move environment/<br/>registries"]
  cli["#5300<br/>Retire the<br/>cli_setup_command shim"]
  docs["#5385<br/>Describe the<br/>package layout"]
  owners["next<br/>CODEOWNERS:<br/>per-package groups"]
  remove["0.10.0<br/>Remove the<br/>old paths"]
  compat --> linter
  linter --> prep
  prep --> config
  config --> utils
  utils --> core
  core --> client
  client --> trajectory
  trajectory --> verification
  verification --> metrics
  metrics --> artifacts
  artifacts --> srmods
  srmods --> su
  su --> model
  model --> modelbase
  modelbase --> agents
  agents --> data
  data --> harbor
  harbor --> rollouts
  rollouts --> rsplit
  rsplit --> testing
  testing --> orch
  orch --> sup
  sup --> eval
  eval --> env
  env --> cli
  cli --> docs
  docs --> owners
  owners --> remove
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef later fill:#f3f4f6,stroke:#9ca3af,color:#4b5563,stroke-dasharray: 4 3
  class harbor this
  class owners,remove later
Loading

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 this
Loading
  • prepare.py is a git rename of the module, so its history follows it. The run commands are appended to cli/eval.py unchanged.
  • cli/eval.py imports the preparation steps it calls from prepare.py, a downward import. Nothing in data/ imports cli/ 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.cli is the same module object as nemo_gym.data.tasks.harbor.prepare.
  • Every name that moved to cli/eval.py resolves at the old path with one warning, through a __getattr__ on prepare.py.
  • Patches that change with the split. The old module, nemo_gym.tasks.harbor.cli, is now nemo_gym.data.tasks.harbor.prepare, so a patch through either path lands on prepare.py:
    • No effect: a patch there of a name the run commands now look up in cli/eval.py succeeds but no longer reaches them. That covers run_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 as write_run_summary, summarize_validation and build_options_from_overrides. Patch them on nemo_gym.cli.eval.
    • Partial effect: cli/eval.py imports prepare_target, resolve_agent, resolve_sandbox_config and build_run by name. A patch of them on prepare.py reaches only prepare.py's own callers, so to change what the run commands call, patch them on nemo_gym.cli.eval.
    • In this repo, tests that drive the run commands patch them on nemo_gym.cli.eval. Their extra patches of prepare_target, resolve_agent and resolve_sandbox_config on prepare.py were 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:

  1. Rename only: data/tasks/harbor/cli.py becomes data/tasks/harbor/prepare.py.
  2. Everything else: the split, the MOVED_MODULES and MOVED_NAMES entries, in-repo references rewritten by scripts/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.
  3. Docs and checks:
    • prepare.py's docstring now describes preparation only and points to nemo_gym.cli.eval.run_target and validate_target; its references to the override readers name nemo_gym.cli.eval, and prepare_builds.py and validation_report.py name their callers instead of cli.py.
    • A new facade test checks that every name code outside 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 with ORACLE_AGENT removed from nemo_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, and git log --follow does not.

Public API

Every layout package that exists after this PR has a lazy public API in its __init__.py: the names code outside nemo_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 outside nemo_gym/ and its tests (servers and their tests, benchmarks, scripts, and docs) imports those names from nemo_gym.<package>, so later moves inside a package leave it alone. Code inside nemo_gym/, and the library's tests under tests/, 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.md states the rule.

Validation

  • pytest -n 16 tests/unit_tests, also with -W error for the old Harbor CLI path and names. The only failures are environment-specific and unrelated to the move: this machine's hostname resolves to 127.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 run on the changed files.
  • Server and agent tests run in CI.

Rollout evidence: N/A. The code moves unchanged; gym eval run and gym dataset validate behave as before.

Compatibility

  • Old paths work until 0.10.0, with one warning each, and give the same objects.
  • The run commands now log under nemo_gym.cli.eval.
  • from nemo_gym.tasks.harbor import cli gives the preparation module, as import nemo_gym.tasks.harbor.cli does. 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.
  • Open branches: run python scripts/migrate_imports.py <paths>.

Issue

Part of #5166.

@ananthsub
ananthsub added this pull request to stack #5170 October 28, 2026 22:09
@copy-pr-bot

copy-pr-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

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 svcnvidia-nemo-ci added area:cli Command-line interfaces and user-facing command behavior feature New capabilities, enhancements, or enablement work labels Oct 28, 2026
@ananthsub ananthsub added the area:core Shared APIs, servers, telemetry, health, and registries label Oct 28, 2026
@ananthsub ananthsub changed the title ananthsub/layout harbor cli refactor(data): split the Harbor run commands out of the task CLI module Oct 28, 2026
@ananthsub
ananthsub requested a review from yaoyu-33 October 28, 2026 22:11
@ananthsub ananthsub added the needs-review PR is ready for code review and waiting on a reviewer label Oct 28, 2026
@ananthsub
ananthsub marked this pull request as ready for review October 28, 2026 22:11
@ananthsub
ananthsub requested a review from a team as a code owner October 28, 2026 22:11
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 28, 2026 22:11

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread nemo_gym/_moved_paths.py Resolved
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

@ananthsub
ananthsub force-pushed the ananthsub/layout-harbor-cli branch from c487097 to 3c6a4b1 Compare October 29, 2026 15:15
@ananthsub
ananthsub force-pushed the ananthsub/layout-harbor-cli branch from 3c6a4b1 to d536899 Compare October 29, 2026 15:51
@ananthsub
ananthsub removed this pull request from stack #5170 October 29, 2026 15:55
@ananthsub
ananthsub added this pull request to stack #5319 October 29, 2026 15:56
@ananthsub
ananthsub force-pushed the ananthsub/layout-harbor-cli branch from d536899 to c96617e Compare October 29, 2026 17:01
@ananthsub
ananthsub force-pushed the ananthsub/layout-harbor-cli branch from c96617e to 168d2b2 Compare October 29, 2026 18:25

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 into nemo_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: --help output is byte-identical before and after for gym, gym eval run, gym dataset validate, gym dataset pull and their siblings, and argument parsing and dispatch match on 8 argv. A local gym dataset validate and gym eval run smoke 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.cli is the same module as prepare, 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_NAMES entries at _moved_paths.py:544-598 are 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.cli of run_target, validate_target, the *_from_overrides readers, write_run_summary, summarize_validation or build_options_from_overrides still succeeds, but it no longer reaches the run commands.
    • Partial effect: cli/eval.py binds prepare_target, resolve_agent, resolve_sandbox_config and build_run by value, so an old-path patch of them reaches only prepare.py's own callers.

Optional

  • In tests that drive run_target/validate_target, the monkeypatch.setattr(harbor_cli, ...) twins for prepare_target, resolve_agent and resolve_sandbox_config are never read. Examples are test_harbor_image_build.py:706 and test_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 suite shards 0 and 1 fail on the ORACLE_AGENT ImportError, in environment_servers/harbor and responses_api_agents/harbor_oracle_agent respectively. Nemo_CICD_Test and the Server suite roll-up follow from them.
  • Harness conformance (non-blocking) / kilocode fails the model_error scenario, the same failure seen across this stack.
Items for other PRs in the stack
  • #5167:
    • moved_names_getattr has no __dir__, so dir() on an old split module drops the moved names, although hasattr still finds them.
    • A pytest monkeypatch.setattr(old_module, moved_name) followed by undo() 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.py rewrites import nemo_gym.tasks.harbor.cli as harbor_cli but leaves harbor_cli.run_target attribute accesses going through the deprecated getter.
  • #5229: fern/docs.yml redirects the nemo_gym/tasks package page but not the per-module nemo_gym/tasks/harbor/<module> reference pages.

Comment thread nemo_gym/data/__init__.py Resolved
Comment thread nemo_gym/data/tasks/harbor/prepare.py Resolved
@ananthsub

ananthsub commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Replies to the summary, as of 74d8445cbc:

  • Patch targets (process note): the description's "What stays importable" section now lists both groups by name. A patch through the old path or prepare.py of a name the run commands now look up in cli/eval.py has no effect. A patch of prepare_target, resolve_agent, resolve_sandbox_config or build_run there reaches only prepare.py's own callers, because cli/eval.py imports them by name.
  • Unread test patches (optional): removed. Every monkeypatch.setattr(harbor_cli, ...) of prepare_target, resolve_agent or resolve_sandbox_config in a test that also patches the same name on cli_eval is gone: 13 in all, in tests that call the run commands directly or through gym eval run. Each was checked first by replacing its value with a function that fails when called, and each test still passed, so none was read.
  • refactor(data): move the task data modules into nemo_gym/data #5229 redirects: fixed there. fern/docs.yml redirects every page under nemo_gym/tasks/ with a :path* pair.
  • feat(compat): keep old import paths working across the package reorganization #5167 items: not changed in this stack, because feat(compat): keep old import paths working across the package reorganization #5167 has merged. moved_names_getattr has no __dir__; monkeypatch.setattr on an old split module followed by undo() leaves the real object in the old module's __dict__; and migrate_imports.py leaves attribute access through a rewritten module alias going through the deprecated getter. These stay as follow-ups.

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]>

This branch was previously deployed

1 inactive deployment
public — 74d8445c Deployed Nov 3, 2026 by copy-pr-bot[bot] via release / finalize / notify #9401
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli Command-line interfaces and user-facing command behavior area:core Shared APIs, servers, telemetry, health, and registries feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants