Example #1
0
 def send_get_response(result: Any) -> None:
     """Pushes GetResponses to the main DataPath loop to send
     to the client. This is called when the object is ready
     on the server side."""
     try:
         serialized = dumps_from_server(result, client_id, self)
         total_size = len(serialized)
         assert total_size > 0, "Serialized object cannot be zero bytes"
         total_chunks = math.ceil(total_size /
                                  OBJECT_TRANSFER_CHUNK_SIZE)
         for chunk_id in range(request.start_chunk_id,
                               total_chunks):
             start = chunk_id * OBJECT_TRANSFER_CHUNK_SIZE
             end = min(total_size, (chunk_id + 1) *
                       OBJECT_TRANSFER_CHUNK_SIZE)
             get_resp = ray_client_pb2.GetResponse(
                 valid=True,
                 data=serialized[start:end],
                 chunk_id=chunk_id,
                 total_chunks=total_chunks,
                 total_size=total_size,
             )
             chunk_resp = ray_client_pb2.DataResponse(
                 get=get_resp, req_id=req_id)
             result_queue.put(chunk_resp)
     except Exception as exc:
         get_resp = ray_client_pb2.GetResponse(
             valid=False, error=cloudpickle.dumps(exc))
         resp = ray_client_pb2.DataResponse(get=get_resp,
                                            req_id=req_id)
         result_queue.put(resp)
Example #2
0
 def _get_object(self, request, client_id: str, context=None):
     if request.id not in self.object_refs[client_id]:
         return ray_client_pb2.GetResponse(valid=False)
     objectref = self.object_refs[client_id][request.id]
     logger.debug("get: %s" % objectref)
     try:
         with disable_client_hook():
             item = ray.get(objectref, timeout=request.timeout)
     except Exception as e:
         return ray_client_pb2.GetResponse(valid=False,
                                           error=cloudpickle.dumps(e))
     item_ser = dumps_from_server(item, client_id, self)
     return ray_client_pb2.GetResponse(valid=True, data=item_ser)
Example #3
0
 def send_get_response(result: Any) -> None:
     """Pushes a GetResponse to the main DataPath loop to send
     to the client. This is called when the object is ready
     on the server side."""
     try:
         serialized = dumps_from_server(result, client_id, self)
         get_resp = ray_client_pb2.GetResponse(valid=True,
                                               data=serialized)
     except Exception as exc:
         get_resp = ray_client_pb2.GetResponse(
             valid=False, error=cloudpickle.dumps(exc))
     resp = ray_client_pb2.DataResponse(get=get_resp,
                                        req_id=req_id)
     result_queue.put(resp)
Example #4
0
 def _get_object(self,
                 request: ray_client_pb2.GetRequest,
                 client_id: str,
                 context=None):
     objectrefs = []
     for rid in request.ids:
         ref = self.object_refs[client_id].get(rid, None)
         if ref:
             objectrefs.append(ref)
         else:
             return ray_client_pb2.GetResponse(valid=False)
     try:
         logger.debug("get: %s" % objectrefs)
         with disable_client_hook():
             items = ray.get(objectrefs, timeout=request.timeout)
     except Exception as e:
         return ray_client_pb2.GetResponse(valid=False,
                                           error=cloudpickle.dumps(e))
     items_ser = dumps_from_server(items, client_id, self)
     return ray_client_pb2.GetResponse(valid=True, data=items_ser)
Example #5
0
 def _get_object(self, request: ray_client_pb2.GetRequest, client_id: str):
     objectrefs = []
     for rid in request.ids:
         ref = self.object_refs[client_id].get(rid, None)
         if ref:
             objectrefs.append(ref)
         else:
             return ray_client_pb2.GetResponse(
                 valid=False,
                 error=cloudpickle.dumps(
                     ValueError(
                         f"ClientObjectRef {rid} is not found for client "
                         f"{client_id}")))
     try:
         logger.debug("get: %s" % objectrefs)
         with disable_client_hook():
             items = ray.get(objectrefs, timeout=request.timeout)
     except Exception as e:
         return ray_client_pb2.GetResponse(valid=False,
                                           error=cloudpickle.dumps(e))
     serialized = dumps_from_server(items, client_id, self)
     return ray_client_pb2.GetResponse(valid=True, data=serialized)
Example #6
0
 def _get_object(self, request: ray_client_pb2.GetRequest, client_id: str):
     objectrefs = []
     for rid in request.ids:
         ref = self.object_refs[client_id].get(rid, None)
         if ref:
             objectrefs.append(ref)
         else:
             yield ray_client_pb2.GetResponse(
                 valid=False,
                 error=cloudpickle.dumps(
                     ValueError(
                         f"ClientObjectRef {rid} is not found for client "
                         f"{client_id}"
                     )
                 ),
             )
             return
     try:
         logger.debug("get: %s" % objectrefs)
         with disable_client_hook():
             items = ray.get(objectrefs, timeout=request.timeout)
     except Exception as e:
         yield ray_client_pb2.GetResponse(valid=False, error=cloudpickle.dumps(e))
         return
     serialized = dumps_from_server(items, client_id, self)
     total_size = len(serialized)
     assert total_size > 0, "Serialized object cannot be zero bytes"
     total_chunks = math.ceil(total_size / OBJECT_TRANSFER_CHUNK_SIZE)
     for chunk_id in range(request.start_chunk_id, total_chunks):
         start = chunk_id * OBJECT_TRANSFER_CHUNK_SIZE
         end = min(total_size, (chunk_id + 1) * OBJECT_TRANSFER_CHUNK_SIZE)
         yield ray_client_pb2.GetResponse(
             valid=True,
             data=serialized[start:end],
             chunk_id=chunk_id,
             total_chunks=total_chunks,
             total_size=total_size,
         )