Skip to content
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

[Client] disable auto init for get_runtime_context() #19127

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/ray/runtime_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _get_actor_call_stats(self):


@PublicAPI(stability="beta")
@client_mode_hook(auto_init=True)
@client_mode_hook(auto_init=False)
def get_runtime_context():
"""Get the runtime context of the current driver/worker.

Expand Down
8 changes: 8 additions & 0 deletions python/ray/tests/test_runtime_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ async def func(self):
assert max(result["AysncActor.func"]["pending"] for result in results) == 3


# get_runtime_context() can be called outside of Ray so it should not start
# Ray automatically.
def test_no_auto_init(shutdown_only):
assert not ray.is_initialized()
ray.get_runtime_context()
assert not ray.is_initialized()


if __name__ == "__main__":
import pytest
sys.exit(pytest.main(["-v", __file__]))