Repository navigation
refactor(trajectory): move the trajectory modules into nemo_gym/trajectory - #5209
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. |
62b9f1c to
8996547
Compare
8996547 to
065c64b
Compare
16caed2 to
e35f4bb
Compare
e35f4bb to
7b92bf2
Compare
7b92bf2 to
bf80261
Compare
bf80261 to
e3cf2fd
Compare
yaoyu-33
left a comment
There was a problem hiding this comment.
Thanks for keeping this move strictly mechanical again; it made it easy to check. We found no blockers or risks, only two small docs notes inline.
What this PR does. It moves the trajectory data model into a new nemo_gym/trajectory package unchanged: rollout_observability.py (renamed trajectory_record.py) and the four ATIF modules. It gives the package a lazy public API, records the moves in _moved_paths.py, points the import-linter trajectory layer at the package, and redirects the old library-reference pages.
What we checked
- Moves.
trajectory_record.py,atif_json.py,atif_v1_7.pyand both ATIF fixtures are byte-identical renames.atif_export.py,atif_reverification.pyand the three moved tests differ only in their imports. Of the 123 changed Python files, 121 differ only in imports; the other two are_moved_paths.pyand the fixture path intest_rollout_reverification.py. - Imports. All 397 rewritten import sites bind the same objects as before. The 18 names in
nemo_gym.trajectory's_PUBLIC_APIare exactly the names that code outside the library imports.lint-importskeeps the contract (17 ignored imports, with thetrajectory_record -> observability.model_callsexception renamed), and the trajectory modules import onlyconfig,coreand each other. - Old paths. All five old module paths give the same module object with one warning each, and every name
import_surface.jsonrecords for them resolves to the identical object. Objects pickled under the old module paths unpickle to the same classes. - Formats. ATIF export,
transcript_to_atif, the reverification payloads,TrajectoryRecordJSON and the model JSON schemas are byte-identical between base and head; nothing writes a module path into output. Committed pre-moveng_trajectoryrows still validate. - Sandboxes.
nooa_agent/sandbox_entrypoint.pyis the only changed file that importsnemo_gyminside a sandbox. The NOOA runtime ships the current checkout'snemo_gym/**/*.py, keyed by a content fingerprint, so it needs no old-path fallback. No uploaded runner that can meet a prebuiltgym_sourcebundle imports a trajectory module. - Wiring. The ten redirects (unversioned and
/:version/), the CODEOWNERS suggestion and packaging are in order. No workflow path filter orharness_conformance/ci.pyrule names the old files. - Tests.
pytest tests/unit_tests -n 8with the moved-pathDeprecationWarnings turned into errors passed 12,433 tests and raised none. Each local failure either also fails at the base (optional dependencies missing from the dev venv, Docker, macOS SSL) or was a timing failure under load that passed when re-run alone. Every touched server and agent passes in CI in its own venv.
CI. The red checks are not from this change. Unit tests / Test fails on the same 13 test IDs as #5206: 11 Harbor tests on a Docker Hub HTTP 429 for ubuntu:24.04, and the 2 telemetry tests described below. Server suite (shard 3) fails in responses_api_models/openai_model as on #5206, and the kilocode harness-conformance failure is the same model_error scenario as on #5206 and #5203.
PR description. The Compatibility note about logger names has nothing to apply to here: none of the five modules creates a logger.
For other PRs in the stack (not blocking this one)
- #5206:
tests/unit_tests/telemetry/test_propagation.py:280patchesnemo_gym.utils.server_process.get_nemo_gym_fastapi_num_workers, butnemo_gym/client/http_client.pybinds that name directly, so the patch never reaches the client. That is whytest_lazy_client_initialization_failure_is_inside_the_client_span[False/True]fail in CI ("Cannot connect to host 127.0.0.1:80").telemetry/test_connection_pool.py:98uses the same target, so itsworkers=4cases run with one worker. Patchingnemo_gym.client.http_client.get_nemo_gym_fastapi_num_workersfixes both. The AGENTS.md rule that a patch target "names the module that defines the name" may be worth rewording to the module the code under test looks the name up in. - #5206:
.agents/skills/add-harness/SKILL.md:186, three observability pages (distributed-tracing.mdx,metrics.mdx,span-groups.mdx) andnemo_gym/telemetry/README.mdstill nameserver_utils.request(). - #5167:
from nemo_gym import <moved module>attributes itsDeprecationWarningtonemo_gym/__init__.py, so the default filters hide it in scripts;import nemo_gym.<old path>warns at the caller's line. Adding thenemo_gym/__init__frame to_SKIP_FILE_PREFIXESfixes it.
yaoyu-33
left a comment
There was a problem hiding this comment.
Approving at c18e37e1cb27, the commit we reviewed. The two inline docs notes are non-blocking. The red checks are the failures shared with #5206 that the review summary describes: the Harbor Docker Hub 429s, the two telemetry tests from #5206, openai_model in server shard 3, and the kilocode conformance scenario.
…ctory rollout_observability.py becomes trajectory/trajectory_record.py, and the four ATIF modules move as they are. Record the five moves in MOVED_MODULES, rewrite in-repo references with scripts/migrate_imports.py, make the contract's trajectory layer the nemo_gym.trajectory package, and redirect the old library reference pages in fern/docs.yml. The ATIF fixtures move with them; the rollout reverification tests read them from the new place. 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
Moves the trajectory data model into a new
nemo_gym/trajectory/package: the records of what happened in a rollout (rollout_observability.py, renamedtrajectory_record.py) and the ATIF export and import modules. Agents, the rollout collector, and evaluation all read these records, so they sit low in the order, aboveclient/.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.
Where the package sits
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:
nemo_gym/rollout_observability.pynemo_gym/trajectory/trajectory_record.pynemo_gym/atif_export.pynemo_gym/trajectory/atif_export.pynemo_gym/atif_reverification.pynemo_gym/trajectory/atif_reverification.pynemo_gym/atif_json.pynemo_gym/trajectory/atif_json.pynemo_gym/atif_v1_7.pynemo_gym/trajectory/atif_v1_7.pyHow to review
One commit. Its changes:
MOVED_MODULESinnemo_gym/_moved_paths.py.scripts/migrate_imports.py.trajectorylayer becomes thenemo_gym.trajectorypackage.fern/docs.ymlredirects the old library reference pages to the new ones.trajectory_record.pyimportsModelCallRecordfor type annotations only, fromobservability.model_calls. refactor(rollouts): move rollout collection and health into nemo_gym/rollouts #5231 movesModelCallRecordintotrajectory/, which removes it.tests/unit_tests/trajectory/, with the two ATIF fixtures they read. The rollout reverification tests read those fixtures from the new place.Public API
Every layout package that exists after this PR has a lazy public API in its
__init__.py: the names non-test code outsidenemo_gym/imports from it (servers, benchmarks, scripts, and code samples in docs and skills), 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 moved paths. 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 modules move unchanged.
Compatibility
python scripts/migrate_imports.py <paths>.Issue
Part of #5166.