Repository navigation
feat(nemo-gym): serve a written resources server on its own - #413
Merged
Merged
Conversation
`python -m agent_env.training.nemo_gym serve FOLDER --port P` runs the resources server `write` wrote into FOLDER without Gym's head server or the agent servers its config names, for a trainer that takes a resources server's URL. verifiers' NeMo Gym taskset (prime-rl's) does: its managed mode starts only servers from NeMo Gym's own package. The server is built as verifiers' own launcher builds Gym's servers. The command becomes a group with `write` and `serve`; any other first argument is write's, so `python -m agent_env.training.nemo_gym SOURCE ROOT` works as before. Writing doesn't need the nemo-gym extra, so `__main__` imports the server guarded and `serve` reports the extra's install hint when it's missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
serve builds Gym's ServerClient, whose config must be an omegaconf DictConfig, so the server imports omegaconf directly. Declare it in the nemo-gym extra under Gym's marker, and teach the dependency guard the nemo-gym and omegaconf module paths it can't read when the extra isn't installed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The folder's name is the server's, and Path(".").name is empty. The serve
test now runs serve . from inside the written folder.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
python -m agent_env.training.nemo_gym serve FOLDER --port Pruns the resources server thatpython -m agent_env.training.nemo_gym SOURCE ROOTwrote intoFOLDER(<root>/resources_servers/<name>), on its own. It runs without Gym's head server and without the agent and environment servers the folder's config names.Why
verifiers' built-in NeMo Gym taskset (
env.taskset.id = "nemo-gym"), which prime-rl trains through, plays a Gym dataset against a resources server atenv.taskset.task.resources_url. Its managed mode starts only servers from NeMo Gym's own published package, so our server has to run on its own. Until now the only way to start it wasgym env startwith the whole written config. That also startssimple_agent, thelegacy_agentenvironment server and the head server, none of which a verifiers run uses.How
server.serve(folder, host=, port=)reads the folder's config. It buildsAgentEnvResourcesServerthe way verifiers' own launcher builds Gym's servers: an explicit config, aServerClientwhose stand-in head server nothing calls, thensetup_webserver,setup_liveness,setup_exception_middlewareand uvicorn. Abundleconfig still serves the bundle for the server's lifetime, as under Gym.writeandserve. Any other first argument iswrite's, sopython -m agent_env.training.nemo_gym SOURCE ROOT, as released and documented, works unchanged.nemo-gymextra. Writing doesn't need it, and the unit tier imports the command without it. So__main__imports the server in a guarded top-level import, andservereports the extra's install hint when it's missing. The import adds about a second towritewhen the extra is installed.omegaconfjoins thenemo-gymextra, under Gym's Python marker. Gym'sServerClienttakes an omegaconfDictConfig, so the server now imports it directly. The dependency guard learns the nemo-gym and omegaconf module paths it can't read when the extra isn't installed. The lock gains two lines.--hostdefaults to loopback. The server checks no token, and the help says to keep it off public interfaces.Tests
test_serve_runs_a_written_server_on_its_own_at_the_port_it_is_given:python -m agent_env.training.nemo_gym serve .as its own process, from inside the written folder.tst/unit/trainingpass in a dev-only venv without nemo-gym or omegaconf, as the unit job runs them; the guard andtst/nemo_gympass with them installed.tst/nemo_gymandtst/unit/trainingpass locally on nemo-gym 0.7.0 (45 passed). The existing CLI unit test covers theSOURCE ROOTform through the default.writeimports and runs.serveexits 1 withrequires pip install 'agentenv-framework[nemo-gym]', on Python 3.13.14 or later.--helplists both commands.SOURCEstill routes towrite.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; the previous folder lookup issue is fixed.Summary
Adds a standalone command for running a written NeMo Gym resources server.
No new actionable issues were found in the changes since the previous review. Tests were not run during this review.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR CLI["serve FOLDER --port P"] --> Folder["Resolve folder"] Folder --> Config["Read written config"] Config --> Server["Build resources server"] Server --> App["Set up web app"] App --> Uvicorn["Listen on requested host and port"]Reviews (2) · Last reviewed commit: "fix(nemo-gym): serve resolves its folder..." · Reviewed by Greptile