Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Serve] allow gRPC deployment to use grpc context #41667

Merged
merged 15 commits into from
Dec 8, 2023

Conversation

GeneDer
Copy link
Contributor

@GeneDer GeneDer commented Dec 6, 2023

Why are these changes needed?

This PR passes a grpc_context to deployments if the deployment uses it to get gRPC request related info can use to set code, details, trailing metadata, and compression. The original grpc._cython.cygrpc._ServicerContext type is not serializable, so we created a RayServegRPCContext to be able to pass to the deployment. Will follow up with doc change.

Related issue number

Closes #38616

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
@GeneDer GeneDer requested a review from a team December 6, 2023 20:36
@GeneDer GeneDer added release-blocker P0 Issue that blocks the release ray 2.9 Issues targeting Ray 2.9 release (~Q4 CY2023) labels Dec 6, 2023
@GeneDer GeneDer marked this pull request as ready for review December 6, 2023 20:36
Copy link
Contributor

@shrekris-anyscale shrekris-anyscale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

python/ray/serve/_private/grpc_util.py Outdated Show resolved Hide resolved
python/ray/serve/_private/proxy.py Outdated Show resolved Hide resolved
python/ray/serve/_private/proxy.py Outdated Show resolved Hide resolved
python/ray/serve/_private/router.py Show resolved Hide resolved
python/ray/serve/tests/test_grpc.py Show resolved Hide resolved
python/ray/serve/api.py Outdated Show resolved Hide resolved
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
@GeneDer
Copy link
Contributor Author

GeneDer commented Dec 7, 2023

Docs build completed this time https://readthedocs.com/projects/anyscale-ray/builds/1885865/ not sure why it's showing failed here 😅

@GeneDer
Copy link
Contributor Author

GeneDer commented Dec 7, 2023

@edoakes would be nice if you have bandwidth to take a look at this one as well🙏

@GeneDer GeneDer requested a review from edoakes December 7, 2023 17:44
Copy link
Contributor

@edoakes edoakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GeneDer question on the API here: from what I remember, when using vanilla gRPC the handler function will be passed the context directly. Why not follow that paradigm instead of adding the get_grpc_context API?

@GeneDer
Copy link
Contributor Author

GeneDer commented Dec 7, 2023

Bc that would be a breaking change given there are already users for gRPC proxy. Also I feel since there are already mechanisms for getting request metadata such as multiplex api, following that pattern is a better alternatives (than forcing users to take an gRPC context that they might not case about)

@edoakes
Copy link
Contributor

edoakes commented Dec 7, 2023

Bc that would be a breaking change given there are already users for gRPC proxy. Also I feel since there are already mechanisms for getting request metadata such as multiplex api, following that pattern is a better alternatives (than forcing users to take an gRPC context that they might not case about)

You can make it an optional kwarg (I think that's what gRPC does to begin with). If user-provided functions take that kwarg, we pass it, else we don't.

Signed-off-by: Gene Su <e870252314@gmail.com>
@GeneDer
Copy link
Contributor Author

GeneDer commented Dec 8, 2023

@edoakes @shrekris-anyscale I addressed all the comments PTAL and hopefully we can get this merged and cherry picked today🙏

python/ray/serve/_private/proxy.py Outdated Show resolved Hide resolved
python/ray/serve/_private/proxy.py Outdated Show resolved Hide resolved
python/ray/serve/_private/replica.py Outdated Show resolved Hide resolved
python/ray/serve/tests/test_grpc.py Show resolved Hide resolved
python/ray/serve/_private/grpc_util.py Outdated Show resolved Hide resolved
python/ray/serve/_private/proxy_request_response.py Outdated Show resolved Hide resolved
python/ray/serve/grpc_util.py Outdated Show resolved Hide resolved
python/ray/serve/grpc_util.py Outdated Show resolved Hide resolved
python/ray/serve/tests/test_grpc.py Outdated Show resolved Hide resolved
python/ray/serve/tests/unit/test_grpc_util.py Outdated Show resolved Hide resolved
python/ray/serve/tests/unit/test_grpc_util.py Show resolved Hide resolved
Signed-off-by: Gene Su <e870252314@gmail.com>
@edoakes edoakes merged commit 2487553 into ray-project:master Dec 8, 2023
11 of 15 checks passed
@GeneDer GeneDer deleted the pass-grpc-context branch December 8, 2023 21:09
GeneDer added a commit to GeneDer/ray that referenced this pull request Dec 8, 2023
This PR passes a grpc_context to deployments if the deployment uses it to get gRPC request related info can use to set code, details, trailing metadata, and compression. The original grpc._cython.cygrpc._ServicerContext type is not serializable, so we created a RayServegRPCContext to be able to pass to the deployment. Will follow up with doc change.

---------

Signed-off-by: Gene Su <e870252314@gmail.com>
architkulkarni pushed a commit that referenced this pull request Dec 9, 2023
… (#41751)

This PR passes a grpc_context to deployments if the deployment uses it to get gRPC request related info can use to set code, details, trailing metadata, and compression. The original grpc._cython.cygrpc._ServicerContext type is not serializable, so we created a RayServegRPCContext to be able to pass to the deployment. Will follow up with doc change.

Why are these changes needed?
Pick of #41667

---------

Signed-off-by: Gene Su <e870252314@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ray 2.9 Issues targeting Ray 2.9 release (~Q4 CY2023) release-blocker P0 Issue that blocks the release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Serve] Pass gRPC context into deployment replicas
3 participants