コード例 #1
0
ファイル: common.py プロジェクト: supatomic/ray
        def deserialize_obj(resp: ray_client_pb2.DataResponse) -> None:
            """Converts from a GetResponse proto to a python object."""
            obj = resp.get
            data = None
            if not obj.valid:
                data = loads_from_server(resp.get.error)
            else:
                data = loads_from_server(resp.get.data)

            py_callback(data)
コード例 #2
0
        def deserialize_obj(
                resp: Union[ray_client_pb2.DataResponse, Exception]) -> None:
            from ray.util.client.client_pickler import loads_from_server

            if isinstance(resp, Exception):
                data = resp
            else:
                obj = resp.get
                data = None
                if not obj.valid:
                    data = loads_from_server(resp.get.error)
                else:
                    data = loads_from_server(resp.get.data)

            py_callback(data)
コード例 #3
0
ファイル: worker.py プロジェクト: alipay/ray
 def _get(self, ref: List[ClientObjectRef], timeout: float):
     req = ray_client_pb2.GetRequest(ids=[r.id for r in ref],
                                     timeout=timeout)
     data = bytearray()
     try:
         resp = self._get_object_iterator(req, metadata=self.metadata)
         for chunk in resp:
             if not chunk.valid:
                 try:
                     err = cloudpickle.loads(chunk.error)
                 except (pickle.UnpicklingError, TypeError):
                     logger.exception("Failed to deserialize {}".format(
                         chunk.error))
                     raise
                 raise err
             if chunk.total_size > OBJECT_TRANSFER_WARNING_SIZE and log_once(
                     "client_object_transfer_size_warning"):
                 size_gb = chunk.total_size / 2**30
                 warnings.warn(
                     "Ray Client is attempting to retrieve a "
                     f"{size_gb:.2f} GiB object over the network, which may "
                     "be slow. Consider serializing the object to a file "
                     "and using S3 or rsync instead.",
                     UserWarning,
                     stacklevel=5,
                 )
             data.extend(chunk.data)
     except grpc.RpcError as e:
         raise decode_exception(e)
     return loads_from_server(data)
コード例 #4
0
ファイル: worker.py プロジェクト: alipay/ray
def decode_exception(e: grpc.RpcError) -> Exception:
    if e.code() != grpc.StatusCode.ABORTED:
        # The ABORTED status code is used by the server when an application
        # error is serialized into the the exception details. If the code
        # isn't ABORTED, then return the original error since there's no
        # serialized error to decode.
        # See server.py::return_exception_in_context for details
        return ConnectionError(f"GRPC connection failed: {e}")
    data = base64.standard_b64decode(e.details())
    return loads_from_server(data)
コード例 #5
0
 def _get(self, ref: ClientObjectRef, timeout: float):
     req = ray_client_pb2.GetRequest(id=ref.id, timeout=timeout)
     try:
         data = self.data_client.GetObject(req)
     except grpc.RpcError as e:
         raise e.details()
     if not data.valid:
         err = cloudpickle.loads(data.error)
         logger.error(err)
         raise err
     return loads_from_server(data.data)
コード例 #6
0
 def _get(self, ref: ClientObjectRef, timeout: float):
     req = ray_client_pb2.GetRequest(id=ref.id, timeout=timeout)
     try:
         data = self.data_client.GetObject(req)
     except grpc.RpcError as e:
         raise decode_exception(e.details())
     if not data.valid:
         try:
             err = cloudpickle.loads(data.error)
         except pickle.UnpicklingError:
             logger.exception("Failed to deserialize {}".format(data.error))
             raise
         raise err
     return loads_from_server(data.data)
コード例 #7
0
ファイル: worker.py プロジェクト: afzalmushtaque/ray
 def _get(self, ref: List[ClientObjectRef], timeout: float):
     req = ray_client_pb2.GetRequest(ids=[r.id for r in ref], timeout=timeout)
     try:
         resp = self._call_stub("GetObject", req, metadata=self.metadata)
     except grpc.RpcError as e:
         raise decode_exception(e)
     if not resp.valid:
         try:
             err = cloudpickle.loads(resp.error)
         except (pickle.UnpicklingError, TypeError):
             logger.exception("Failed to deserialize {}".format(resp.error))
             raise
         raise err
     return loads_from_server(resp.data)
コード例 #8
0
def decode_exception(data) -> Exception:
    data = base64.standard_b64decode(data)
    return loads_from_server(data)