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

This commit is contained in:
mwtian 2021-10-06 20:20:47 -07:00 committed by GitHub
parent 86cbe3e833
commit fe413c3c5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -189,7 +189,7 @@ _runtime_context = None
@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.

View file

@ -220,6 +220,14 @@ def test_actor_stats_async_actor(ray_start_regular):
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__]))