-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[no_early_kickoff] Make sure all public APIs will auto-init ray #34730
Conversation
Signed-off-by: Hao Chen <chenh1024@gmail.com>
Nice! |
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.
Cool. Consider adding a unit tests / automated checks for the symbols exposed in init as you mentioned earlier.
Btw, our convention is to "assign" reviewers instead of "request reviewers". This is because assignees show up persistently in github.com/pulls
, but review requests sometimes appear and disappear so it's not a great way to track what PRs you're supposed to review.
Signed-off-by: Hao Chen <chenh1024@gmail.com>
@@ -25,7 +26,8 @@ | |||
_filesystem = None | |||
|
|||
|
|||
@client_mode_hook(auto_init=True) | |||
@wrap_auto_init |
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.
This api (along with get_client
and list_named_actors
) isn't part of __init__.py:__all__
.
Not sure if they should be there. I didn't move them to __all__
, but just added a standalone wrapper there.
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.
Sounds good. They are not public APIs yet, but the plan is to eventually get them there.
If you want to auto-wrap the APIs, would it be better to have a separate list? Something like
We probably don't want things like |
@pcmoritz that makes sense. Currently I avoid ObjectID by only only wrapping function objects. |
Signed-off-by: Hao Chen <chenh1024@gmail.com>
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.
The new scheme makes sense I think.
I do enourage you to put it into ray/__init__.py
like
AUTO_INIT_APIS = [
"cancel",
"get",
"get_actor",
"get_gpu_ids",
"get_runtime_context",
"kill",
"put",
"wait",
]
wrap_auto_init_for_apis(AUTO_INIT_APIS)
since that makes it a little more discoverable for adding new APIs :)
python/ray/__init__.py
Outdated
"kill", | ||
"put", | ||
"wait", | ||
] |
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.
Hmm, I think it's actually a bug that cluster_resources / available_resources isn't enabled in auto init. To make sure folks don't forgot one or the other, how about we make this explicit, and have:
AUTO_INIT_APIS = [...]
NO_AUTO_INIT_APIS = [...]
And raise an error if there is some API that is not in one of these lists?
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.
How can we collect the full list of all APIs? I checked @PublicAPI
. There are too many. And most of them are not Ray core APIs.
I think it's actually a bug that cluster_resources / available_resources isn't enabled in auto init.
Which bug do you refer to? The bug reported in #34631 is because get_runtime_context
doesn't auto init. "cluster_resources / available_resources" still don't auto init. Not sure whether they should.
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.
To clarify, I mean the previous list of APIs in "all", the list of 20 or so things including ObjectID.
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.
sounds good. Refactored the "init.py" file. do you want to take a another look?
Signed-off-by: Hao Chen <chenh1024@gmail.com>
There are a number of tests failing with this currently. |
Signed-off-by: Hao Chen <chenh1024@gmail.com>
Signed-off-by: Hao Chen <chenh1024@gmail.com>
It turns out that we cannot simply auto init |
- Fix the issue that `get_runtime_context` won't auto-init ray. - Make sure all public APIs will auto-init ray, by decorating all functions in `__all__` of `ray/__init__.py`. - Decouple auto-init with client mode.
…mote" (#36334) #34730 changed `__all__` in `__init__.py` to a computed list. mypy doesn't support this. Reverting it back to a literal list to fix this issue. Repro: `mypy --strict --follow-imports=skip --ignore-missing-imports 1.py` ```python # 1.py import ray @ray.remote def foo() -> None: pass ``` Note, the reason why CI didn't catch this issue is because we don't enable strict mode, see [here](https://github.com/ray-project/ray/blob/407062499038344b0f3edb54b2c7985c3320d1ec/ci/lint/format.sh#L135). Currently we have too many issues if enabling strict mode. Signed-off-by: Hao Chen <chenh1024@gmail.com>
…mote" (ray-project#36334) ray-project#34730 changed `__all__` in `__init__.py` to a computed list. mypy doesn't support this. Reverting it back to a literal list to fix this issue. Repro: `mypy --strict --follow-imports=skip --ignore-missing-imports 1.py` ```python # 1.py import ray @ray.remote def foo() -> None: pass ``` Note, the reason why CI didn't catch this issue is because we don't enable strict mode, see [here](https://github.com/ray-project/ray/blob/407062499038344b0f3edb54b2c7985c3320d1ec/ci/lint/format.sh#L135). Currently we have too many issues if enabling strict mode. Signed-off-by: Hao Chen <chenh1024@gmail.com>
…mote" (#36334) (#36356) #34730 changed `__all__` in `__init__.py` to a computed list. mypy doesn't support this. Reverting it back to a literal list to fix this issue. Repro: `mypy --strict --follow-imports=skip --ignore-missing-imports 1.py` ```python # 1.py import ray @ray.remote def foo() -> None: pass ``` Note, the reason why CI didn't catch this issue is because we don't enable strict mode, see [here](https://github.com/ray-project/ray/blob/407062499038344b0f3edb54b2c7985c3320d1ec/ci/lint/format.sh#L135). Currently we have too many issues if enabling strict mode. Signed-off-by: Hao Chen <chenh1024@gmail.com>
…mote" (ray-project#36334) ray-project#34730 changed `__all__` in `__init__.py` to a computed list. mypy doesn't support this. Reverting it back to a literal list to fix this issue. Repro: `mypy --strict --follow-imports=skip --ignore-missing-imports 1.py` ```python # 1.py import ray @ray.remote def foo() -> None: pass ``` Note, the reason why CI didn't catch this issue is because we don't enable strict mode, see [here](https://github.com/ray-project/ray/blob/407062499038344b0f3edb54b2c7985c3320d1ec/ci/lint/format.sh#L135). Currently we have too many issues if enabling strict mode. Signed-off-by: Hao Chen <chenh1024@gmail.com> Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
Why are these changes needed?
get_runtime_context
won't auto-init ray.__all__
ofray/__init__.py
.Related issue number
Fixes #34631
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.