-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[Core] Add options(...) function to @ray.remote stubs #47330
Conversation
0fb26b7
to
32b71af
Compare
Seems like the failing |
@ruisearch42 since this is on the worker side of the house can you PTAL? @can-anyscale any recommendation on how we can skip/pass the seemingly unrelated RLLib failing tests? TY for the contribution @milesvant |
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.
Thanks for the contribution.
Left a couple questions, but otherwise LGTM.
RF = TypeVar("RF", bound="HasOptions") | ||
|
||
|
||
class HasOptions(Protocol): |
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.
I understand that generally it is better to have proper type annotations. Just wondering in this particular case, are you trying to achieve something specific? What is the use case that you were trying to enable? IIUC currently Ray runs mypy on a limited number of files.
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.
I work in a codebase that uses the pattern in the description/issue frequently, and has strict type checking. Without this sort of annotation I have to ignore typechecking on most usages of Ray
6591434
to
0f34734
Compare
0f34734
to
2a19809
Compare
Signed-off-by: Miles Van Tongeren <[email protected]>
Signed-off-by: Miles Van Tongeren <[email protected]>
Signed-off-by: Miles Van Tongeren <[email protected]>
2a19809
to
1b72dc7
Compare
@ruisearch42 What can I do to get this merged? I think the failing tests are flaky |
@rkooo567 Does this look good to you? If so, we can ask CI team to force merge. |
@ruisearch42 @rkooo567 bump |
@milesvant can you merge master and retry? |
@ruisearch42 |
@ruisearch42 @jjyao @rynewang bump |
) ## Why are these changes needed? Removes incorrect `mypy` failures resulting from using `@ray.remote`. On my reproduction script: ``` import ray @ray.remote def fn(x: int) -> int: return 2 * x def main() -> None: fn_with_cpus = fn.options(num_cpus=1) print(ray.get(fn_with_cpus.remote(4))) if __name__ == "__main__": ray.init() main() ray.shutdown() ``` with nightly Ray, `mypy script.py` produces `error: "RemoteFunction0[int, int]" has no attribute "options" [attr-defined]` whereas my branch produces no error. Signed-off-by: Miles Van Tongeren <[email protected]> Signed-off-by: ujjawal-khare <[email protected]>
Why are these changes needed?
Removes incorrect
mypy
failures resulting from using@ray.remote
.On my reproduction script:
with nightly Ray,
mypy script.py
produceserror: "RemoteFunction0[int, int]" has no attribute "options" [attr-defined]
whereas my branch produces no error.Related issue number
Closes #47329.
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.