Skip to content

refactor(verification): move nemo_gym.verifiers into verification/ - #5561

Open
ananthsub wants to merge 1 commit into
mainfrom
ananthsub/verification-python-verifier
Open

ananthsub wants to merge 1 commit into
mainfrom
ananthsub/verification-python-verifier

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Moves the Harbor Python verifier helpers from nemo_gym/verifiers/ into nemo_gym/verification/python_verifier/, and removes nemo_gym/verifiers/.

Before this PR, the helpers for verifying submissions lived under two top-level names:

  • verification/ held the helpers that resources servers use, such as LLM judges.
  • verifiers/ held the helpers that a Harbor task's verifier.py imports, plus the runner that calls verify inside the sandbox.

The two names were one word apart, so it wasn't clear which one to use. Now both sets of helpers live in verification/.

Where this PR sits

This is a follow-up to the package reorganization (#5166), after the stack and #5536.

flowchart LR
  stack["#5167 to #5385<br/>Package reorganization"]
  groups["#5536<br/>Group #5072's modules"]
  this["This PR<br/>Move verifiers/ into<br/>verification/"]
  remove["0.10.0<br/>Remove the<br/>old paths"]
  stack --> groups
  groups --> this
  this --> remove
  classDef thispr fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef later fill:#f3f4f6,stroke:#9ca3af,color:#4b5563,stroke-dasharray: 4 3
  class this thispr
  class remove later
Loading

What moves

Old path New path
nemo_gym/verifiers/__init__.py nemo_gym/verification/python_verifier/__init__.py
nemo_gym/verifiers/files.py nemo_gym/verification/python_verifier/files.py
nemo_gym/verifiers/runner.py nemo_gym/verification/python_verifier/runner.py

The modules move unchanged, apart from docstrings that name their own path. Verifier code now imports from the new path:

from nemo_gym.verification.python_verifier import exact_match, final_text
from nemo_gym.verification.python_verifier.files import read_text

Why a subpackage

The helpers could sit flat in verification/. They get their own folder because they follow different rules from the rest of the package: they run in the sandbox, use only the standard library, and keep to Python 3.8, while judge.py, verifier_fixture.py and sandbox_verification.py run on the host and import the rest of Gym.

  • The shim copies a folder, not a list. It copies every .py file in python_verifier/. Flat modules would need a hard-coded list of the files allowed into the sandbox, and a new helper missing from the list would fail only inside the sandbox.
  • The sandbox rules cover the folder. The Python 3.8 check and the standard-library-only test apply to everything in it, and the path tells a reviewer which rules a file follows.
  • Authors import from the package itself. The helpers are defined in the subpackage's __init__.py, so a verifier writes from nemo_gym.verification.python_verifier import exact_match. Importing them from nemo_gym.verification instead would need that package's lazy public API, which depends on nemo_gym._public_api and serves the host modules. The sandbox would then need a second, hand-written verification/__init__.py.

How the helpers reach the sandbox

The helpers run inside the verifier sandbox, under whatever Python 3.8 or newer the task image has. Nothing else from nemo_gym is available there. The shim copies the helpers into the .ng/ folder that it uploads over /tests:

flowchart TD
  host["Host: nemo_gym/verification/python_verifier/"]
  shim["write_shim"]
  pkg[".ng/nemo_gym/verification/python_verifier/<br/>copies of the helpers"]
  parents[".ng/nemo_gym/__init__.py and<br/>.ng/nemo_gym/verification/__init__.py<br/>empty"]
  alias[".ng/nemo_gym/verifiers/__init__.py<br/>old-path alias, until 0.10.0"]
  verifier["The task's verify()"]
  host --> shim
  shim --> pkg
  shim --> parents
  shim --> alias
  verifier -->|"new path"| pkg
  verifier -->|"old path"| alias
  alias --> pkg
Loading
  • New location: the shim vendors the helpers at .ng/nemo_gym/verification/python_verifier/.
  • Empty parents: it writes empty __init__.py files for nemo_gym and nemo_gym.verification. The sandbox then never runs the real nemo_gym.verification package, whose __init__.py depends on the rest of nemo_gym.
  • Layering: the import-linter contract now checks the helpers as part of the verification layer. That layer allows imports of lower layers, but the sandbox has none of them, so a new test fails if a vendored module imports anything outside the standard library and its own package.

Compatibility

nemo_gym.verifiers was on main before the reorganization, so it gets an old path like the other moved modules. It keeps working until 0.10.0.

  • On the host: a MOVED_MODULES entry serves nemo_gym.verifiers, nemo_gym.verifiers.files and nemo_gym.verifiers.runner from the new modules, with a DeprecationWarning.
  • In the sandbox: the host's moved-path finder isn't available there. The shim therefore also writes .ng/nemo_gym/verifiers/__init__.py, an alias that registers the vendored modules under their old names. It prints one line to stderr (the verifier log) saying where the helpers moved and when the old path is removed.
  • Removal: the shim writes the alias only while the MOVED_MODULES entry exists. The test that fails once the version reaches 0.10.0 with the entry still present therefore removes both together.
  • Already published tasks: a task published with gym dataset publish --harbor carries its own copy of the old package in tests/.ng/, so it keeps grading under Harbor without changes.
  • Docs: fern/docs.yml redirects the old library reference pages to the new ones.

How to review

One commit. Its changes:

  1. The move: three renames, with docstring updates only.
  2. Mechanical rewrites: scripts/migrate_imports.py updated the in-repo imports, docs, and the hello_verifier_reuse examples. I reverted its changes to the two example lines that name an old path on purpose (nemo_gym.server_utils in AGENTS.md and the API reference).
  3. The shim (nemo_gym/data/tasks/harbor/python_verifier.py): the new vendoring path, the empty parent __init__.py files, and the alias.
  4. Docs: AGENTS.md, the API reference, and the Harbor tasks page say where the helpers live and that they import nothing from nemo_gym. The Harbor tasks page also notes the old path.
  5. Tests:
    • The shim layout tests expect the new files.
    • The test that plants a fake nemo_gym in the task's tests/ folder now plants it at the new path.
    • New tests check that a verifier written against the old path still grades in a fresh interpreter and that the log names the new path; that the shim drops the alias once the MOVED_MODULES entry is gone; and that the vendored modules and the alias import only the standard library.
    • verifiers is no longer exempt from the layer coverage test.

Validation

  • pytest -n 16 tests/unit_tests.
  • pytest environment_servers/harbor/tests.
  • lint-imports.
  • pre-commit run on the changed files.
  • Python 3.8 container check: in a real python:3.8-slim container, I ran the shim's test.sh for two verifiers. One was hello_verifier_reuse/exact-greeting, which imports from the new path. The other was the same check written against nemo_gym.verifiers. Both returned a reward of 1.0. The second also printed the deprecation line naming the new path and 0.10.0.
  • Server and agent tests run in CI.

Rollout evidence: N/A. No agent or model behavior changes. The only change at run time is where the shim puts the helpers inside the verifier sandbox, which the container check above exercises.

Issue

Follow-up to #5166.

The Harbor Python verifier helpers move from nemo_gym/verifiers/ to
nemo_gym/verification/python_verifier/, beside the other helpers for
verifying submissions. nemo_gym/verifiers/ is removed, and the
verification package is no longer split across two top-level names.

The helpers still import nothing from nemo_gym and keep to Python 3.8,
because the shim copies them into the verifier sandbox. The shim now
vendors them at .ng/nemo_gym/verification/python_verifier/, with empty
parent __init__.py files.

The old path keeps working until 0.10.0. On the host it has a
MOVED_MODULES entry. In the sandbox, the shim also writes an alias
package at .ng/nemo_gym/verifiers/ that serves the same modules and
prints where they moved. The shim writes the alias only while the
MOVED_MODULES entry exists, so both go away together.

Signed-off-by: Ananth Subramaniam <[email protected]>

@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 — LGTM — no concerns found.

I reviewed all 19 changed files and traced the affected host imports, sandbox vendoring, Harbor uploads, publishing, and regression tests. I found no material correctness or compatibility regression.

This was a static review. I didn't execute tests or build the documentation.

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.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 5, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added support User questions, support, or maintenance requests needs-review PR is ready for code review and waiting on a reviewer area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters labels Nov 7, 2026

This branch was previously deployed

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

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA support User questions, support, or maintenance requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants