-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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 methods to pass type @serve.batch
type hint
#45004
Merged
edoakes
merged 1 commit into
ray-project:master
from
shrekris-anyscale:shrekris/fix_batch_type_hint
Apr 29, 2024
Merged
[Serve] Allow methods to pass type @serve.batch
type hint
#45004
edoakes
merged 1 commit into
ray-project:master
from
shrekris-anyscale:shrekris/fix_batch_type_hint
Apr 29, 2024
Conversation
This file contains 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
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
edoakes
approved these changes
Apr 29, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx!
harborn
pushed a commit
to harborn/ray
that referenced
this pull request
May 8, 2024
…ect#45004) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? <!-- Please give a short summary of the change and the problem this solves. --> Without this change, `mypy` raises a type warning when decorating methods with `@serve.batch`: <img width="504" alt="Screenshot 2024-04-26 at 5 14 00 PM" src="https://github.com/ray-project/ray/assets/92341594/fd535d23-2a41-4f62-bb38-5f41a8bf53d5"> With this change, `mypy` no longer raises a type warning for methods: <img width="505" alt="Screenshot 2024-04-26 at 5 14 35 PM" src="https://github.com/ray-project/ray/assets/92341594/b14c4167-30e9-417e-a920-d694629b8038"> We should be aware that functions with an extra parameter before the input list will now pass the type check. This allows users to define a method outside a class and then assign it to a class: <img width="329" alt="Screenshot 2024-04-26 at 5 17 30 PM" src="https://github.com/ray-project/ray/assets/92341594/54043cf3-677a-48b8-a83b-10bec2ee6053"> ## Related issue number <!-- For example: "Closes ray-project#1234" --> N/A ## Checks - [X] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [X] 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 - This change relies on existing tests. Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
ryanaoleary
pushed a commit
to ryanaoleary/ray
that referenced
this pull request
Jun 7, 2024
…ect#45004) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? <!-- Please give a short summary of the change and the problem this solves. --> Without this change, `mypy` raises a type warning when decorating methods with `@serve.batch`: <img width="504" alt="Screenshot 2024-04-26 at 5 14 00 PM" src="https://github.com/ray-project/ray/assets/92341594/fd535d23-2a41-4f62-bb38-5f41a8bf53d5"> With this change, `mypy` no longer raises a type warning for methods: <img width="505" alt="Screenshot 2024-04-26 at 5 14 35 PM" src="https://github.com/ray-project/ray/assets/92341594/b14c4167-30e9-417e-a920-d694629b8038"> We should be aware that functions with an extra parameter before the input list will now pass the type check. This allows users to define a method outside a class and then assign it to a class: <img width="329" alt="Screenshot 2024-04-26 at 5 17 30 PM" src="https://github.com/ray-project/ray/assets/92341594/54043cf3-677a-48b8-a83b-10bec2ee6053"> ## Related issue number <!-- For example: "Closes ray-project#1234" --> N/A ## Checks - [X] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [X] 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 - This change relies on existing tests. Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
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?
Without this change,
mypy
raises a type warning when decorating methods with@serve.batch
:With this change,
mypy
no longer raises a type warning for methods:We should be aware that functions with an extra parameter before the input list will now pass the type check. This allows users to define a method outside a class and then assign it to a class:
Related issue number
N/A
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.