コード例 #1
0
ファイル: server.py プロジェクト: tseiger1/ray
 def ClusterInfo(self,
                 request,
                 context=None) -> ray_client_pb2.ClusterInfoResponse:
     resp = ray_client_pb2.ClusterInfoResponse()
     resp.type = request.type
     if request.type == ray_client_pb2.ClusterInfoType.CLUSTER_RESOURCES:
         resources = ray.cluster_resources()
         # Normalize resources into floats
         # (the function may return values that are ints)
         float_resources = {k: float(v) for k, v in resources.items()}
         resp.resource_table.CopyFrom(
             ray_client_pb2.ClusterInfoResponse.ResourceTable(
                 table=float_resources))
     elif request.type == \
             ray_client_pb2.ClusterInfoType.AVAILABLE_RESOURCES:
         resources = ray.available_resources()
         # Normalize resources into floats
         # (the function may return values that are ints)
         float_resources = {k: float(v) for k, v in resources.items()}
         resp.resource_table.CopyFrom(
             ray_client_pb2.ClusterInfoResponse.ResourceTable(
                 table=float_resources))
     else:
         resp.json = self._return_debug_cluster_info(request, context)
     return resp
コード例 #2
0
ファイル: proxier.py プロジェクト: wuisawesome/ray
    def ClusterInfo(self, request, context=None) -> ray_client_pb2.ClusterInfoResponse:

        # NOTE: We need to respond to the PING request here to allow the client
        # to continue with connecting.
        if request.type == ray_client_pb2.ClusterInfoType.PING:
            resp = ray_client_pb2.ClusterInfoResponse(json=json.dumps({}))
            return resp
        return self._call_inner_function(request, context, "ClusterInfo")
コード例 #3
0
 def ClusterInfo(self,
                 request,
                 context=None) -> ray_client_pb2.ClusterInfoResponse:
     resp = ray_client_pb2.ClusterInfoResponse()
     resp.type = request.type
     if request.type == ray_client_pb2.ClusterInfoType.CLUSTER_RESOURCES:
         with disable_client_hook():
             resources = ray.cluster_resources()
         # Normalize resources into floats
         # (the function may return values that are ints)
         float_resources = {k: float(v) for k, v in resources.items()}
         resp.resource_table.CopyFrom(
             ray_client_pb2.ClusterInfoResponse.ResourceTable(
                 table=float_resources))
     elif request.type == \
             ray_client_pb2.ClusterInfoType.AVAILABLE_RESOURCES:
         with disable_client_hook():
             resources = ray.available_resources()
         # Normalize resources into floats
         # (the function may return values that are ints)
         float_resources = {k: float(v) for k, v in resources.items()}
         resp.resource_table.CopyFrom(
             ray_client_pb2.ClusterInfoResponse.ResourceTable(
                 table=float_resources))
     elif request.type == ray_client_pb2.ClusterInfoType.RUNTIME_CONTEXT:
         ctx = ray_client_pb2.ClusterInfoResponse.RuntimeContext()
         with disable_client_hook():
             rtc = ray.get_runtime_context()
             ctx.job_id = rtc.job_id.binary()
             ctx.node_id = rtc.node_id.binary()
             ctx.namespace = rtc.namespace
             ctx.capture_client_tasks = \
                 rtc.should_capture_child_tasks_in_placement_group
             ctx.runtime_env = json.dumps(rtc.runtime_env)
         resp.runtime_context.CopyFrom(ctx)
     else:
         with disable_client_hook():
             resp.json = self._return_debug_cluster_info(request, context)
     return resp