mirror of
https://github.com/wassname/ray.git
synced 2026-08-06 13:31:10 +08:00
Refactor CoreWorker to remove TaskInterface (#5924)
* Remove TaskInterface * Remove Status return value * Remove CActorHandle, some return values, TaskSubmitter * lint * doc * doc * fix build * lint * Return Status, guarded by annotation, fail tasks for RECONSTRUCTING actors * fix * move annotation * revert * Fix core worker test * nits
This commit is contained in:
+13
-28
@@ -23,7 +23,6 @@ from libcpp.vector cimport vector as c_vector
|
||||
from cython.operator import dereference, postincrement
|
||||
|
||||
from ray.includes.common cimport (
|
||||
CActorHandle,
|
||||
CLanguage,
|
||||
CRayObject,
|
||||
CRayStatus,
|
||||
@@ -630,7 +629,6 @@ cdef class CoreWorker:
|
||||
CRayFunction ray_function
|
||||
c_vector[CTaskArg] args_vector
|
||||
c_vector[CObjectID] return_ids
|
||||
CTaskID caller_id
|
||||
|
||||
with profiling.profile("submit_task"):
|
||||
prepare_resources(resources, &c_resources)
|
||||
@@ -638,11 +636,9 @@ cdef class CoreWorker:
|
||||
ray_function = CRayFunction(
|
||||
LANGUAGE_PYTHON, string_vector_from_list(function_descriptor))
|
||||
prepare_args(args, &args_vector)
|
||||
caller_id = self.core_worker.get().GetCallerId()
|
||||
|
||||
with nogil:
|
||||
check_status(self.core_worker.get().Tasks().SubmitTask(
|
||||
caller_id,
|
||||
check_status(self.core_worker.get().SubmitTask(
|
||||
ray_function, args_vector, task_options, &return_ids))
|
||||
|
||||
return VectorToObjectIDs(return_ids)
|
||||
@@ -654,13 +650,12 @@ cdef class CoreWorker:
|
||||
resources,
|
||||
placement_resources):
|
||||
cdef:
|
||||
unique_ptr[CActorHandle] actor_handle
|
||||
CRayFunction ray_function
|
||||
c_vector[CTaskArg] args_vector
|
||||
c_vector[c_string] dynamic_worker_options
|
||||
unordered_map[c_string, double] c_resources
|
||||
unordered_map[c_string, double] c_placement_resources
|
||||
CTaskID caller_id
|
||||
CActorID c_actor_id
|
||||
|
||||
with profiling.profile("submit_task"):
|
||||
prepare_resources(resources, &c_resources)
|
||||
@@ -668,22 +663,16 @@ cdef class CoreWorker:
|
||||
ray_function = CRayFunction(
|
||||
LANGUAGE_PYTHON, string_vector_from_list(function_descriptor))
|
||||
prepare_args(args, &args_vector)
|
||||
caller_id = self.core_worker.get().GetCallerId()
|
||||
|
||||
with nogil:
|
||||
check_status(self.core_worker.get().Tasks().CreateActor(
|
||||
caller_id,
|
||||
check_status(self.core_worker.get().CreateActor(
|
||||
ray_function, args_vector,
|
||||
CActorCreationOptions(
|
||||
max_reconstructions, False, c_resources,
|
||||
c_placement_resources, dynamic_worker_options),
|
||||
&actor_handle))
|
||||
&c_actor_id))
|
||||
|
||||
actor_id = ActorID(actor_handle.get().GetActorID().Binary())
|
||||
inserted = self.core_worker.get().AddActorHandle(
|
||||
move(actor_handle))
|
||||
assert inserted, "Actor {} already exists".format(actor_id)
|
||||
return actor_id
|
||||
return ActorID(c_actor_id.Binary())
|
||||
|
||||
def submit_actor_task(self,
|
||||
ActorID actor_id,
|
||||
@@ -699,7 +688,6 @@ cdef class CoreWorker:
|
||||
CRayFunction ray_function
|
||||
c_vector[CTaskArg] args_vector
|
||||
c_vector[CObjectID] return_ids
|
||||
CTaskID caller_id
|
||||
|
||||
with profiling.profile("submit_task"):
|
||||
prepare_resources(resources, &c_resources)
|
||||
@@ -707,12 +695,10 @@ cdef class CoreWorker:
|
||||
ray_function = CRayFunction(
|
||||
LANGUAGE_PYTHON, string_vector_from_list(function_descriptor))
|
||||
prepare_args(args, &args_vector)
|
||||
caller_id = self.core_worker.get().GetCallerId()
|
||||
|
||||
with nogil:
|
||||
check_status(self.core_worker.get().Tasks().SubmitActorTask(
|
||||
caller_id,
|
||||
self.core_worker.get().GetActorHandle(c_actor_id),
|
||||
check_status(self.core_worker.get().SubmitActorTask(
|
||||
c_actor_id,
|
||||
ray_function,
|
||||
args_vector, task_options, &return_ids))
|
||||
|
||||
@@ -726,17 +712,16 @@ cdef class CoreWorker:
|
||||
self.core_worker.get().CreateProfileEvent(c_event_type),
|
||||
extra_data)
|
||||
|
||||
def deserialize_actor_handle(self, c_string bytes):
|
||||
cdef:
|
||||
unique_ptr[CActorHandle] actor_handle
|
||||
actor_handle.reset(new CActorHandle(bytes))
|
||||
actor_id = ActorID(actor_handle.get().GetActorID().Binary())
|
||||
self.core_worker.get().AddActorHandle(move(actor_handle))
|
||||
def deserialize_and_register_actor_handle(self, const c_string &bytes):
|
||||
c_actor_id = self.core_worker.get().DeserializeAndRegisterActorHandle(
|
||||
bytes)
|
||||
actor_id = ActorID(c_actor_id.Binary())
|
||||
return actor_id
|
||||
|
||||
def serialize_actor_handle(self, ActorID actor_id):
|
||||
cdef:
|
||||
CActorID c_actor_id = actor_id.native()
|
||||
c_string output
|
||||
self.core_worker.get().GetActorHandle(c_actor_id).Serialize(&output)
|
||||
check_status(self.core_worker.get().SerializeActorHandle(
|
||||
c_actor_id, &output))
|
||||
return output
|
||||
|
||||
Reference in New Issue
Block a user