Repository navigation
[serve] Add grpcio-reflection to the serve extra - #66067
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds grpcio-reflection as a dependency in python/requirements.txt and python/setup.py, and updates the corresponding lock files across various Python versions and environments. Additionally, some lock files reflect minor upgrades to related packages such as google-api-core, googleapis-common-protos, grpcio, opentelemetry-proto, proto-plus, protobuf, and requests. There are no review comments, and I have no feedback to provide.
Review feedback on ray-project#66067. The exact version still comes from the compiled constraint (1.75.0 on py3.12); the bound mirrors the <1.72 line and keeps that track on protobuf 6 if a depset ever loses its constraints file. No lock changes: resolution is unchanged. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Review feedback on ray-project#66067. The exact version still comes from the compiled constraint (1.75.0 on py3.12); the bound mirrors the <1.72 line and keeps that track on protobuf 6 if a depset ever loses its constraints file. No lock changes: resolution is unchanged. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Qisheng He <[email protected]>
dc68efd to
4718242
Compare
Add `grpcio-reflection` as a default Serve dependency: the `serve` extra in setup.py (mirrored in python/requirements.txt), pinned in test-requirements.txt alongside grpcio-tools and grpcio-status, mirrored into the compiled constraints, and the lock files regenerated with `raydepsets build --all-configs` (`--check` passes). This is the dependency half of ray-project#65854 (gRPC server reflection on the Serve gRPC proxy), split out so the lock regeneration reviews on its own. grpcio-reflection tracks grpcio, so it takes the same three-way pin that ray-project#66119 gave grpcio-tools and grpcio-status: 1.71.2 below Python 3.12 (1.72+ requires protobuf>=6.30, incompatible with the protobuf 5.27.5 pin on that track), 1.75.0 on 3.12-3.13, and 1.76.0 on 3.14. No lock moves protobuf or grpcio. Lock changes: every lock that installs the serve extra gains exactly one grpcio-reflection line, matched to its existing grpcio pin. The two `expand` depsets with no constraints file (tests/data/datatfds_py3.12, byod/audio_transcription_py3.10) resolve the newest grpcio-reflection (1.83.1) and follow it to grpcio 1.83.1, protobuf 7.36.1, and newer google-cloud/opentelemetry pins; this is inherent to unconstrained expand depsets and matches the pre-rebase version of this change. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Qisheng He <[email protected]>
4718242 to
12acee9
Compare
|
Rebased on master after #66119 (protobuf 5.27.5 on py<3.12) and force-pushed as a single commit. That pin made the earlier py3.10 override mechanism unnecessary: grpcio-reflection now simply takes the same three-way pin as grpcio-tools / grpcio-status (1.71.2 below 3.12, 1.75.0 on 3.12–3.13, 1.76.0 on 3.14). The override file and the depset config edits are gone, and no lock moves protobuf or grpcio any more; every lock except the two unconstrained @abrarsheikh @elliot-barn sorry to dismiss the approval; the diff is smaller than before if you have a moment to re-stamp. The previous build's only failure was an NVIDIA apt mirror flake in the |
Empty commit to retrigger premerge after a flaky test_proxy_shutdown_duration_metric run (see ray-project#66151). Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Qisheng He <[email protected]>
## Why Feature Request: https://anyscale1.atlassian.net/browse/CI-1545 gRPC Serve apps have no equivalent of FastAPI's `/docs`. With [server reflection](https://grpc.io/docs/guides/reflection/) enabled, standard tools (grpcurl, grpcui, Postman) can discover and call services with no local proto files: ```bash $ grpcurl -plaintext localhost:9000 list grpc.reflection.v1alpha.ServerReflection userdefinedprotos.UserDefinedService ``` ## What - A new `enable_reflection` option in `gRPCOptions` (on by default, per review), mirrored in the config schema and as `--grpc-enable-reflection/--grpc-disable-reflection` on `serve start` / `serve build`. - The proxy's `gRPCGenericServer` normally rewrites every registered handler to route to replicas. Reflection must run on the proxy itself, so this PR adds a passthrough mechanism: services marked via `add_passthrough_service()` keep their real handlers. When the flag is set, the proxy derives service names from the registered handlers, excludes Serve's built-in `RayServeAPIService`, and registers the reflection servicer as a passthrough. This all happens once at server startup; the per-request path is unchanged, and with the option disabled no new code runs. - `grpcio-reflection` becomes a default Serve dependency in #66067, split out so the lock regeneration reviews on its own. **This PR depends on #66067 and should merge after it.** ## Security stance Reflection exposes service/method/message names and types, the same class of info FastAPI's default-on `/docs` already exposes for HTTP. ## Known limitation to be resolved in follow-up PRs In HAProxy mode with multiple apps, reflection requests must carry `application` metadata; header-less requests get NOT_FOUND from HAProxy. Planned fix (separate PR): route `/grpc.reflection.` to the fallback proxy like `ListApplications`. Documented in the guide. ## Duplicate check No open PRs or issues for Serve gRPC reflection (`gh pr list --repo ray-project/ray --state open --search "grpc reflection"` — one unrelated hit). Coordinated on the internal FR ticket. ## Tests - `pytest python/ray/serve/tests/unit/test_grpc_util.py`: 13 passed (passthrough survives unmodified, service-name derivation, built-in excluded from advertisement). The reflection tests no longer `importorskip`, so they run in CI now that the package is in the Serve CI locks. - `pytest python/ray/serve/tests/unit/test_schema.py -k grpc`: passed (config/schema round-trip) - `pytest python/ray/serve/tests/test_grpc.py`: 5 passed, incl. new e2e: reflection client lists/describes with flag on, `UNIMPLEMENTED` with reflection disabled, user RPCs still route either way - Manually verified on a real multi-node cluster and through an ALB: grpcurl `list`/`describe`, unary and server-streaming RPCs invoked purely via reflection, and the grpcui web UI. <img width="1276" height="911" alt="image" src="https://github.com/user-attachments/assets/648635e9-3001-4691-97ef-470c76d8596a" /> AI assistance was used for this PR; every changed line was reviewed and all tests were run by the submitter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Qisheng He <[email protected]> Co-authored-by: Claude <[email protected]>
## Why Prerequisite for ray-project#65854, which adds gRPC server reflection to Serve's gRPC proxy. Reviewers there asked for `grpcio-reflection` to be a default Serve dependency rather than an optional install, and for the lock regeneration to be reviewed on its own, so the dependency change is split out here. ## What - `grpcio-reflection` added to the `serve` extra in `setup.py`, mirrored in `python/requirements.txt` (same shape as the `jinja2` addition in ray-project#65542). - Pinned in `test-requirements.txt` next to `grpcio-tools` / `grpcio-status`, with the same three-way split ray-project#66119 gave those two: **1.71.2 on py<3.12**, 1.75.0 on py3.12–3.13, 1.76.0 on py3.14. grpcio-reflection ≥ 1.72 requires protobuf ≥ 6.30, so 1.71.2 is the newest release compatible with the protobuf 5.27.5 pin on the py<3.12 track. Mirrored into `requirements_compiled.txt` (py<3.12 branch, as pip-compile emits it) and `requirements_compiled_py3.14.txt`. - Lock files regenerated with `bazelisk run //ci/raydepsets:raydepsets -- build --all-configs`; `--check` passes locally. No code changes. The feature that uses the package lands in ray-project#65854. **Rebased on 2026-09-14 after ray-project#66119 landed.** Master now pins protobuf 5.27.5 on py<3.12, which is exactly the constraint the earlier `py310_protobuf_overrides.txt` / `--override` mechanism was working around, so that mechanism is gone: no override file, no depset config edits. The branch is a single commit again. ## Lock changes vs master - 92 locks gain exactly one `grpcio-reflection` line, matched to the grpcio already pinned in that lock (1.71.2, 1.75.0, 1.76.0, or 1.78.0/1.80.0/1.62.3 in the few locks on a different grpcio). **No lock moves protobuf or grpcio.** - **Two `expand` depsets with no constraints file** (`tests/data/datatfds_py3.12`, `byod/audio_transcription_py3.10`) resolve the newest grpcio-reflection (1.83.1) and follow it to grpcio 1.83.1, protobuf 7.36.1, and newer google-cloud/opentelemetry pins. Same as before the rebase: a pre-existing gap in those depset definitions; happy to add a constraints file to them if preferred. ## Tests - `bazelisk run //ci/raydepsets:raydepsets -- build --all-configs` then `--check`: "Lock files are up to date." - `pre-commit run --files` on the edited source and compiled files: passed. - The `pip-compile dependencies` CI job validates the hand-added `requirements_compiled*.txt` entries. AI assistance was used for this PR; every changed line was reviewed and all checks were run by the submitter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Qisheng He <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
…ect#65854) ## Why Feature Request: https://anyscale1.atlassian.net/browse/CI-1545 gRPC Serve apps have no equivalent of FastAPI's `/docs`. With [server reflection](https://grpc.io/docs/guides/reflection/) enabled, standard tools (grpcurl, grpcui, Postman) can discover and call services with no local proto files: ```bash $ grpcurl -plaintext localhost:9000 list grpc.reflection.v1alpha.ServerReflection userdefinedprotos.UserDefinedService ``` ## What - A new `enable_reflection` option in `gRPCOptions` (on by default, per review), mirrored in the config schema and as `--grpc-enable-reflection/--grpc-disable-reflection` on `serve start` / `serve build`. - The proxy's `gRPCGenericServer` normally rewrites every registered handler to route to replicas. Reflection must run on the proxy itself, so this PR adds a passthrough mechanism: services marked via `add_passthrough_service()` keep their real handlers. When the flag is set, the proxy derives service names from the registered handlers, excludes Serve's built-in `RayServeAPIService`, and registers the reflection servicer as a passthrough. This all happens once at server startup; the per-request path is unchanged, and with the option disabled no new code runs. - `grpcio-reflection` becomes a default Serve dependency in ray-project#66067, split out so the lock regeneration reviews on its own. **This PR depends on ray-project#66067 and should merge after it.** ## Security stance Reflection exposes service/method/message names and types, the same class of info FastAPI's default-on `/docs` already exposes for HTTP. ## Known limitation to be resolved in follow-up PRs In HAProxy mode with multiple apps, reflection requests must carry `application` metadata; header-less requests get NOT_FOUND from HAProxy. Planned fix (separate PR): route `/grpc.reflection.` to the fallback proxy like `ListApplications`. Documented in the guide. ## Duplicate check No open PRs or issues for Serve gRPC reflection (`gh pr list --repo ray-project/ray --state open --search "grpc reflection"` — one unrelated hit). Coordinated on the internal FR ticket. ## Tests - `pytest python/ray/serve/tests/unit/test_grpc_util.py`: 13 passed (passthrough survives unmodified, service-name derivation, built-in excluded from advertisement). The reflection tests no longer `importorskip`, so they run in CI now that the package is in the Serve CI locks. - `pytest python/ray/serve/tests/unit/test_schema.py -k grpc`: passed (config/schema round-trip) - `pytest python/ray/serve/tests/test_grpc.py`: 5 passed, incl. new e2e: reflection client lists/describes with flag on, `UNIMPLEMENTED` with reflection disabled, user RPCs still route either way - Manually verified on a real multi-node cluster and through an ALB: grpcurl `list`/`describe`, unary and server-streaming RPCs invoked purely via reflection, and the grpcui web UI. <img width="1276" height="911" alt="image" src="https://github.com/user-attachments/assets/648635e9-3001-4691-97ef-470c76d8596a" /> AI assistance was used for this PR; every changed line was reviewed and all tests were run by the submitter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Qisheng He <[email protected]> Co-authored-by: Claude <[email protected]>
…67444) ## Description Since #65854, `ray/serve/_private/grpc_util.py` imports `grpc_reflection` at module load, so `import ray.serve` needs grpcio-reflection even when reflection is off. That package only comes with the `serve` extra. vLLM's Ray metrics (`vllm/v1/metrics/ray_wrappers.py`) import `ray.serve` and `ray.util.metrics` in one `try` block, so in a `ray[default]` environment a vLLM engine with `RayPrometheusStatLogger` fails to start with "RayPrometheusMetric requires Ray to be installed." I hit this on Ray nightly with SkyRL, which turns that logger on by default. Ray 2.59.0 doesn't have the import, so the next release would be the first one affected. This PR moves the import into `enable_server_reflection()`, its only user. If reflection is turned on without the package, the error names it and points to `pip install "ray[serve]"`, the hint Serve already adds at import time. ## Related issues None filed. Found while running SkyRL's Harbor integration on Ray nightly (skyrl-project/SkyRL#2467). ## Additional information - Not a duplicate: I searched PRs and issues for `grpc_reflection`, `grpcio-reflection` and the vLLM error, and none moves this import. #66067 added grpcio-reflection to the `serve` extra, which doesn't cover environments without that extra. - Tests: `test_serve_imports_without_grpc_reflection` imports Serve in a subprocess with `grpc_reflection` blocked, and `test_enable_server_reflection_without_grpc_reflection` checks the error message. Both fail on master. - Tested on macOS arm64 and Python 3.12 with today's nightly wheel (3608367, whose `grpc_util.py` matches master) and the two changed files linked in. `pytest python/ray/serve/tests/unit/test_grpc_util.py`: 18 passed. `pytest python/ray/serve/tests/test_grpc.py`: 45 passed. With grpcio-reflection uninstalled, vLLM's imports fail on master and work with this change. pre-commit passes. - I used Claude Code to help write and test this change. --------- Signed-off-by: xyuzh <[email protected]>
…ay-project#67444) ## Description Since ray-project#65854, `ray/serve/_private/grpc_util.py` imports `grpc_reflection` at module load, so `import ray.serve` needs grpcio-reflection even when reflection is off. That package only comes with the `serve` extra. vLLM's Ray metrics (`vllm/v1/metrics/ray_wrappers.py`) import `ray.serve` and `ray.util.metrics` in one `try` block, so in a `ray[default]` environment a vLLM engine with `RayPrometheusStatLogger` fails to start with "RayPrometheusMetric requires Ray to be installed." I hit this on Ray nightly with SkyRL, which turns that logger on by default. Ray 2.59.0 doesn't have the import, so the next release would be the first one affected. This PR moves the import into `enable_server_reflection()`, its only user. If reflection is turned on without the package, the error names it and points to `pip install "ray[serve]"`, the hint Serve already adds at import time. ## Related issues None filed. Found while running SkyRL's Harbor integration on Ray nightly (skyrl-project/SkyRL#2467). ## Additional information - Not a duplicate: I searched PRs and issues for `grpc_reflection`, `grpcio-reflection` and the vLLM error, and none moves this import. ray-project#66067 added grpcio-reflection to the `serve` extra, which doesn't cover environments without that extra. - Tests: `test_serve_imports_without_grpc_reflection` imports Serve in a subprocess with `grpc_reflection` blocked, and `test_enable_server_reflection_without_grpc_reflection` checks the error message. Both fail on master. - Tested on macOS arm64 and Python 3.12 with today's nightly wheel (3608367, whose `grpc_util.py` matches master) and the two changed files linked in. `pytest python/ray/serve/tests/unit/test_grpc_util.py`: 18 passed. `pytest python/ray/serve/tests/test_grpc.py`: 45 passed. With grpcio-reflection uninstalled, vLLM's imports fail on master and work with this change. pre-commit passes. - I used Claude Code to help write and test this change. --------- Signed-off-by: xyuzh <[email protected]>
Why
Prerequisite for #65854, which adds gRPC server reflection to Serve's gRPC proxy. Reviewers there asked for
grpcio-reflectionto be a default Serve dependency rather than an optional install, and for the lock regeneration to be reviewed on its own, so the dependency change is split out here.What
grpcio-reflectionadded to theserveextra insetup.py, mirrored inpython/requirements.txt(same shape as thejinja2addition in [Serve] Import jinja2 lazily and declare it in the serve extra #65542).test-requirements.txtnext togrpcio-tools/grpcio-status, with the same three-way split [ci][deps] Downgrade protobuf to 5.27.5 without the unrelated lock drift #66119 gave those two: 1.71.2 on py<3.12, 1.75.0 on py3.12–3.13, 1.76.0 on py3.14. grpcio-reflection ≥ 1.72 requires protobuf ≥ 6.30, so 1.71.2 is the newest release compatible with the protobuf 5.27.5 pin on the py<3.12 track. Mirrored intorequirements_compiled.txt(py<3.12 branch, as pip-compile emits it) andrequirements_compiled_py3.14.txt.bazelisk run //ci/raydepsets:raydepsets -- build --all-configs;--checkpasses locally.No code changes. The feature that uses the package lands in #65854.
Rebased on 2026-09-14 after #66119 landed. Master now pins protobuf 5.27.5 on py<3.12, which is exactly the constraint the earlier
py310_protobuf_overrides.txt/--overridemechanism was working around, so that mechanism is gone: no override file, no depset config edits. The branch is a single commit again.Lock changes vs master
grpcio-reflectionline, matched to the grpcio already pinned in that lock (1.71.2, 1.75.0, 1.76.0, or 1.78.0/1.80.0/1.62.3 in the few locks on a different grpcio). No lock moves protobuf or grpcio.expanddepsets with no constraints file (tests/data/datatfds_py3.12,byod/audio_transcription_py3.10) resolve the newest grpcio-reflection (1.83.1) and follow it to grpcio 1.83.1, protobuf 7.36.1, and newer google-cloud/opentelemetry pins. Same as before the rebase: a pre-existing gap in those depset definitions; happy to add a constraints file to them if preferred.Tests
bazelisk run //ci/raydepsets:raydepsets -- build --all-configsthen--check: "Lock files are up to date."pre-commit run --fileson the edited source and compiled files: passed.pip-compile dependenciesCI job validates the hand-addedrequirements_compiled*.txtentries.AI assistance was used for this PR; every changed line was reviewed and all checks were run by the submitter.
🤖 Generated with Claude Code