diff --git a/python/ray/tests/test_client.py b/python/ray/tests/test_client.py index 4ee54ed1eac6..e648009f95e3 100644 --- a/python/ray/tests/test_client.py +++ b/python/ray/tests/test_client.py @@ -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__])) diff --git a/python/ray/util/client/__init__.py b/python/ray/util/client/__init__.py index e56b096ed27d..f862f9714a7d 100644 --- a/python/ray/util/client/__init__.py +++ b/python/ray/util/client/__init__.py @@ -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: diff --git a/python/ray/util/client/runtime_context.py b/python/ray/util/client/runtime_context.py index 054cd16ea60a..0fe9f33935cf 100644 --- a/python/ray/util/client/runtime_context.py +++ b/python/ray/util/client/runtime_context.py @@ -1,4 +1,5 @@ from typing import TYPE_CHECKING +from types import SimpleNamespace if TYPE_CHECKING: from ray import JobID, NodeID @@ -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) diff --git a/python/ray/util/client/server/server.py b/python/ray/util/client/server/server.py index 962b8bbb1c19..bf896efec210 100644 --- a/python/ray/util/client/server/server.py +++ b/python/ray/util/client/server/server.py @@ -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: diff --git a/src/ray/protobuf/ray_client.proto b/src/ray/protobuf/ray_client.proto index 33dc40f15140..864145a144d3 100644 --- a/src/ray/protobuf/ray_client.proto +++ b/src/ray/protobuf/ray_client.proto @@ -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;