Exemplo n.º 1
0
 def call_remote(self, instance, *args, **kwargs):
     task = instance._prepare_client_task()
     for arg in args:
         pb_arg = convert_to_arg(arg)
         task.args.append(pb_arg)
     logging.debug("Scheduling %s" % task)
     ticket = self.server.Schedule(task, metadata=self.metadata)
     return ClientObjectRef.from_remote_ref(ticket.return_ref)
Exemplo n.º 2
0
 def call_remote(self, func, *args, **kwargs):
     if not isinstance(func, ClientRemoteFunc):
         raise TypeError("Client not passing a ClientRemoteFunc stub")
     func_ref = self._put(func)
     task = ray_client_pb2.ClientTask()
     task.name = func._name
     task.payload_id = func_ref.id
     for arg in args:
         pb_arg = convert_to_arg(arg)
         task.args.append(pb_arg)
     ticket = self.server.Schedule(task)
     return ClientObjectRef(ticket.return_id)
Exemplo n.º 3
0
 def _call_method(self, instance: ClientRemoteMethod, *args, **kwargs):
     if not isinstance(instance, ClientRemoteMethod):
         raise TypeError("Client not passing a ClientRemoteMethod stub")
     task = ray_client_pb2.ClientTask()
     task.type = ray_client_pb2.ClientTask.METHOD
     task.name = instance.method_name
     task.payload_id = instance.actor_handle.actor_id.id
     for arg in args:
         pb_arg = convert_to_arg(arg)
         task.args.append(pb_arg)
     ticket = self.server.Schedule(task, metadata=self.metadata)
     return ticket
Exemplo n.º 4
0
 def _put_and_schedule(self, item, task_type, *args, **kwargs):
     if isinstance(item, ClientRemoteFunc):
         ref = self._put(item)
     elif isinstance(item, ClientActorClass):
         ref = self._put(item.actor_cls)
     else:
         raise TypeError("Client not passing a ClientRemoteFunc stub")
     task = ray_client_pb2.ClientTask()
     task.type = task_type
     task.name = item._name
     task.payload_id = ref.id
     for arg in args:
         pb_arg = convert_to_arg(arg)
         task.args.append(pb_arg)
     ticket = self.server.Schedule(task, metadata=self.metadata)
     return ticket