8000 [serve] split call_user_method by zcin · Pull Request #54104 · ray-project/ray · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[serve] split call_user_method #54104

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

Merged
merged 8 commits into from
Jun 26, 2025
Merged

Conversation

zcin
Copy link
Contributor
@zcin zcin commented Jun 25, 2025

Why are these changes needed?

Split UserCallableWrapper.call_user_method into three functions:

  1. call_http_entrypoint - processes all requests with request_metadata.is_http_request == True
  2. call_user_generator - processes all requests with request_metadata.is_http_request == False and request_metadata.is_streaming == True
  3. call_user_method - processes all requests with request_metadata.is_streaming == False

Note that

  • ReplicaBase.handle_request directly calls call_user_method
  • ReplicaBase.handle_request_with_streaming calls ReplicaBase._call_streaming which calls call_http_entrypoint if request_metadata.is_http_request == True otherwise calls call_user_generator
  • ReplicaBase.handle_request_with_rejection calls call_user_method if request_metadata.is_streaming == False otherwise calls ReplicaBase._call_streaming.

zcin added 2 commits June 25, 2025 12:45
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
@zcin zcin added the go add ONLY when ready to merge, run all tests label Jun 25, 2025
zcin added 2 commits June 25, 2025 14:56
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
@zcin zcin force-pushed the split-call-user-method branch from 32bc5ae to f5542e0 Compare June 25, 2025 22:59
zcin added 2 commits June 26, 2025 09:28
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
@zcin zcin marked this pull request as ready for review June 26, 2025 16:42
@Copilot Copilot AI review requested due to automatic review settings June 26, 2025 16:42
@zcin zcin requested a review from a team as a code owner June 26, 2025 16:42
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR splits the single call_user_method into three distinct functions to properly handle HTTP entrypoints, streaming generators, and non-streaming user methods.

  • Updated test cases to call call_http_entrypoint and call_user_generator instead of call_user_method for streaming or HTTP requests.
  • Modified ReplicaBase internals to conditionally call the new methods based on request metadata.
  • Adjusted local testing mode to support the new call_user_generator and call_http_entrypoint functions.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
python/ray/serve/tests/unit/test_user_callable_wrapper.py Updated test invocations to use the appropriate call_ functions.
python/ray/serve/_private/replica.py Splits the call_user_method logic into call_http_entrypoint, call_user_generator, and call_user_method.
python/ray/serve/_private/local_testing_mode.py Adjusted handling of streaming requests to call the correct function.
Comments suppressed due to low confidence (1)

python/ray/serve/_private/replica.py:609

  • [nitpick] The variable 'call_user_method_future' now holds the result from either call_http_entrypoint or call_user_generator. Consider renaming it (e.g., 'call_user_future') to better reflect its usage.
                    )

Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
@abrarsheikh
Copy link
Contributor

the refactor makes sense. left some nits.

*,
generator_result_callback: Optional[Callable] = None,
) -> Any:
"""Call a user method (unary or generator).
Copy link
Contributor

Choose a reason for hiding this comment

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

does this method handle generator case for GRPC / deployment_handle calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep

Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
@zcin zcin merged commit cccbc2f into ray-project:master Jun 26, 2025
5 checks passed
@zcin zcin deleted the split-call-user-method branch June 26, 2025 22:39
minerharry pushed a commit to minerharry/ray that referenced this pull request Jun 27, 2025
## Why are these changes needed?

Split `UserCallableWrapper.call_user_method` into three functions:
1. `call_http_entrypoint` - processes all requests with
`request_metadata.is_http_request == True`
2. `call_user_generator` - processes all requests with
`request_metadata.is_http_request == False and
request_metadata.is_streaming == True`
3. `call_user_method` - processes all requests with
`request_metadata.is_streaming == False`

Note that
- `ReplicaBase.handle_request` directly calls `call_user_method`
- `ReplicaBase.handle_request_with_streaming` calls
`ReplicaBase._call_streaming` which calls `call_http_entrypoint` if
`request_metadata.is_http_request == True` otherwise calls
`call_user_generator`
- `ReplicaBase.handle_request_with_rejection` calls `call_user_method`
if `request_metadata.is_streaming == False` otherwise calls
`ReplicaBase._call_streaming`.

---------

Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0