Repository navigation
refactor(models): move the model clients, converters and token capture into nemo_gym/models - #5224
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. |
|
Something went wrong on our side and the automatic retries didn't recover — please try again. (ref: |
5cb4839 to
230d80f
Compare
230d80f to
eb762f0
Compare
5354c31 to
fdece53
Compare
fdece53 to
04aa4d6
Compare
04aa4d6 to
6011d8d
Compare
yaoyu-33
left a comment
There was a problem hiding this comment.
Verdict: SHIP WITH CARE. Reviewed at 704bed5405a7 (base 250da81e). There are no blockers, 1 risk and 8 notes inline, plus one process question below.
The package move itself is clean. All 55 renamed files are identical to the base apart from imports. Every rewritten import resolves to the same object as before, and every old module path, including each token_id_capture submodule, still resolves with one warning. importlib.resources still reads the golden vectors through the old path and from a built wheel. Thanks for the careful layering and the redirect work.
Two notes are small leftovers from the move: the docs redirects and one assertion message. The rest come from the token_id_capture → token_capture rename that the latest push added. The loader rewrites old config keys, and the module-level names are served through MOVED_NAMES. The gaps are what sits around those two paths:
- old attribute names (RISK);
- raw dict readers;
- interpolations;
- the
nemo_gym.configfacade.
Resolved since the earlier head: .secrets.baseline now excludes the new golden_vectors.json path, and secrets-detector passes.
Process: the rename's scope. #5166 says config keys, CLI commands, server configs and output files "do not change". This push renames config keys and public pydantic fields, and adds a config rewrite layer. That also grows the PR from 129 to 187 files. Would you consider landing the move here and the identifier and config-key rename in its own PR, with NeMo RL coordinated? Otherwise, could #5166's compatibility list be amended to cover the rename? A cheaper middle ground would keep the config keys and rename only the Python identifiers through MOVED_NAMES. That would remove most of the inline notes.
Cross-PR and cross-repo items (not for this PR)
- NeMo RL, for its migration PR (checked at RL
6e68b179):tests/unit/environments/test_nemo_gym_utils.py:456readsTokenIdCaptureConfig.model_validate(...).token_id_capture, which now raises AttributeError (see the inline risk).nemo_rl/algorithms/single_controller_utils/rollout_checkpoint.py:123leaves onlyenv.**.token_id_captureout of the resume fingerprint, so a recipe migrated totoken_capturechanges it.nemo_rl/environments/nemo_gym.py:1040still injectsinitial_global_config_dict["token_id_capture"], and:1049still namesnemo_gym.token_id_capture.lineage:FileLineageStore. Both work, with a warning on every run. A user who also setstoken_capturein the same initial dict gets the loader's "both set" ConfigError.
- tau2:
responses_api_agents/tau2/requirements.txtpins the tau2 fork by branch (bxyu/nemo_gym_stable). Itssrc/tau2/utils/llm_utils.py:43importsnemo_gym.openai_utils, which works through the alias now and breaks at 0.10.0. It could go on the #5166 checklist. - #5215:
tests/unit_tests/server_runtime/test_mcp_auto_exposure.py:62importsnemo_gym.server_utils, so that file fails to collect under-W 'error:nemo_gym.:DeprecationWarning'`. The same happens at the base.
Validation
- CI at
704bed54: green. The only failure is the non-blocking kilocode harness-conformance job, which fails the same way on the base. - Unit suite, run locally: no failures caused by this PR. The failing IDs are environment-specific and fail the same way on the base tree. With
-W 'error:nemo_gym.:DeprecationWarning'`, the only new failure is the inline test note. lint-imports: kept. The packaging and moved-path tests pass.- Moved test IDs: 1143 at the base and 1143 at the head, all present.
- Token capture:
golden_vectors.jsonis byte-identical, and the recomputed digests match the base. Record fields, route paths, digest domains and env var names are unchanged. - Mutation checks: the claims hold that the new compat tests fail with the config rewrite turned off and with the field aliases removed.
- Sandbox runner fallbacks: checked in both directions against old and new bundles. All touched servers install nemo-gym from the local checkout.
- Not verified: GPU paths and real sandboxes.
|
Thanks for the review. On the scope question, I took the middle ground you suggested: this PR now renames only the Python names ( On the cross-repository items:
|
…e into nemo_gym/models openai_utils.py, anthropic_utils.py, anthropic_converter.py, chat_streaming.py and responses_streaming.py move as they are, responses_converter.py becomes models/chat_completions_converter.py, and the token_id_capture package becomes models/token_capture. The Python names follow the package: TokenIdCaptureConfig, TokenIdCaptureSettings, TOKEN_ID_CAPTURE_BLOCK, token_id_capture_config, token_id_capture_enabled_for_agent and token_id_capture_dirs_from_config become their token_capture spellings. The old names resolve at every old module path that defined or imported them, through MOVED_NAMES, with a warning, until 0.10.0. Config keys, pydantic field names and messages keep the token_id_capture spelling, so configs do not change. Record the seven moves in MOVED_MODULES (token_id_capture as a package), rewrite in-repo references with scripts/migrate_imports.py, point the NeMoGymAsyncOpenAI lazy export, the golden-vectors package-data pattern and the secrets scan exclusion at the new paths, make the contract's model layer the nemo_gym.models package next to base_responses_api_model until that module moves, and redirect the old library reference pages, including each token_id_capture submodule page, in fern/docs.yml. Regenerate the public API of each layout package that exists here from what code outside the library imports. Code outside nemo_gym and its tests imports from nemo_gym.<package>; the library's tests import from the module that defines each name. Signed-off-by: Ananth Subramaniam <[email protected]>
What and why
Moves the model clients, converters, and streaming helpers, and token ID capture, into
nemo_gym/models/, the package that #5214 started with the checkpoint model-server modules.base_responses_api_model.pymoves in the next PR, where its model call capture is split out.The token capture classes, the config block constant and the module-level helpers follow the new package name:
token_id_capturebecomestoken_capturein those Python names. Config keys, pydantic field names and messages keeptoken_id_capture, as #5166 promises, so configs and NeMo RL recipes do not change. The old Python names keep resolving until 0.10.0, with a warning.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/openai_utils.pynemo_gym/models/openai_utils.pynemo_gym/anthropic_utils.pynemo_gym/models/anthropic_utils.pynemo_gym/anthropic_converter.pynemo_gym/models/anthropic_converter.pynemo_gym/responses_converter.pynemo_gym/models/chat_completions_converter.pynemo_gym/chat_streaming.pynemo_gym/models/chat_streaming.pynemo_gym/responses_streaming.pynemo_gym/models/responses_streaming.pynemo_gym/token_id_capture/nemo_gym/models/token_capture/Names follow the package
TokenIdCaptureConfig,TokenIdCaptureSettingsTokenCaptureConfig,TokenCaptureSettingsTOKEN_ID_CAPTURE_BLOCK(value"token_id_capture", unchanged)TOKEN_CAPTURE_BLOCKtoken_id_capture_config,token_id_capture_enabled_for_agent,token_id_capture_dirs_from_configtoken_capture_config,token_capture_enabled_for_agent,token_capture_dirs_from_configUnchanged: the
token_id_captureconfig block, the per-servertoken_id_captureflag, the model server'stoken_id_capture_non_generating_requestskey, the pydantic fields and attributes of the same names, and every message that names those keys.Each old name resolves at every old module path that defined or imported it, through
MOVED_NAMESinnemo_gym/_moved_paths.py, with a warning. A package's public API also serves names that moved out of it, sofrom nemo_gym.config import TOKEN_ID_CAPTURE_BLOCKkeeps working. The recorded import surface checks every old name.How to review
One commit. Its changes:
MOVED_MODULESinnemo_gym/_moved_paths.py.scripts/migrate_imports.py.modelslayer becomes thenemo_gym.modelspackage.fern/docs.ymlredirects the old library reference pages to the new ones, including everytoken_id_capturesubmodule page.openai_utils.pystill serves the Responses API types refactor(core): move shared definitions into nemo_gym/core #5203 moved tocore/; those names keep resolving at both of its paths.nemo_gym/_public_api.py: a package's public API falls back toMOVED_NAMESfor a name it no longer exports, so an old name imported through a package resolves with a warning.tests/unit_tests/server_runtime/test_mcp_auto_exposure.pyimported four names throughnemo_gym.server_utils, which refactor(server_runtime): split server_utils into the server runtime package #5215 left alone because a comment sat inside the parenthesized import; it now imports them from their defining modules.chat_completions_converter.py, the converter's new file name.NeMoGymAsyncOpenAIlazy export, the secrets scan's exclusion of the staging golden vectors, which still named the old directory, the golden-vectors package-data pattern inpyproject.toml(written relative to thenemo_gympackage, so the rewriter's path pass does not see it; the package-data test catches it), and the contract's model layer, which isnemo_gym.modelsnext tobase_responses_api_modeluntil that module moves.tests/unit_tests/models/.test_responses_converter.pybecomestest_chat_completions_converter.pywith its module, andtest_token_id_capture.pybecomestest_token_capture.py. New tests check that every old name resolves at every old path to its renamed object with a warning, including through a package's public API, and that the config key and field names keep their spelling. They pass in any order and with the moved-path warnings turned into errors.Public API
Every layout package that exists after this PR has a lazy public API in its
__init__.py: the names code outsidenemo_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 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.MOVED_NAMES.lint-imports.pre-commit runon the changed files.Rollout evidence: N/A. The modules move unchanged, and the renamed Python names keep resolving at their old paths.
Compatibility
nemo_gym.models.*. A logging config set onnemo_gymstill covers them.python scripts/migrate_imports.py <paths>.Issue
Part of #5166.