Skip to content

refactor(data): move the task data modules into nemo_gym/data - #5229

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/layout-data
Nov 2, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/layout-data

Conversation

@ananthsub

@ananthsub ananthsub commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Moves task data into a new nemo_gym/data/ package: datasets and their preparation, prompts, task rows and their materialization, and task formats such as Harbor. The Harbor task CLI is split between data/ and cli/ in the next PR, so this one moves whole modules only.

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 data this
  class owners,remove later
Loading

Where the package sits

flowchart TD
  cli["cli/"]
  eval["eval/"]
  environment["environment/"]
  orchestration["orchestration/"]
  rollouts["rollouts/"]
  data["data/"]
  agents["agents/"]
  model["models/"]
  server_runtime["server_runtime/"]
  artifacts["artifacts/"]
  metrics["metrics/"]
  verification["verification/"]
  trajectory["trajectory/"]
  sandbox["sandbox/"]
  client["client/"]
  telemetry["telemetry/"]
  core["core/"]
  utils["utils/"]
  config["config/"]
  cli --> eval
  cli --> environment
  cli --> orchestration
  eval --> rollouts
  environment --> data
  orchestration --> data
  rollouts --> data
  rollouts --> agents
  rollouts --> model
  data --> server_runtime
  data --> artifacts
  agents --> server_runtime
  model --> server_runtime
  server_runtime --> metrics
  server_runtime --> verification
  server_runtime --> trajectory
  artifacts --> trajectory
  artifacts --> utils
  metrics --> utils
  verification --> sandbox
  trajectory --> core
  sandbox --> client
  client --> telemetry
  client --> utils
  telemetry --> core
  core --> config
  utils --> config
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef done fill:#d1fae5,stroke:#047857,color:#1f2937
  classDef todo fill:#f3f4f6,stroke:#9ca3af,color:#4b5563
  class data this
  class config,utils,core,telemetry,client,trajectory,verification,metrics,artifacts,server_runtime,models,agents done
  class cli,eval,environment,orchestration,rollouts,model,sandbox todo
Loading

An arrow means "imports"; each package imports only packages below it. Yellow: created by this PR. Green: created by an earlier PR in the stack. Grey: still to come.

What moves

Whole modules, unchanged:

Old path New path
nemo_gym/prompt.py nemo_gym/data/prompt.py
nemo_gym/vision_input.py nemo_gym/data/vision_input.py
nemo_gym/task_data.py nemo_gym/data/task_data.py
nemo_gym/task_materialization.py nemo_gym/data/task_materialization.py
nemo_gym/tasks/ nemo_gym/data/tasks/
nemo_gym/dataset_metrics.py nemo_gym/data/dataset_metrics.py
nemo_gym/dataset_orchestrator.py nemo_gym/data/dataset_orchestrator.py
nemo_gym/train_data_utils.py nemo_gym/data/dataset_preparation.py
nemo_gym/hf_utils.py nemo_gym/data/hf_utils.py
nemo_gym/gitlab_utils.py nemo_gym/data/gitlab_utils.py

How to review

One commit. Its changes:

  1. Renames, with no content changes.
  2. Everything else:
    • The moves are recorded in MOVED_MODULES in nemo_gym/_moved_paths.py.
    • In-repo references are rewritten by scripts/migrate_imports.py.
    • The contract's data layer becomes the nemo_gym.data package.
    • fern/docs.yml redirects the old library reference pages to the new ones, including every page under nemo_gym/tasks/.
    • The Harbor package's __init__.py becomes a lazy public API, like the layout packages, instead of importing six names eagerly.
    • The rewrite also covers resources_servers/agentic_turn_simulation and responses_api_agents/agentic_turn_simulation_agent, which Agentic turn simulation environment #5027 merged with old import paths such as nemo_gym.server_utils and nemo_gym.openai_utils.
    • Comments and docs that named the old files by path now name the new ones: the lazy-import note in cli/eval.py, two IHEval comments, the .gitignore note on pulled Harbor datasets, and the auto-download source in the Hugging Face download guide.
    • tasks is recorded as a package, so every Harbor task module resolves at its old path. Sandboxes import only nemo_gym.verifiers, which does not move, so no sandbox script needs a fallback here.
    • By hand: the sandbox policy test built the path to the Harbor task modules from parts ("nemo_gym" / "tasks"), which the rewriter does not see.
    • The contract's five exceptions for the Harbor CLI and digest keep their entries under the new paths; the next PR's split removes the CLI ones.
    • By hand: harness_agent's source tarball excluded every directory named data, which would have dropped nemo_gym/data/ from the sandbox's copy of Gym. It now excludes only the agent's own data/, and a test builds the tarball and checks both.
  3. Tests: the dataset, prompt, task data, task materialization, and data source tests move into tests/unit_tests/data/; test_train_data_utils.py becomes test_dataset_preparation.py with its module. The Harbor tests stay for now: several read fixtures by path and drive the environment server too.

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.

nemo_gym.data.tasks.harbor has a public API of its own. Harbor is one task format in data/tasks/, and many of its names, such as load_task, DIGEST_KEY and TaskDataSchema, do not name the format. Exported from nemo_gym.data, they would read as generic task-data names, and a second task format would collide with them. So code outside nemo_gym/ imports Harbor names from nemo_gym.data.tasks.harbor, and nemo_gym.data exports only the package's own names. The generic materialize_task and load_task_data_schema are in nemo_gym.data, because their Harbor namesakes now live in the Harbor API. AGENTS.md states the rule, and the facade tests and the public-import check cover a nested API.

Validation

  • pytest -n 16 tests/unit_tests, also with -W error for the moved paths. 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 modules move unchanged.

Compatibility

  • Old paths work until 0.10.0, with one warning each, and give the same module objects.
  • Logger names follow the module path, so these modules now log under nemo_gym.data.*. A logging config set on nemo_gym still covers them.
  • 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 21:43
@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.

@ananthsub ananthsub added feature New capabilities, enhancements, or enablement work area:core Shared APIs, servers, telemetry, health, and registries labels Oct 28, 2026
@ananthsub
ananthsub requested a review from yaoyu-33 October 28, 2026 21:44
@ananthsub ananthsub changed the title ananthsub/layout data refactor(data): move the task data modules into nemo_gym/data Oct 28, 2026
@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 21:44
@ananthsub
ananthsub requested a review from a team as a code owner October 28, 2026 21:44
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 28, 2026 21:44
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

@ananthsub
ananthsub force-pushed the ananthsub/layout-data branch from d2dd82f to e98feeb Compare October 29, 2026 15:15
@ananthsub
ananthsub force-pushed the ananthsub/layout-data branch from e98feeb to 99b65c6 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-data branch from 99b65c6 to 22081c4 Compare October 29, 2026 17:01

@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.

Thanks for the careful move. We found no blockers or risks. There are two small inline NOTEs and a few summary-only notes below. Verdict: SHIP.

What we checked at 419155a0

  • The move is mechanical. Every renamed module is AST-identical to its old version apart from imports and docstring paths. Every rewritten import (435 distinct bindings) resolves to the same object at the old and new path. The hand edits are the ones the body lists, plus the Harbor imports in note 1 below.
  • Old paths keep working. All 44 old modules (the nine modules, tasks, tasks.harbor and its 33 submodules) resolve to the identical module object with a DeprecationWarning. No mock.patch / monkeypatch target in the repo stops taking effect, so the #5166 list for this PR is empty.
  • The task-data contract is unaffected. No in-repo task_data.py schema imports nemo_gym; load_task_data_schema loads them by file path. A third-party schema that still uses from nemo_gym.task_data import ... loads, with one warning. import nemo_gym.data.task_data pulls in no third-party module beyond what nemo_gym.task_data did. normalize_task_fields, RESERVED_ROW_KEYS and the legacy-field map moved byte-identically.
  • Layers and the tarball. lint-imports is KEPT, and none of the five renamed exceptions is stale. The harness_agent tarball now ships nemo_gym/data/ and still leaves out the agent's own data/; the new test fails if either regresses.
  • Unit suite. No failures are caused by this PR, including a run with the moved-path DeprecationWarnings as errors. Every local failure also fails on the base tree or needs an extra / Linux.
  • CI is green except the non-blocking Harness conformance job, which fails on the kilocode model_error probe as on the earlier stack PRs.

Notes not tied to a diff line

  1. Harbor names re-exported by nemo_gym.data.tasks.harbor.
    • scripts/migrate_imports.py (Migrator._destinations) writes from nemo_gym.data.tasks.harbor import HarborTask, load_task for these names. The 17 environment_servers/harbor files here were converted by hand to from nemo_gym.data import ... instead, so open branches that run the script get the sub-package form.
    • test_code_outside_the_library_imports_exported_names_from_the_public_api keys on the module path in _PUBLIC_API, so it accepts the sub-package form.
    • The same test also accepts from nemo_gym.data.tasks.harbor.digest import DIGEST_KEY (environment_servers/harbor/tests/test_app.py:77, environment_servers/harbor/tests/test_identity.py:12), because nemo_gym/data/__init__.py:76 maps DIGEST_KEY to the re-exporting tasks.harbor rather than tasks.harbor.digest.
    • Could you list the hand conversion under "By hand" in the body? Matching on the object rather than one module path, in both the script and the test, belongs with #5167 / #5189.
  2. Stale prose that migrate_imports does not touch.
  3. The CLI-refactor shims now report the new module name. Each moved_attr_getter(__name__, ...) shim (nemo_gym/data/prompt.py:189, dataset_preparation.py:1443, dataset_orchestrator.py:63, gitlab_utils.py:154) now sees nemo_gym.data.<mod>.
    • So from nemo_gym.prompt import materialize_prompts_cli gives a second warning naming nemo_gym.data.prompt.materialize_prompts_cli, a path that was never published. The advice in it is still right.
    • This is the same as #5211's reward_profile. A stack-wide fix (pass the published old path literally) would cover both.
  4. Pre-existing, optional. fern/versions/latest/pages/data/download-huggingface.mdx:281 cites dataset_preparation.py:476-494 for auto-download; that code is around L761-792.

For #5230: splitting Harbor out removes the materialize_task / load_task_data_schema name collisions in the inline comment below. The ORACLE_AGENT entry (tasks.harbor.cli) in nemo_gym.data._PUBLIC_API will need to follow the CLI split.

Comment thread fern/docs.yml Resolved
Comment thread nemo_gym/data/__init__.py Resolved
yaoyu-33
yaoyu-33 previously approved these changes Nov 2, 2026

@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.

Approving at 419155a05b0e. The team review found no blockers or risks; the remaining inline notes are optional and can be handled here or in a follow-up.

@ananthsub

ananthsub commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Replies to the summary notes, as of 136e264bd8:

  1. Harbor names re-exported by nemo_gym.data.tasks.harbor.
    • nemo_gym.data.tasks.harbor now has a public API of its own, and nemo_gym.data exports only the package's own names. Harbor names such as load_task, DIGEST_KEY and TaskDataSchema do not name the format, so exporting them from nemo_gym.data would make them read as generic and leave no room for a second task format.
    • The Harbor environment server and the other Harbor importers now import from nemo_gym.data.tasks.harbor, which is also the form scripts/migrate_imports.py writes, so the two no longer disagree.
    • DIGEST_KEY maps to tasks.harbor.digest, the module that defines it.
    • Matching on the object rather than the module path, in both the script and the facade test, stays a follow-up: feat(compat): keep old import paths working across the package reorganization #5167 and refactor(config): move config modules into nemo_gym/config #5189 have merged.
  2. Stale prose. Fixed: the lazy-import note in nemo_gym/cli/eval.py and the two IHEval comments name dataset_preparation, and the .gitignore note names nemo_gym/data/tasks/harbor/hub.py.
  3. Shim warnings. Fixed by refactor(models): split model call capture out of the model server base and move the OpenAI client into client/ #5225, which changed moved_attr_getter to name the path the caller imported. from nemo_gym.prompt import materialize_prompts_cli now warns about nemo_gym.prompt.materialize_prompts_cli, the published path. The same fix covers reward_profile.
  4. Hugging Face download guide. The auto-download row now cites TrainDataProcessor.load_datasets() in nemo_gym/data/dataset_preparation.py instead of a line range, which would drift again.

For #5230: ORACLE_AGENT is now in the Harbor API. It maps to tasks.harbor.cli at this level and follows the module to tasks.harbor.prepare in #5230.

prompt.py, vision_input.py, task_data.py, task_materialization.py,
dataset_metrics.py, dataset_orchestrator.py, hf_utils.py,
gitlab_utils.py and the tasks package move as they are, and
train_data_utils.py becomes data/dataset_preparation.py.

Record the ten moves in MOVED_MODULES (tasks as a package), rewrite in-
repo references with scripts/migrate_imports.py, point the sandbox
policy test's path to the Harbor task modules at the new directory, make
the contract's data layer the nemo_gym.data package, and redirect the
old library reference pages in fern/docs.yml.

The task data test finds the repository root one level further up.

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 — 136e264b Deployed Nov 2, 2026 by copy-pr-bot[bot] via release / finalize / notify #9381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared APIs, servers, telemetry, health, and registries feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants