Repository navigation
refactor(server_runtime): split server_utils into the server runtime package - #5215
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 19:28
35 of 41 tasks
Contributor
ananthsub
force-pushed
the
ananthsub/layout-server-utils
branch
from
October 28, 2026 19:56
90c8192 to
8c00744
Compare
ananthsub
force-pushed
the
ananthsub/layout-server-utils
branch
from
October 28, 2026 20:25
8c00744 to
c30668c
Compare
ananthsub
force-pushed
the
ananthsub/layout-server-utils
branch
from
October 28, 2026 22:26
9e993d2 to
4f1e4c0
Compare
ananthsub
force-pushed
the
ananthsub/layout-server-utils
branch
from
October 28, 2026 23:10
4f1e4c0 to
5a29873
Compare
ananthsub
force-pushed
the
ananthsub/layout-server-utils
branch
from
October 29, 2026 00:55
5a29873 to
db0b04d
Compare
ananthsub
force-pushed
the
ananthsub/layout-server-utils
branch
from
October 29, 2026 14:04
db0b04d to
43e50d7
Compare
This was referenced Oct 29, 2026
…package Move nemo_gym/server_utils.py to nemo_gym/server_runtime/base_server.py. It keeps the server base classes, BaseServer and SimpleServer, and their uvicorn setup, next to base_resources_server.py and base_environment_server.py. The rest moves out unchanged: - Ray detection and cluster setup to server_runtime/ray_support.py; - the head server to server_runtime/registry_server.py; - request validation errors, request context isolation, disconnect cancellation and trace context middleware to server_runtime/request_handling/; - the two helpers that read literal class flags from an entrypoint's source to server_runtime/entrypoint_flags.py, which both Ray support and the Harbor CLI use, so Ray support does not import base_server back. Record the module move in MOVED_MODULES and the split names in MOVED_NAMES, including the names server_utils imported only for code that moved out. Rewrite in-repo references with scripts/migrate_imports.py, point test patches and log captures at the module that now looks each name up, and make the contract's server runtime layer the nemo_gym.server_runtime package alone. Regenerate the public API of each layout package that exists here from what non-test code outside nemo_gym 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]>
7 tasks done
7 tasks done
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
server_utils.pyintonemo_gym/server_runtime/asbase_server.pyand splits it by responsibility. After #5206 took the HTTP and server clients out, it still held the server base classes, Ray setup, the head server, and four pieces of request middleware. Now each lives in its own module, andbase_server.pykeeps the server base classes and their uvicorn setup, named likebase_resources_server.pyandbase_environment_server.pybeside it.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.
What moves
flowchart LR subgraph SU["server_utils.py today"] B["BaseServer, SimpleServer,<br/>uvicorn configs"] R["Ray detection and cluster setup"] F["Entrypoint class flags"] H["HeadServer"] E["Validation error logging"] C["Request context isolation"] D["Disconnect cancellation"] T["Trace context in the URL path"] end B --> B2["server_runtime/base_server.py"] R --> R2["server_runtime/ray_support.py"] F --> F2["server_runtime/entrypoint_flags.py"] H --> H2["server_runtime/registry_server.py"] E --> E2["request_handling/errors.py"] C --> C2["request_handling/request_context.py"] D --> D2["request_handling/disconnect.py"] T --> T2["request_handling/trace_context.py"] classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937 class B2,R2,F2,H2,E2,C2,D2,T2 thisserver_utils.pytobase_server.pyis a git rename, so its history follows it. The modules split out of it are new files.entrypoint_flags.pyis the one module the proposal did not name. Ray support and the Harbor CLI both read literal class flags from an entrypoint's source. Left inbase_server.py, those helpers would make Ray support importbase_serverback.What stays importable from the old paths
nemo_gym.server_utilsis the same module object asnemo_gym.server_runtime.base_server.server_utilsimported only for code that moved out.server_utilsof a name that a split module now looks up has no effect. In this repo the test patches and log captures now target the module that looks each name up.How to review
One commit. Its changes:
server_utils.pybecomesserver_runtime/base_server.py.base_server.py, andbase_server.pyimports back the five names it uses.nemo_gym.server_runtime.request_handling.errors.nemo_gym/_moved_paths.py.scripts/migrate_imports.py, and test patches andcaploglogger names are pointed at the module that looks each name up.nemo_gym.server_runtimepackage alone.server_utils, now names itbase_server. Where such code read an HTTP client name through it, it now reads the name fromnemo_gym.client.http_client, which defines it.nemo_gym.client. It importsServerClientand the HTTP client fromnemo_gym.client, and falls back tonemo_gym.server_utilswhen that package is missing. Before this, the rewritten import raised there and the overlay installed nothing.test_server_utils.pybecomestests/unit_tests/server_runtime/test_base_server.py, andtest_ray_opt_out.pymoves intotests/unit_tests/server_runtime/.History of split files
The repository squash-merges, so this PR lands as one commit. Whole-module moves still show as renames. A split file does not: its old path stays with less in it, so the new file starts its own history.
git blame -C -C <new file>follows the moved lines back to the old file, andgit log --followdoes not.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 every oldserver_utilspath and name. 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 code moves unchanged.
Compatibility
nemo_gym.server_runtime.base_server, and the head server, Ray support, and request handling under their own modules. A logging config set onnemo_gymstill covers them.nemo_gym.server_utilsof a name that moved to a split module no longer takes effect.python scripts/migrate_imports.py <paths>.Issue
Part of #5166.