Skip to content

Commit

Permalink
[VirtualCluster] fix unexpected auto_ray_init called by get_runtime_c…
Browse files Browse the repository at this point in the history
…ontext (#501)

Signed-off-by: sule <sule.sl@antgroup.com>
  • Loading branch information
xsuler authored Feb 14, 2025
1 parent 127ef79 commit 1519624
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions python/ray/_private/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,9 @@ def nodes(virtual_cluster_id=None):
Information about the Ray clients in the cluster.
"""
if not virtual_cluster_id:
virtual_cluster_id = ray.get_runtime_context().virtual_cluster_id
virtual_cluster_id = (
ray._private.worker.global_worker.current_virtual_cluster_id
)
elif type(virtual_cluster_id) is not str:
raise TypeError(
f"virtual_cluster_id must be a string, got {type(virtual_cluster_id)}"
Expand Down Expand Up @@ -1024,7 +1026,9 @@ def cluster_resources(virtual_cluster_id=None):
resource in the cluster.
"""
if not virtual_cluster_id:
virtual_cluster_id = ray.get_runtime_context().virtual_cluster_id
virtual_cluster_id = (
ray._private.worker.global_worker.current_virtual_cluster_id
)
elif type(virtual_cluster_id) is not str:
raise TypeError(
f"virtual_cluster_id must be a string, got {type(virtual_cluster_id)}"
Expand All @@ -1049,7 +1053,9 @@ def available_resources(virtual_cluster_id=None):
be included in this dictionary.
"""
if not virtual_cluster_id:
virtual_cluster_id = ray.get_runtime_context().virtual_cluster_id
virtual_cluster_id = (
ray._private.worker.global_worker.current_virtual_cluster_id
)
elif type(virtual_cluster_id) is not str:
raise TypeError(
f"virtual_cluster_id must be a string, got {type(virtual_cluster_id)}"
Expand Down Expand Up @@ -1081,7 +1087,9 @@ def total_resources_per_node(virtual_cluster_id=None):
"""

if not virtual_cluster_id:
virtual_cluster_id = ray.get_runtime_context().virtual_cluster_id
virtual_cluster_id = (
ray._private.worker.global_worker.current_virtual_cluster_id
)
elif type(virtual_cluster_id) is not str:
raise TypeError(
f"virtual_cluster_id must be a string, got {type(virtual_cluster_id)}"
Expand Down

0 comments on commit 1519624

Please sign in to comment.