Repository navigation
[Serve][LLM] Lazily import RouterApplication to fix the docs build - #67741
Merged
Merged
Conversation
builder.py imported RouterApplication at module level. router_application imports router, whose module-level @serve.ingress(FastAPI()) raises a TypeError when fastapi is mocked, as it is in the Sphinx docs build. That broke `import ray.serve.llm` and failed every master docs build since #66519. Import RouterApplication inside build_openai_router_app, matching the existing lazy LLMRouter import in _build_openai_ingress_request_router. @rtd-build Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request moves the import of RouterApplication from the module level to a lazy import inside the build_openai_router_app function. This prevents import failures when fastapi is mocked, such as during documentation builds, which previously broke import ray.serve.llm. There are no review comments, and I have no additional feedback to provide.
eicherseiji
approved these changes
Nov 3, 2026
This was referenced Nov 9, 2026
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.
Why are these changes needed?
The Ray docs build on
masterhas failed on every commit since #66519 merged. Sphinx aborts during autosummary setup withno module named ray.serve.llm(for example, RtD build 4665012). That message masks the real import error:The docs build mocks
fastapi(doc/source/api_mock_imports.py), soFastAPIisn't a real type there.builder.pyalready avoids this by importingLLMRouterlazily inside_build_openai_ingress_request_router. The new top-levelRouterApplicationimport pulledrouter.pyback in at import time.This PR moves the
RouterApplicationimport intobuild_openai_router_app, the only place that uses it. #66519 changed nothing underdoc/, so its RtD previews were skipped by the doc-change guard and the break first showed up onmaster. The commit carries an@rtd-buildline so this PR builds a preview.Duplicate check
I searched open PRs for
RouterApplication,serve llm import docs, and the #66519 author's open PRs, and found nothing that addresses this break.Testing
ray.serve.llmfrom source with Sphinx'ssphinx.ext.autodoc.mock.mock()active over the docs mock list, in a venv built fromdoc/requirements-doc.lock.txt. The import fails atdec986ce([Serve][LLM][3/5] Add multi-application OpenAI routing #66519) with the traceback above, succeeds at its parentc2adf94c, and succeeds with this change.test_builder_openai_router_app.pyand the router tests, and the RtD preview on this PR confirms the docs build.AI assistance
Claude Code helped diagnose the build failure and draft this change. I reviewed the change and the analysis.
🤖 Generated with Claude Code