Repository navigation
refactor(metrics): move the metrics modules into nemo_gym/metrics - #5211
Merged
Merged
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. |
ananthsub
marked this pull request as ready for review
October 28, 2026 18:50
35 of 41 tasks
Contributor
ananthsub
force-pushed
the
ananthsub/layout-metrics
branch
from
October 28, 2026 19:01
13b184f to
8d3504a
Compare
ananthsub
force-pushed
the
ananthsub/layout-metrics
branch
from
October 28, 2026 19:25
8d3504a to
80c2435
Compare
ananthsub
force-pushed
the
ananthsub/layout-metrics
branch
from
October 28, 2026 21:56
be2168f to
b6a7cff
Compare
ananthsub
force-pushed
the
ananthsub/layout-metrics
branch
from
October 28, 2026 23:10
b6a7cff to
2cd8756
Compare
ananthsub
force-pushed
the
ananthsub/layout-metrics
branch
from
October 29, 2026 00:54
2cd8756 to
5dd83c4
Compare
yaoyu-33
reviewed
Oct 29, 2026
yaoyu-33
left a comment
Contributor
There was a problem hiding this comment.
Thanks for another clean, mechanical step. We found no blockers or risks, only two small notes inline: one about old-path test coverage, one question about how the CLI reward_profile shim should travel with its module.
What this PR does. It moves reward_profile.py and metrics_config.py into a new nemo_gym/metrics package with a lazy public API. It records both moves in _moved_paths.py, swaps the import-linter layer to nemo_gym.metrics, rewrites the in-repo imports, and adds the docs redirects.
What we checked
- Moves.
metrics_config.pyis byte-identical.reward_profile.pyandtest_reward_profile.pydiffer from the base only in their imports. Nothing in either module depends on its file location. - Imports. The other 64 changed Python files differ only in their imports. All 21 rewritten (module, name) pairs resolve to the identical objects. Both old module paths give the same module objects with one warning each, in either import order, and a pickle written at the base still loads.
- Metrics. The aggregate-metric and reward-profile functions are unchanged. So are the
/aggregate_metricsroutes and the mixin MRO of every server, agent and environment server that uses them._PUBLIC_APIholds exactly the eight names that code outside the library imports, andtest_public_api_facades.pypicks the package up on its own. - Runtime lookups. No config, manifest or
mock.patchstring names these modules by dotted path. No script shipped into a sandbox imports them, and the harness tarballs includenemo_gym/metrics/. Thefern/docs.ymlredirects cover both URL forms.lint-importspasses in the Lint job. - Tests. The targeted unit tests pass locally, apart from three wandb tests that also fail at the base without the extra. With moved-path warnings turned into errors they still pass, which matches the PR's validation. Every touched server's tests pass in CI.
PR description
- Neither moved module uses
logging, so the logger-name bullet under Compatibility doesn't apply here. What does change is the module theirUserWarnings are attributed to: a downstreamwarningsfilter keyed onmodule="nemo_gym.reward_profile"(for example on "Standard error is 0") stops matching. - Validation could give the exact
-Wfilter. A blanket-W error::DeprecationWarningalso trips the unrelatedagent_refrouting deprecation inrollout_collection.py.
CI (not from this PR)
Unit tests / Test: the Docker Hub 429 Harbor failures, plustelemetry/test_propagation.py::test_lazy_client_initialization_failure_is_inside_the_client_span[False/True].Server suite (shard 3): fouropenai_modelTestRefusedProviderConnectionfailures.- These six also fail on #5210's head and first appear at #5206, where the test fixtures patch names in
server_utilsthat the moved client code no longer reads, so the fix belongs there.Harness conformanceis non-blocking.
Record the two moves in MOVED_MODULES, rewrite in-repo references with scripts/migrate_imports.py, make the contract's metrics layer the nemo_gym.metrics package, and redirect the old library reference pages in fern/docs.yml. 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]>
7 tasks done
This was referenced Nov 2, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Moves the rollout metrics into a new
nemo_gym/metrics/package: reward profiles with pass@k and majority statistics, and the metric definitions they share.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/reward_profile.pynemo_gym/metrics/reward_profile.pynemo_gym/metrics_config.pynemo_gym/metrics/metrics_config.pyHow to review
One commit. Its changes:
MOVED_MODULESinnemo_gym/_moved_paths.py.scripts/migrate_imports.py.metricslayer becomes thenemo_gym.metricspackage.fern/docs.ymlredirects the old library reference pages to the new ones.tests/unit_tests/metrics/.test_aggregate_metrics.pystays: it checks the metrics endpoints of a resources server and an agent end to end.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
UserWarnings, such as "Standard error is 0", are now attributed tonemo_gym.metrics.reward_profile, so awarningsfilter keyed onmodule="nemo_gym.reward_profile"needs the new name.python scripts/migrate_imports.py <paths>.Issue
Part of #5166.