Skip to content

Commit

Permalink
[Client] Implement runtime_context().gcs_address (ray-project#36895)
Browse files Browse the repository at this point in the history
Fixes gcs_address for RuntimeContexts on Ray Client.

Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
  • Loading branch information
ckw017 authored and arvind-chandra committed Aug 31, 2023
1 parent ceb890c commit c883687
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions python/ray/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,15 @@ def get_value(self):
assert ray.get(deserialized.get_value.remote()) == 1234


def test_get_runtime_context_gcs_client(call_ray_start_shared):
"""
Tests get_runtime_context gcs_client
"""
with ray_start_client_server_for_address(call_ray_start_shared) as ray:
context = ray.get_runtime_context()
assert context.gcs_address, "gcs_address not set"


if __name__ == "__main__":
if os.environ.get("PARALLEL_CI"):
sys.exit(pytest.main(["-n", "auto", "--boxed", "-vs", __file__]))
Expand Down
2 changes: 1 addition & 1 deletion python/ray/util/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# This version string is incremented to indicate breaking changes in the
# protocol that require upgrading the client version.
CURRENT_PROTOCOL_VERSION = "2022-12-06"
CURRENT_PROTOCOL_VERSION = "2023-06-27"


class _ClientContext:
Expand Down
8 changes: 8 additions & 0 deletions python/ray/util/client/runtime_context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import TYPE_CHECKING
from types import SimpleNamespace

if TYPE_CHECKING:
from ray import JobID, NodeID
Expand Down Expand Up @@ -55,3 +56,10 @@ def should_capture_child_tasks_in_placement_group(self) -> bool:
@property
def runtime_env(self) -> str:
return self._fetch_runtime_context().runtime_env

def check_connected(self) -> bool:
return self.worker.ping_server()

@property
def gcs_client(self) -> str:
return SimpleNamespace(address=self._fetch_runtime_context().gcs_address)
1 change: 1 addition & 0 deletions python/ray/util/client/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def ClusterInfo(self, request, context=None) -> ray_client_pb2.ClusterInfoRespon
ctx.capture_client_tasks = (
rtc.should_capture_child_tasks_in_placement_group
)
ctx.gcs_address = rtc.gcs_address
ctx.runtime_env = rtc.get_runtime_env_string()
resp.runtime_context.CopyFrom(ctx)
else:
Expand Down
1 change: 1 addition & 0 deletions src/ray/protobuf/ray_client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ message ClusterInfoResponse {
string namespace = 3;
string runtime_env = 4;
bool capture_client_tasks = 5;
string gcs_address = 6;
}

ClusterInfoType.TypeEnum type = 1;
Expand Down

0 comments on commit c883687

Please sign in to comment.