Repository navigation
refactor: remove path and name couplings before the reorganization - #5169
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. |
6b26517 to
f94bf4e
Compare
f94bf4e to
46a454a
Compare
46a454a to
6b257d7
Compare
6b257d7 to
54b474a
Compare
54b474a to
6a7b1d7
Compare
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no concerns found.
Reviewed all seven changed files and their directly affected paths, including middleware registration and MCP dispatch, import-surface compatibility, standalone venv setup, and packaging checks. The marker-based gate retains unmarked-custom-middleware rejection, and the script lookup preserves standalone file execution and shell quoting.
Static review only; tests and package builds were not executed.
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.
6a7b1d7 to
52a9a4b
Compare
511c7b2 to
046a940
Compare
046a940 to
c2f7c06
Compare
c2f7c06 to
8386dca
Compare
8386dca to
39a67e2
Compare
yaoyu-33
left a comment
There was a problem hiding this comment.
Thanks for clearing these out before the moves. Checking a marker instead of the module name is the right fix for the MCP gate, and it follows the existing applies_to_mcp_requests pattern.
What we checked:
- Before this PR, the module-name rule accepted only two function middleware:
add_session_idandexception_handling_middleware. Both now carry the marker, so every app built in the repo passes or fails the gate exactly as before. - Removing any one of the four markers fails a test.
find_spec("nemo_gym.cli._venv_setup").origingives the same path asPath(__file__).with_name(...)and does not import the script.- That lookup keeps working through #5167's
MovedModuleFinder, which preservesorigin, and after #5195 moves the script tonemo_gym/utils/venv_setup.py.
Verdict: SHIP. We found no blockers or risks, and left three non-blocking notes inline:
- A subclass of a marked middleware class inherits the marker and now passes the gate. The fix is one line, plus a test for class middleware being refused.
test_accepts_every_gym_middlewareclaims to cover every middleware but leaves outSessionRoutingMiddleware.- The package-data test's comment, and the dead
resources/*.pypattern.
PR hygiene: Validation says the failures "match main on the same machine". Could you list which tests failed, and the main SHA you compared against?
CI: We reviewed 3d5f6a06. The current head cb55fece carries the same patch, rebased onto the updated #5168 branch, and its CI is still running. On 3d5f6a06, the red checks were unrelated to this PR:
Unit tests / TestandServer suite (shard 0)failed in the harbor tests on Docker Hub pull rate limits (HTTP 429).- The kilocode harness-conformance probe is non-blocking.
- The new tests passed.
yaoyu-33
left a comment
There was a problem hiding this comment.
Approving at cb55fece. The three inline notes are non-blocking and can be picked up here or in a follow-up.
|
On PR hygiene: the Validation section now names the failing tests and the |
yaoyu-33
left a comment
There was a problem hiding this comment.
Re-approving at 91b3339. The marker is now read from the class's own vars(), so a subclass of Gym middleware is refused, and a test covers it. Unit tests / Test failed in the harbor tests on Docker Hub's rate limit (HTTP 429 for ubuntu:24.04), not on this change.
Some code finds other code by module name or by file location, which would break silently when modules move. - mcp_auto_exposure recognized Gym's own middleware by dotted module names. Gym middleware that direct MCP dispatch may skip now carries a skipped_on_direct_mcp_dispatch marker, so the check survives a move. - setup_command found _venv_setup.py next to its own file. It now finds the script by module name, since the two move to different packages. - Tests that each nemo_gym package-data pattern still matches a file, that the Go sidecar source is where the launcher looks, and that the venv setup script is found. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
What and why
Some code finds other code by module name or file location. A move would break it without any error, so this PR changes it first.
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.
The MCP gate recognizes Gym middleware by a marker
harvest_toolsrefuses to expose a resources server over MCP when the app has middleware that direct MCP dispatch would skip. It recognized Gym's own middleware by dotted names such asnemo_gym.server_utils.ClientDisconnectCancellationMiddleware. After the moves those names change, and every Gym resources server withexpose_tools_over_mcpwould fail to start.flowchart TD M["Middleware on the app"] --> Q{"skipped_on_direct_mcp_dispatch<br/>set on it?"} Q -->|"yes"| S["Skip: Gym middleware"] Q -->|"no"| A{"applies_to_mcp_requests?"} A -->|"yes"| S2["Skip: it runs on the /mcp request"] A -->|"no"| R["Refuse to expose tools over MCP"] classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937 class Q thisMarked:
RolloutContextMiddleware,ClientDisconnectCancellationMiddleware, and theadd_session_idandexception_handling_middlewarefunctions. Only a class's own marker counts, so a subclass that overrides__call__is refused, as the name match refused it. A server's own middleware must not set the marker. Starlette'sSessionMiddlewareis still matched by name, since it is not Gym code.Other couplings
cli/setup_command.pyran_venv_setup.pyfrom next to its own file; the two move to different packagesimportlib.util.find_spec("nemo_gym.cli._venv_setup"); the script still runs without importing Gymnemo_gympackage-data pattern matches a fileThe
resources/*.pypackage-data pattern matched no file, and this PR removes it.Validation
pytest -n 16 tests/unit_tests. The failures are the same onmainat 5911d62 on this machine: the benchmark listing test and the Harbor run summary tests, which fail because this machine's hostname resolves to127.0.1.1, and the Docker PTY tests for a PID file that is not a regular file.run_webserveradds after the gate runs, after checking both are on the app. Others check that a marked middleware defined outside Gym is accepted, and that unmarked custom middleware, as a function or a class, and a subclass of a marked class are refused. Removing any one marker fails the MCP tests, and the subclass test fails with the oldgetattrcheck.nemo_gym/token_id_capture/, the package-data test failed on the pattern that still named the old directory.pre-commit run --all-files.Rollout evidence: N/A. The same middleware passes and fails the MCP gate as before, and
gym env startruns the same venv setup script.Compatibility
No user-visible change. The private constant
nemo_gym.mcp_auto_exposure._GYM_MIDDLEWARE_MODULESis removed.Issue
Part of #5166.