Repository navigation
[docs] Drop private-module import from LLM Serve doc examples - #65381
dstrodtman wants to merge 1 commit into
Conversation
The 13 LLM Serve documentation examples under doc/source/llm/doc_code/serve imported SERVE_DEFAULT_APP_NAME from ray.serve._private.constants to look up the deployed application in their CI polling loop. These files are executed by CI, so the import couples the doc build to a private Serve module for no benefit: each example deploys exactly one unnamed application, so the polling loop can read that application directly without naming it. Replace the keyed lookup with the single application's status. No published example content changes -- every edited line sits outside the literalinclude marker regions, so the rendered docs are byte-identical. Signed-off-by: Douglas Strodtman <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request removes the usage of the private constant SERVE_DEFAULT_APP_NAME across multiple Ray Serve example scripts, replacing it with dynamically fetching the status of the first application using next(iter(serve.status().applications.values())).status. The reviewer pointed out a potential issue where serve.status().applications could be empty during startup, which would cause next(iter(...)) to raise a StopIteration exception and crash the script. They recommended using next(iter(...), None) to handle empty applications gracefully.
| status != ApplicationStatus.RUNNING and time.time() - start_time < timeout_seconds | ||
| ): | ||
| status = serve.status().applications[SERVE_DEFAULT_APP_NAME].status | ||
| status = next(iter(serve.status().applications.values())).status |
There was a problem hiding this comment.
If serve.status().applications is empty (for example, during initial startup or if there is a slight delay in application registration), calling next(iter(...)) will raise a StopIteration exception and crash the script. Using next(iter(...), None) handles the empty case gracefully by returning None instead of raising an exception.
app_status = next(iter(serve.status().applications.values()), None)
status = app_status.status if app_status else None| status != ApplicationStatus.RUNNING and time.time() - start_time < timeout_seconds | ||
| ): | ||
| status = serve.status().applications[SERVE_DEFAULT_APP_NAME].status | ||
| status = next(iter(serve.status().applications.values())).status |
There was a problem hiding this comment.
If serve.status().applications is empty (for example, during initial startup or if there is a slight delay in application registration), calling next(iter(...)) will raise a StopIteration exception and crash the script. Using next(iter(...), None) handles the empty case gracefully by returning None instead of raising an exception.
app_status = next(iter(serve.status().applications.values()), None)
status = app_status.status if app_status else None| status != ApplicationStatus.RUNNING and time.time() - start_time < timeout_seconds | ||
| ): | ||
| status = serve.status().applications[SERVE_DEFAULT_APP_NAME].status | ||
| status = next(iter(serve.status().applications.values())).status |
There was a problem hiding this comment.
If serve.status().applications is empty (for example, during initial startup or if there is a slight delay in application registration), calling next(iter(...)) will raise a StopIteration exception and crash the script. Using next(iter(...), None) handles the empty case gracefully by returning None instead of raising an exception.
| status = next(iter(serve.status().applications.values())).status | |
| app_status = next(iter(serve.status().applications.values()), None) | |
| status = app_status.status if app_status else None |
| status != ApplicationStatus.RUNNING and time.time() - start_time < timeout_seconds | ||
| ): | ||
| status = serve.status().applications[SERVE_DEFAULT_APP_NAME].status | ||
| status = next(iter(serve.status().applications.values())).status |
There was a problem hiding this comment.
If serve.status().applications is empty (for example, during initial startup or if there is a slight delay in application registration), calling next(iter(...)) will raise a StopIteration exception and crash the script. Using next(iter(...), None) handles the empty case gracefully by returning None instead of raising an exception.
| status = next(iter(serve.status().applications.values())).status | |
| app_status = next(iter(serve.status().applications.values()), None) | |
| status = app_status.status if app_status else None |
| status != ApplicationStatus.RUNNING and time.time() - start_time < timeout_seconds | ||
| ): | ||
| status = serve.status().applications[SERVE_DEFAULT_APP_NAME].status | ||
| status = next(iter(serve.status().applications.values())).status |
There was a problem hiding this comment.
If serve.status().applications is empty (for example, during initial startup or if there is a slight delay in application registration), calling next(iter(...)) will raise a StopIteration exception and crash the script. Using next(iter(...), None) handles the empty case gracefully by returning None instead of raising an exception.
| status = next(iter(serve.status().applications.values())).status | |
| app_status = next(iter(serve.status().applications.values()), None) | |
| status = app_status.status if app_status else None |
| status != ApplicationStatus.RUNNING and time.time() - start_time < timeout_seconds | ||
| ): | ||
| status = serve.status().applications[SERVE_DEFAULT_APP_NAME].status | ||
| status = next(iter(serve.status().applications.values())).status |
There was a problem hiding this comment.
If serve.status().applications is empty (for example, during initial startup or if there is a slight delay in application registration), calling next(iter(...)) will raise a StopIteration exception and crash the script. Using next(iter(...), None) handles the empty case gracefully by returning None instead of raising an exception.
| status = next(iter(serve.status().applications.values())).status | |
| app_status = next(iter(serve.status().applications.values()), None) | |
| status = app_status.status if app_status else None |
| status != ApplicationStatus.RUNNING and time.time() - start_time < timeout_seconds | ||
| ): | ||
| status = serve.status().applications[SERVE_DEFAULT_APP_NAME].status | ||
| status = next(iter(serve.status().applications.values())).status |
There was a problem hiding this comment.
If serve.status().applications is empty (for example, during initial startup or if there is a slight delay in application registration), calling next(iter(...)) will raise a StopIteration exception and crash the script. Using next(iter(...), None) handles the empty case gracefully by returning None instead of raising an exception.
| status = next(iter(serve.status().applications.values())).status | |
| app_status = next(iter(serve.status().applications.values()), None) | |
| status = app_status.status if app_status else None |
| status != ApplicationStatus.RUNNING and time.time() - start_time < timeout_seconds | ||
| ): | ||
| status = serve.status().applications[SERVE_DEFAULT_APP_NAME].status | ||
| status = next(iter(serve.status().applications.values())).status |
There was a problem hiding this comment.
If serve.status().applications is empty (for example, during initial startup or if there is a slight delay in application registration), calling next(iter(...)) will raise a StopIteration exception and crash the script. Using next(iter(...), None) handles the empty case gracefully by returning None instead of raising an exception.
| status = next(iter(serve.status().applications.values())).status | |
| app_status = next(iter(serve.status().applications.values()), None) | |
| status = app_status.status if app_status else None |
| status != ApplicationStatus.RUNNING and time.time() - start_time < timeout_seconds | ||
| ): | ||
| status = serve.status().applications[SERVE_DEFAULT_APP_NAME].status | ||
| status = next(iter(serve.status().applications.values())).status |
There was a problem hiding this comment.
If serve.status().applications is empty (for example, during initial startup or if there is a slight delay in application registration), calling next(iter(...)) will raise a StopIteration exception and crash the script. Using next(iter(...), None) handles the empty case gracefully by returning None instead of raising an exception.
| status = next(iter(serve.status().applications.values())).status | |
| app_status = next(iter(serve.status().applications.values()), None) | |
| status = app_status.status if app_status else None |
| status != ApplicationStatus.RUNNING and time.time() - start_time < timeout_seconds | ||
| ): | ||
| status = serve.status().applications[SERVE_DEFAULT_APP_NAME].status | ||
| status = next(iter(serve.status().applications.values())).status |
There was a problem hiding this comment.
If serve.status().applications is empty (for example, during initial startup or if there is a slight delay in application registration), calling next(iter(...)) will raise a StopIteration exception and crash the script. Using next(iter(...), None) handles the empty case gracefully by returning None instead of raising an exception.
| status = next(iter(serve.status().applications.values())).status | |
| app_status = next(iter(serve.status().applications.values()), None) | |
| status = app_status.status if app_status else None |
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
This pull request has been automatically closed because there has been no more activity in the 14 days Please feel free to reopen or open a new pull request if you'd still like this to be addressed. Again, you can always ask for help on our discussion forum or Ray's public slack channel. Thanks again for your contribution! |
Description
The 13 LLM Serve documentation examples under
doc/source/llm/doc_code/serve/each importedSERVE_DEFAULT_APP_NAMEfromray.serve._private.constantsso their CI polling loop could look up the deployed application by name:These files are executed by CI, so this couples the doc build to a private Serve module. It also buys nothing: every one of the 13 calls
serve.run(app)exactly once with noname=, so there is exactly one application and the loop never needs to name it.This replaces the keyed lookup with the single application's status:
No published example content changes. Every edited line sits outside the
literalincludemarker regions these files expose to the docs, so the rendered pages are byte-identical. Three of the files (custom_vllm_yaml_config_example.py,direct_streaming_yaml_config_example.py,llm_yaml_config_example.py) aren't referenced by any doc page at all and exist purely as CI tests.Related issues
Related to #58624, which covers the separate
ray.serve._private.common.DeploymentIDcase indoc/source/serve/doc_code/autoscaling_policy.py. That one needs a symbol relocated and is not addressed here.Additional information
Part of a broader pass removing private-module imports from executed documentation examples. This is the mechanical subset: one repeated pattern, no public API change, no rendered-doc change.
blackandruffreport the same findings on these files before and after this change (5 files black would reformat, 20 ruff errors), all pre-existing and inside published example regions, so this PR leaves them alone. Note thatdoc/source/is excluded from the repo's pre-commit hooks, so those tools were run directly rather than viapre-commit.