Skip to content

[Serve] Allow methods to pass type @serve.batch type hint#45004

Merged
edoakes merged 1 commit intoray-project:masterfrom
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 intoray-project:masterfrom
shrekris-anyscale:shrekris/fix_batch_type_hint

Conversation

@shrekris-anyscale
Copy link
Contributor

Why are these changes needed?

Without this change, mypy raises a type warning when decorating methods with @serve.batch:

Screenshot 2024-04-26 at 5 14 00 PM

With this change, mypy no longer raises a type warning for methods:

Screenshot 2024-04-26 at 5 14 35 PM

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:

Screenshot 2024-04-26 at 5 17 30 PM

Related issue number

N/A

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
    • This change relies on existing tests.

Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Copy link
Collaborator

@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.

thx!

@edoakes edoakes merged commit e3fb472 into ray-project:master Apr 29, 2024
@shrekris-anyscale shrekris-anyscale self-assigned this Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants