Repository navigation
[serve] Clean up API reference and various docstrings - #34711
Merged
Merged
Conversation
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
edoakes
requested review from
a team,
architkulkarni,
shrekris-anyscale,
sihanwang41 and
zcin
as code owners
April 24, 2023 15:26
edoakes
force-pushed
the
app-class-apiref
branch
from
April 24, 2023 16:06
af3e47b to
5244b3a
Compare
Signed-off-by: Edward Oakes <[email protected]>
edoakes
force-pushed
the
app-class-apiref
branch
from
April 24, 2023 21:33
56200f1 to
569f420
Compare
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
edoakes
force-pushed
the
app-class-apiref
branch
from
April 25, 2023 19:59
c1ad974 to
2f05639
Compare
Signed-off-by: Edward Oakes <[email protected]>
Co-authored-by: Cindy Zhang <[email protected]> Signed-off-by: Edward Oakes <[email protected]>
Collaborator
Author
|
@ray-project/ray-docs can I get a review on this please |
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
angelinalg
reviewed
May 5, 2023
richardliaw
approved these changes
May 5, 2023
angelinalg
reviewed
May 5, 2023
|
|
||
| <!--- | ||
| NOTE: `serve.deployment` and `serve.Deployment` have an autosummary-generated filename collision due to case insensitivity. | ||
| This is fixed by added custom filename mappings in `source/conf.py` (look for "autosummary_filename_map"). |
Contributor
There was a problem hiding this comment.
Suggested change
| This is fixed by added custom filename mappings in `source/conf.py` (look for "autosummary_filename_map"). | |
| This is fixed by added custom filename mappings in `source/conf.py`. (Look for "autosummary_filename_map".) |
Collaborator
Author
There was a problem hiding this comment.
I think it's actually correct as-is?
Co-authored-by: angelinalg <[email protected]> Signed-off-by: Edward Oakes <[email protected]>
richardliaw
reviewed
May 5, 2023
| >>> # deployment_name#krcwoa | ||
| >>> serve.get_replica_context().replica_tag # doctest: +SKIP | ||
|
|
||
| .. code-block:: python |
Contributor
There was a problem hiding this comment.
eventually we will move off this code-block thing, fyi
Contributor
|
Had some minor copy edits. Please use the |
Collaborator
Author
|
Thanks @angelinalg !! |
Signed-off-by: Edward Oakes <[email protected]>
architkulkarni
pushed a commit
to architkulkarni/ray
that referenced
this pull request
May 16, 2023
) Cleans up the API reference page formatting, adds/updates docstrings where applicable (corrects typing + verbiage, adds inline examples). Co-authored-by: Cindy Zhang <[email protected]> Co-authored-by: angelinalg <[email protected]>
akyang-anyscale
pushed a commit
that referenced
this pull request
Oct 26, 2026
## Description
`serve.deployment` dispatches on whether `_func_or_class` is passed. Its
only return annotation is `Callable[[Callable], Deployment]`. A bare
`@serve.deployment` therefore types as the decorator it would return.
Every later `.bind()` or `.options()` call on it is a type error:
```
error: Cannot access attribute "bind" for class "FunctionType"
Attribute "bind" is unknown (reportFunctionMemberAccess)
```
This adds two `@overload` signatures. A callable first argument returns
`Deployment`, with or without options. No callable returns the
decorator. The first overload also accepts the options, unlike the pair
removed in #34711. `serve.deployment(MyClass, num_replicas=2)` works at
runtime and now types as `Deployment` too.
`check_deployment_typing.py` covers the bare, called and direct-call
forms. It sits next to `check_handle_typing.py` and is registered in the
`mypy (ray serve)` and `pyrefly (ray serve)` hooks and in
`pyrefly-serve.toml`.
## Related issues
Fixes #52483
## Additional information
mypy (python/mypy#3135) and pyrefly ignore the return type of a class
decorator. For them this fixes functions and direct calls.
`@serve.deployment class X` still types as `type[X]` there. pyright
applies class decorators, so the reproduction script in #52483 now
reports 0 errors.
Not a duplicate: #52483 has no linked PR. `gh pr list --repo
ray-project/ray --state open --search "52483 in:body"` returns nothing.
Tests run. Each `master api.py` result is the same command with only
`api.py` reverted to master.
```
# mypy 1.7.0, flags and file set of the "mypy (ray serve)" hook
MYPYPATH=python mypy --no-site-packages --follow-imports=silent --ignore-missing-imports <69 hook files>
Success: no issues found in 69 source files # master api.py: 7 errors, all in check_deployment_typing.py
# pyrefly 1.1.1
pyrefly check --config python/ray/serve/pyrefly-serve.toml python/ray/serve/tests/typing_files/check_deployment_typing.py
0 errors # master api.py: 7 errors
# pyright 1.1.406, extraPaths = ["python"]
pyright python/ray/serve/tests/typing_files/check_deployment_typing.py
0 errors # master api.py: 7 errors
pyright <reproduction script from #52483>
0 errors # master api.py: 2 errors
```
Disclaimer: this PR was prepared with the assistance of an AI agent
(Claude Code). All code and test changes were reviewed by the author
before submission.
---------
Signed-off-by: codechrl <[email protected]>
This file contains hidden or 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
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?
Cleans up the API reference page formatting, adds/updates docstrings where applicable (corrects typing + verbiage, adds inline examples).
Related issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.