Skip to content

refactor(environments)!: fold the environments that share a benchmark's name into their benchmarks and refuse new shared names - #6692

Merged
ffrujeri merged 5 commits into
mainfrom
yuhez/fold-shared-environment-names
Nov 30, 2026
Merged

ffrujeri merged 5 commits into
mainfrom
yuhez/fold-shared-environment-names

Conversation

@yuhezhang-ai

@yuhezhang-ai yuhezhang-ai commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

A catalog name is its folder path under benchmarks/ or environments/ (_path_identity in nemo_gym/environment/registry.py). It should identify one catalog entry whatever its kind. Three top-level names were folders in both trees on main: labbench2_pdf, biomnibench_da and ether0. Their manifest names did not clash yet only because one folder of each pair has no manifest. Each pair is one task set, so each gets one catalog ID. The benchmarks keep their names, which are the upstream benchmarks' names, and the three environment folders are removed. A rule now keeps a new shared name from landing.

Environment folder Now Why
environments/labbench2_pdf Moved into benchmarks/labbench2_pdf/ It was the benchmark's implementation, and nothing else used it. The benchmark's config included its config, the benchmark's prepare.py imported three of its modules, and only harbor_agent_general's config test loaded its two profiles.
environments/biomnibench_da Moved to benchmarks/biomnibench_da/terminus_2/, a run preset of the benchmark with no manifest It downloads the same upstream dataset as the benchmark (phylobio/BiomniBench-DA). It differs only in its harness (Terminus 2 through harbor_agent with Gym's model server, where the benchmark uses OpenCode through harbor_agent_general) and in a seeded train/test partition. A harness-only difference is a preset of the benchmark, not a catalog entry.
environments/ether0 Removed It repeated resources_servers/ether0/configs/ether0.yaml with paths under environments/, lacking only oracle_max_concurrency. Its example data and prepare.py are byte-identical to the resources server's data/example*.jsonl and scripts/prepare_ether0.py.

Where things moved

  • LabBench2, all moved into benchmarks/labbench2_pdf/:
    • The Harbor job profiles: config.yaml became harbor_docker.yaml, which the benchmark's config.yaml includes, and config_singularity.yaml became harbor_singularity.yaml.
    • The task materializer prepare.py became materialize.py, because the benchmark already has a prepare.py.
    • data_utils.py, download_papers.py, download_questions.py, prepare_data.py, verifier.py, docker/ and .dockerignore moved beside it. ENV_ROOT is now BENCHMARK_DIR.
    • The README became harbor-tasks.md, which the benchmark README links to.
    • The example input and smoke-rollout evidence moved to data/, whose .gitignore keeps them and ignores generated files.
    • The tests moved to tests/, with test_prepare.py renamed test_materialize.py.
    • Downloads and generated Harbor tasks now go under benchmarks/labbench2_pdf/data/. Harbor job directories stay in results/labbench2_pdf/harbor_jobs.
    • harbor-tasks.md has a new "Move generated tasks" section: Docker tasks bind their papers by absolute path, so a tree generated under the old folder must be generated again from the moved caches.
  • BiomniBench-DA, the Terminus 2 preset in benchmarks/biomnibench_da/terminus_2/, kept apart from the benchmark's OpenCode adapter in harbor/:
    • config.yaml became harbor_docker.yaml and config_singularity.yaml became harbor_singularity.yaml.
    • prepare.py, docker/, .dockerignore, data/ (example input, rollouts and metrics) and tests/ moved with only path changes. ENV_ROOT is now PRESET_DIR.
    • The README now describes the folder as a preset with no manifest, and the benchmark README links to it.
    • Every path that named the old folder moved: the configs' local_dataset_path, prepare.py's examples and generator field, the example metrics' jsonl_fpath, the example rollouts' task paths, and the harbor_agent README's worked example.
    • In the benchmark folder: its .gitignore anchors data/ and logs/ to its root, so the preset's committed data/ is not ignored. A .dockerignore keeps terminus_2/ out of the benchmark image's build context (its Dockerfile copies nothing from it). An __init__.py makes the folder a package for the preset's tests.
  • ether0: benchmarks/ether0/prepare.py now imports format_row (the same function) from resources_servers/ether0/scripts/prepare_ether0.py, and its README links there.
  • responses_api_agents/harbor_agent_general/tests/test_config.py points at the two moved LabBench2 profiles.
  • None of the moved profiles is named config.yaml, and none declares a type: benchmark dataset. So gym list shows only the three benchmarks, and --benchmark biomnibench_da/terminus_2 selects nothing.
  • No reference in fern/, .github/, scripts/ (including scripts/ci/core_test_durations.json), .gitignore or the README table.

The rule

  • folder_in_other_catalog_tree (nemo_gym/environment/registry.py) returns the folder in the other tree of the same search root that has the name's top-level folder name.
  • gym env init --environment/--benchmark refuses such a name before it writes anything.
  • gym env validate refuses a manifest whose name's top-level folder is in the other tree.
  • tests/unit_tests/test_catalog_tree_names.py fails when a tracked top-level folder name exists in both trees of the repository.
  • The check is on the folder, so it also covers a folder without a manifest: its config is listed under the folder path. Two names can only be equal if their top-level folders are equal, so the top-level check covers nested names too.
  • Discovery (gym list) does not enforce the rule, so search roots whose trees already share a name keep listing both entries.
  • The name row in the manifest field reference (contribute/environments/new-environment.mdx) documents the rule.
  • The cross-tree check in feat(environment): make a manifest's name its ID instead of its folder path #6102 compared manifest names. That PR is deferred, and names stay path-shaped, so this PR checks folders instead.

No GitHub issue: this follows from keeping catalog names path-shaped (#6102 deferred). Internal tracking: GYMINT-932.

Compatibility and migration

Breaking: three environment folders are removed. The benchmarks' names, --benchmark selectors and configs are unchanged.

Before After
--environment labbench2_pdf, --config environments/labbench2_pdf/config.yaml --config benchmarks/labbench2_pdf/harbor_docker.yaml
--config environments/labbench2_pdf/config_singularity.yaml --config benchmarks/labbench2_pdf/harbor_singularity.yaml
environments/labbench2_pdf/{prepare_data,download_papers,download_questions,prepare}.py, environments.labbench2_pdf.* benchmarks/labbench2_pdf/..., with prepare.py now materialize.py; benchmarks.labbench2_pdf.*
--environment biomnibench_da, --config environments/biomnibench_da/config.yaml --config benchmarks/biomnibench_da/terminus_2/harbor_docker.yaml
--config environments/biomnibench_da/config_singularity.yaml --config benchmarks/biomnibench_da/terminus_2/harbor_singularity.yaml
environments/biomnibench_da/prepare.py, environments.biomnibench_da.prepare benchmarks/biomnibench_da/terminus_2/prepare.py, benchmarks.biomnibench_da.terminus_2.prepare
--environment ether0, --config environments/ether0/config.yaml --resources-server ether0: the same servers and datasets, with the resources server's oracle_max_concurrency: 8
environments.ether0.prepare resources_servers.ether0.scripts.prepare_ether0
  • Gym has no way to keep an old --environment name or config path working with a deprecation warning. nemo_gym/_moved_paths.py covers Python modules and names inside nemo_gym only, and asset_config_path maps a selector directly to a folder. The old names therefore stop resolving, and this PR does not add an alias mechanism.
  • Local data under the old folders is gitignored, so git leaves it behind. Until an old folder is deleted, gym env validate refuses the benchmark manifest of the same name and names the leftover folder.
  • Generated Docker task trees must be generated again, not moved. Each Docker task's docker-compose.yaml binds its data by absolute host path, so a moved tree still binds the old folder and loses that data once the old folder is deleted. Move the download caches, generate the Docker tasks again from them, then delete the old folder:
    • LabBench2: move environments/labbench2_pdf/data/source to benchmarks/labbench2_pdf/data/source, then run the command below with the first run's selection flags (--benchmarks, --limit-per-benchmark, --source-policy, --missing-paper, --image). With both directories supplied it downloads nothing, and the task names stay the same because they come from each question's position in the question snapshot. Users of the cataloged workflow can instead rerun gym eval prepare --benchmark labbench2_pdf with +prepare_script_args.questions_dir and +prepare_script_args.papers_dir set to the absolute paths of the moved caches and +prepare_script_args.build_image=false. "Move generated tasks" in benchmarks/labbench2_pdf/harbor-tasks.md has the steps.

      python benchmarks/labbench2_pdf/prepare_data.py \
        --questions-dir benchmarks/labbench2_pdf/data/source/questions \
        --papers-dir benchmarks/labbench2_pdf/data/source/papers \
        --environment-type docker \
        --overwrite
    • BiomniBench-DA: move environments/biomnibench_da/data/source to benchmarks/biomnibench_da/terminus_2/data/source, then rerun benchmarks/biomnibench_da/terminus_2/prepare.py --environment-type docker --overwrite for each Docker task tree, with --local-dir benchmarks/biomnibench_da/terminus_2/data/source, its new --output-dir (for the example, benchmarks/biomnibench_da/terminus_2/data/example) and the first run's selection and split flags. Without --download it downloads nothing.

  • Singularity task trees can be moved as they are. LabBench2 hard-links each task's papers into the task folder, BiomniBench-DA copies each task's data into it, and neither names a host path. Move environments/labbench2_pdf/data/tasks_singularity to benchmarks/labbench2_pdf/data/, and BiomniBench-DA Singularity trees such as data/example_singularity to benchmarks/biomnibench_da/terminus_2/data/.
  • ether0: a prepared environments/ether0/data/val.jsonl goes to resources_servers/ether0/data/.
  • Harbor job directories do not move: the LabBench2 profiles write them to results/labbench2_pdf/harbor_jobs and the BiomniBench-DA profiles to responses_api_agents/harbor_agent/jobs, as on main.
  • gym list environments no longer lists labbench2_pdf, biomnibench_da or ether0. It now lists resources_servers/ether0, the resources server's own config, which environments/ether0 used to hide.
  • Benchmark results are unaffected: every resolved config is identical to main apart from the paths that moved (see Validation).

Validation

  • uv run --frozen --extra dev pytest tests/unit_tests/test_catalog_tree_names.py tests/unit_tests/environment: 794 passed. The new tests cover refusal by gym env init and gym env validate from both trees, for a folder without a manifest and for a nested name's top-level folder. On main (17674bec9a), git ls-tree shows the three shared names that the new repository test rejects.
  • pytest benchmarks/labbench2_pdf/tests benchmarks/biomnibench_da/terminus_2/tests: 54 passed. The new LabBench2 tests cover three cases:
    • Docker tasks moved and then generated again: every /papers bind source exists under the new tree, and the task names are unchanged.
    • A moved Singularity tree names no host path.
    • The default task folders are inside the folder that holds materialize.py.
  • Moving generated tasks, offline, with fixture inputs: five questions across the three benchmarks, one of them missing its PDF.
    • Generated Docker and Singularity tasks with main's environments/labbench2_pdf/prepare_data.py. Then moved the caches and both task trees to benchmarks/labbench2_pdf/data/ and deleted the old folder.
    • After the move:
      • None of the 4 Docker /papers bind sources existed.
      • No file in the Singularity tasks named the old folder, and their staged PDFs were readable.
    • Generated both again with this branch's prepare_data.py --questions-dir … --papers-dir … --overwrite, with HTTP(S) proxies set to a closed port:
      • All 4 bind sources exist under benchmarks/labbench2_pdf/data/tasks_docker/_corpus_views/<benchmark>/papers and hold the expected PDFs.
      • The Docker and Singularity task names match the first run.
    • The same check on the BiomniBench-DA Terminus 2 preset, with its test fixture:
      • The moved Docker tree's bind source was missing.
      • The moved Singularity tree named no host path.
      • Generating again with the moved --local-dir binds data under terminus_2/data/source.
  • responses_api_agents/harbor_agent_general/tests/test_config.py, run in that agent's own locked environment: 38 passed, including both moved LabBench2 profiles.
  • gym env test --resources-server ether0: 124 passed, 4 skipped. This includes test_preparation.py, which imports benchmarks.ether0.prepare and through it the resources server's format_row.
  • gym env validate passes for --benchmark labbench2_pdf, --benchmark ether0, --benchmark biomnibench_da, --config benchmarks/biomnibench_da/terminus_2/harbor_{docker,singularity}.yaml --model-type vllm_model and --config benchmarks/labbench2_pdf/harbor_{docker,singularity}.yaml.
  • Catalog: gym list lists labbench2_pdf, ether0 and biomnibench_da as benchmarks, and none of the moved profiles. --benchmark biomnibench_da/terminus_2 does not resolve.
  • gym env resolve, on this branch and on main, ignoring randomly assigned ports:
    • benchmarks/biomnibench_da/terminus_2/harbor_{docker,singularity}.yaml against main's environments/biomnibench_da/config{,_singularity}.yaml: identical apart from local_dataset_path and the config_paths entry.
    • benchmarks/labbench2_pdf/harbor_{docker,singularity}.yaml against environments/labbench2_pdf/config{,_singularity}.yaml, and benchmarks/labbench2_pdf/config.yaml against itself: identical apart from the Harbor tasks path and the config_paths entry.
    • benchmarks/{ether0,biomnibench_da}/config.yaml: identical.
    • resources_servers/ether0/configs/ether0.yaml against environments/ether0/config.yaml: differs only in its own data paths and oracle_max_concurrency: 8.
  • Rule checked by hand: with a stray environments/ether0/config.yaml, gym env validate ether0 --kind benchmark refuses it and names the folder. gym env init --benchmark <taken environment name> refuses the name and writes nothing.
  • pre-commit run --files <58 changed files>: passed, with no files modified.
  • Repo-wide tests/unit_tests/{data/test_task_data.py,tooling,benchmarks}, test_packaging_paths.py, test_fern_docs_links.py and test_public_api_facades.py, run together with the environment tests above: 4521 passed and 20 failed. All 20 are in tests/unit_tests/tooling and tests/unit_tests/benchmarks/test_super35_batch_launcher.py, and these two folders give the same 20 failures on a clean main checkout on this machine. The causes are macOS-specific, such as bash 3.2's unbound-variable error on an empty array and APFS rejecting a non-UTF-8 filename.
  • Commits are signed off (DCO).

Rollout evidence

N/A. Folders, files and the paths that point into them move. The resolved configs are identical to main apart from those paths, and the code that runs is unchanged apart from module and constant names. The new rule runs only in gym env init, gym env validate and a unit test, never in a rollout.

🤖 Generated with Claude Code

yuhezhang-ai and others added 4 commits November 23, 2026 22:30
…sources server's config

A catalog name is its folder path under benchmarks/ or environments/, and
ether0 was a folder in both. environments/ether0 (#1472) repeats
resources_servers/ether0/configs/ether0.yaml with paths under
environments/ (it lacks only oracle_max_concurrency), and its example data
and prepare.py are byte-identical to the resources server's
data/example*.jsonl and scripts/prepare_ether0.py. The benchmark keeps the
name.

benchmarks/ether0/prepare.py now imports format_row from
resources_servers/ether0/scripts/prepare_ether0.py, the same function, and
its README links there.

Breaking: `--environment ether0` and config paths under
environments/ether0/ no longer resolve. `--resources-server ether0` loads
the same servers and datasets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
… benchmark

A catalog name is its folder path under benchmarks/ or environments/, and
labbench2_pdf was a folder in both. environments/labbench2_pdf was the
benchmark's implementation and nothing else used it: the benchmark's
config included its config, its prepare.py imported three of its modules,
and harbor_agent_general's config test loaded its two profiles. Its files
now live in benchmarks/labbench2_pdf/ and the environment folder is gone:

- config.yaml -> harbor_docker.yaml (the Harbor job profile that
  config.yaml includes) and config_singularity.yaml ->
  harbor_singularity.yaml. Neither declares a benchmark dataset, so the
  catalog does not list them.
- prepare.py -> materialize.py (the Harbor task materializer, since the
  benchmark already has a prepare.py); data_utils.py, download_papers.py,
  download_questions.py, prepare_data.py and verifier.py sit beside it,
  with docker/ and .dockerignore. ENV_ROOT is now BENCHMARK_DIR.
- README.md -> harbor-tasks.md, which the benchmark README links to for
  acquisition, task layout, direct runs and licensing.
- The example input and smoke-rollout evidence move to data/, whose
  .gitignore keeps them while ignoring generated files. Downloads,
  generated Harbor tasks and job directories now go under
  benchmarks/labbench2_pdf/data/.
- The tests move to tests/ (test_prepare.py -> test_materialize.py).

Breaking: `--environment labbench2_pdf`, config paths under
environments/labbench2_pdf/ and `environments.labbench2_pdf` imports no
longer resolve. Use `--config benchmarks/labbench2_pdf/harbor_docker.yaml`
(or harbor_singularity.yaml) and `benchmarks.labbench2_pdf`. The
benchmark's own name, config and selector are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
…benchmark as a Terminus 2 preset

A catalog name is its folder path under benchmarks/ or environments/, and
biomnibench_da was a folder in both. The environment (#1897) and the
benchmark (#3915) download the same upstream dataset,
phylobio/BiomniBench-DA. The environment only adds another harness
(Terminus 2 through harbor_agent with Gym's model server) and a seeded
train/test partition. A harness-only difference is a run preset of the
benchmark, without a manifest of its own, so the environment now lives in
benchmarks/biomnibench_da/terminus_2/, apart from the benchmark's OpenCode
adapter in harbor/:

- config.yaml -> harbor_docker.yaml, config_singularity.yaml ->
  harbor_singularity.yaml. Neither declares a benchmark dataset or is named
  config.yaml, so the catalog does not list them and
  `--benchmark biomnibench_da/terminus_2` selects nothing.
- prepare.py, docker/, .dockerignore, data/ (example input, rollouts and
  metrics) and tests/ move unchanged apart from paths. ENV_ROOT is now
  PRESET_DIR, and the test's repository root is one level further up.
- README.md is the preset's README, linked from the benchmark README; the
  harbor_agent README's worked example points at it.
- Every path naming the old folder moves: the configs' local_dataset_path,
  prepare.py's examples and generator, the example metrics' jsonl_fpath
  and the example rollouts' task paths.
- The benchmark's .gitignore anchors data/ and logs/ to its root so the
  preset's committed data/ is not ignored, a .dockerignore keeps
  terminus_2/ out of the benchmark image's build context, and an
  __init__.py makes the folder a package for the preset's tests.

Breaking: `--environment biomnibench_da`, config paths under
environments/biomnibench_da/ and `environments.biomnibench_da` imports no
longer resolve. Use `--config
benchmarks/biomnibench_da/terminus_2/harbor_docker.yaml` (or
harbor_singularity.yaml) and `benchmarks.biomnibench_da.terminus_2`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
…e has

A catalog name is its folder path, and it identifies one entry whatever
its kind, so a top-level folder name is used in only one of benchmarks/
and environments/. This holds for folders without a manifest too, since
their config is listed under the folder path.

- registry.folder_in_other_catalog_tree returns the folder in the other
  tree of the same search root that has a name's top-level folder name.
- `gym env init --environment/--benchmark` refuses such a name before it
  writes anything.
- `gym env validate` refuses a manifest whose name's top-level folder is
  in the other tree.
- tests/unit_tests/test_catalog_tree_names.py fails when a tracked
  top-level folder name is in both trees of the repository.

Discovery (`gym list`) does not enforce it, so search roots whose trees
already share a name keep listing both entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
@yuhezhang-ai
yuhezhang-ai requested a review from a team as a code owner November 24, 2026 03:56
@copy-pr-bot

copy-pr-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

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

SHIP WITH CARE — one migration risk: moving existing LabBench2 Docker tasks leaves their PDF bind mounts pointing at the removed directory.

I reviewed all 68 changed files, surrounding implementations, callers, configs, tests and existing feedback. No other concerns found.

Focused probes in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:main-offline, Python 3.13.14, showed:

  • Catalog collisions are rejected without writes; unrelated names work and discovery remains tolerant.
  • Only the three intended benchmarks are cataloged; moved Harbor profiles are not added as benchmarks.
  • Base/head preparation preserved task identities and verifier behavior. Biomni Docker/Singularity outputs and ether0 formatting matched after expected path normalization.
  • Following the LabBench2 move-only migration produced a missing bind source. Re-materialization from moved caches repaired it without downloading or changing task identity.

CI evidence on this head: lint, secrets, copyright, DCO and lock-freshness checks passed. Unit/server-suite results were unavailable; the PR comment reports runner vetting is required. Formal reviews and inline comments were empty. I did not rerun repository suites or perform live container/model rollouts.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added feature New capabilities, enhancements, or enablement work area:env-infra Shared environment framework, lifecycle, registry, scaffolding, and validation needs-review PR is ready for code review and waiting on a reviewer labels Nov 24, 2026
A Docker task's docker-compose.yaml binds its corpus view at /papers by
the view's absolute host path, so a tasks_docker tree moved from
environments/labbench2_pdf/data still binds the folder it was generated
in and loses /papers once that folder is gone. harbor-tasks.md now
requires moving the question and PDF caches and generating the tasks
again from them with prepare_data.py (--questions-dir, --papers-dir,
--overwrite), which downloads nothing and keeps the task names.
Singularity tasks hold hard links to their papers and name no host
path, so a moved tasks_singularity tree keeps working.

Tests cover generating again after a move (every /papers bind source
exists under the new tree, same task names), a moved Singularity tree
naming no host path, and the default output folders sitting in the
folder that holds materialize.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
@yuhezhang-ai

Copy link
Copy Markdown
Contributor Author

/ok to test 16408d1

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 24, 2026 15:52
@github-actions

Copy link
Copy Markdown
Contributor

@yaoyu-33
yaoyu-33 requested a review from agronskiy November 24, 2026 17:40
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 25, 2026

@ffrujeri ffrujeri 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. One name, one catalog entry: the guard is in gym env init, gym env validate and a repository test, and the migration table covers the three removed paths. LGTM.

@ffrujeri
ffrujeri enabled auto-merge November 30, 2026 19:33
@ffrujeri
ffrujeri added this pull request to the merge queue Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/46501693676

Merged via the queue into main with commit 36acf4a Nov 30, 2026
68 of 70 checks passed
@ffrujeri
ffrujeri deleted the yuhez/fold-shared-environment-names branch November 30, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:env-infra Shared environment framework, lifecycle, registry, scaffolding, and validation feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer risk:high Autobot PR risk: high sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants