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)
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)
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
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