mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 06:15:23 +08:00
Refactor ID Serial 2: change all ID functions to CamelCase (#4896)
This commit is contained in:
@@ -80,7 +80,7 @@ cdef c_vector[CObjectID] ObjectIDsToVector(object_ids):
|
||||
cdef VectorToObjectIDs(c_vector[CObjectID] object_ids):
|
||||
result = []
|
||||
for i in range(object_ids.size()):
|
||||
result.append(ObjectID(object_ids[i].binary()))
|
||||
result.append(ObjectID(object_ids[i].Binary()))
|
||||
return result
|
||||
|
||||
|
||||
@@ -88,11 +88,11 @@ def compute_put_id(TaskID task_id, int64_t put_index):
|
||||
if put_index < 1 or put_index > kMaxTaskPuts:
|
||||
raise ValueError("The range of 'put_index' should be [1, %d]"
|
||||
% kMaxTaskPuts)
|
||||
return ObjectID(CObjectID.for_put(task_id.native(), put_index).binary())
|
||||
return ObjectID(CObjectID.ForPut(task_id.native(), put_index).Binary())
|
||||
|
||||
|
||||
def compute_task_id(ObjectID object_id):
|
||||
return TaskID(object_id.native().task_id().binary())
|
||||
return TaskID(object_id.native().TaskId().Binary())
|
||||
|
||||
|
||||
cdef c_bool is_simple_value(value, int *num_elements_contained):
|
||||
@@ -362,7 +362,7 @@ cdef class RayletClient:
|
||||
with nogil:
|
||||
check_status(self.client.get().PrepareActorCheckpoint(
|
||||
c_actor_id, checkpoint_id))
|
||||
return ActorCheckpointID(checkpoint_id.binary())
|
||||
return ActorCheckpointID(checkpoint_id.Binary())
|
||||
|
||||
def notify_actor_resumed_from_checkpoint(self, ActorID actor_id,
|
||||
ActorCheckpointID checkpoint_id):
|
||||
@@ -370,7 +370,7 @@ cdef class RayletClient:
|
||||
actor_id.native(), checkpoint_id.native()))
|
||||
|
||||
def set_resource(self, basestring resource_name, double capacity, ClientID client_id):
|
||||
self.client.get().SetResource(resource_name.encode("ascii"), capacity, CClientID.from_binary(client_id.binary()))
|
||||
self.client.get().SetResource(resource_name.encode("ascii"), capacity, CClientID.FromBinary(client_id.binary()))
|
||||
|
||||
@property
|
||||
def language(self):
|
||||
@@ -378,11 +378,11 @@ cdef class RayletClient:
|
||||
|
||||
@property
|
||||
def client_id(self):
|
||||
return ClientID(self.client.get().GetClientID().binary())
|
||||
return ClientID(self.client.get().GetClientID().Binary())
|
||||
|
||||
@property
|
||||
def driver_id(self):
|
||||
return DriverID(self.client.get().GetDriverID().binary())
|
||||
return DriverID(self.client.get().GetDriverID().Binary())
|
||||
|
||||
@property
|
||||
def is_worker(self):
|
||||
|
||||
@@ -124,15 +124,15 @@ cdef class Task:
|
||||
|
||||
def driver_id(self):
|
||||
"""Return the driver ID for this task."""
|
||||
return DriverID(self.task_spec.get().DriverId().binary())
|
||||
return DriverID(self.task_spec.get().DriverId().Binary())
|
||||
|
||||
def task_id(self):
|
||||
"""Return the task ID for this task."""
|
||||
return TaskID(self.task_spec.get().TaskId().binary())
|
||||
return TaskID(self.task_spec.get().TaskId().Binary())
|
||||
|
||||
def parent_task_id(self):
|
||||
"""Return the task ID of the parent task."""
|
||||
return TaskID(self.task_spec.get().ParentTaskId().binary())
|
||||
return TaskID(self.task_spec.get().ParentTaskId().Binary())
|
||||
|
||||
def parent_counter(self):
|
||||
"""Return the parent counter of this task."""
|
||||
@@ -162,7 +162,7 @@ cdef class Task:
|
||||
if count > 0:
|
||||
assert count == 1
|
||||
arg_list.append(
|
||||
ObjectID(task_spec.ArgId(i, 0).binary()))
|
||||
ObjectID(task_spec.ArgId(i, 0).Binary()))
|
||||
else:
|
||||
serialized_str = (
|
||||
task_spec.ArgVal(i)[:task_spec.ArgValLength(i)])
|
||||
@@ -178,7 +178,7 @@ cdef class Task:
|
||||
cdef CTaskSpecification *task_spec = self.task_spec.get()
|
||||
return_id_list = []
|
||||
for i in range(task_spec.NumReturns()):
|
||||
return_id_list.append(ObjectID(task_spec.ReturnId(i).binary()))
|
||||
return_id_list.append(ObjectID(task_spec.ReturnId(i).Binary()))
|
||||
return return_id_list
|
||||
|
||||
def required_resources(self):
|
||||
@@ -207,16 +207,16 @@ cdef class Task:
|
||||
|
||||
def actor_creation_id(self):
|
||||
"""Return the actor creation ID for the task."""
|
||||
return ActorID(self.task_spec.get().ActorCreationId().binary())
|
||||
return ActorID(self.task_spec.get().ActorCreationId().Binary())
|
||||
|
||||
def actor_creation_dummy_object_id(self):
|
||||
"""Return the actor creation dummy object ID for the task."""
|
||||
return ObjectID(
|
||||
self.task_spec.get().ActorCreationDummyObjectId().binary())
|
||||
self.task_spec.get().ActorCreationDummyObjectId().Binary())
|
||||
|
||||
def actor_id(self):
|
||||
"""Return the actor ID for this task."""
|
||||
return ActorID(self.task_spec.get().ActorId().binary())
|
||||
return ActorID(self.task_spec.get().ActorId().Binary())
|
||||
|
||||
def actor_counter(self):
|
||||
"""Return the actor counter for this task."""
|
||||
|
||||
@@ -8,116 +8,116 @@ cdef extern from "ray/id.h" namespace "ray" nogil:
|
||||
T from_random()
|
||||
|
||||
@staticmethod
|
||||
T from_binary(const c_string &binary)
|
||||
T FromBinary(const c_string &binary)
|
||||
|
||||
@staticmethod
|
||||
const T nil()
|
||||
const T Nil()
|
||||
|
||||
@staticmethod
|
||||
size_t size()
|
||||
size_t Size()
|
||||
|
||||
size_t hash() const
|
||||
c_bool is_nil() const
|
||||
size_t Hash() const
|
||||
c_bool IsNil() const
|
||||
c_bool operator==(const CBaseID &rhs) const
|
||||
c_bool operator!=(const CBaseID &rhs) const
|
||||
const uint8_t *data() const;
|
||||
|
||||
c_string binary() const;
|
||||
c_string hex() const;
|
||||
c_string Binary() const;
|
||||
c_string Hex() const;
|
||||
|
||||
cdef cppclass CUniqueID "ray::UniqueID"(CBaseID):
|
||||
CUniqueID()
|
||||
|
||||
@staticmethod
|
||||
size_t size()
|
||||
size_t Size()
|
||||
|
||||
@staticmethod
|
||||
CUniqueID from_random()
|
||||
|
||||
@staticmethod
|
||||
CUniqueID from_binary(const c_string &binary)
|
||||
CUniqueID FromBinary(const c_string &binary)
|
||||
|
||||
@staticmethod
|
||||
const CUniqueID nil()
|
||||
const CUniqueID Nil()
|
||||
|
||||
@staticmethod
|
||||
size_t size()
|
||||
size_t Size()
|
||||
|
||||
cdef cppclass CActorCheckpointID "ray::ActorCheckpointID"(CUniqueID):
|
||||
|
||||
@staticmethod
|
||||
CActorCheckpointID from_binary(const c_string &binary)
|
||||
CActorCheckpointID FromBinary(const c_string &binary)
|
||||
|
||||
cdef cppclass CActorClassID "ray::ActorClassID"(CUniqueID):
|
||||
|
||||
@staticmethod
|
||||
CActorClassID from_binary(const c_string &binary)
|
||||
CActorClassID FromBinary(const c_string &binary)
|
||||
|
||||
cdef cppclass CActorID "ray::ActorID"(CUniqueID):
|
||||
|
||||
@staticmethod
|
||||
CActorID from_binary(const c_string &binary)
|
||||
CActorID FromBinary(const c_string &binary)
|
||||
|
||||
cdef cppclass CActorHandleID "ray::ActorHandleID"(CUniqueID):
|
||||
|
||||
@staticmethod
|
||||
CActorHandleID from_binary(const c_string &binary)
|
||||
CActorHandleID FromBinary(const c_string &binary)
|
||||
|
||||
cdef cppclass CClientID "ray::ClientID"(CUniqueID):
|
||||
|
||||
@staticmethod
|
||||
CClientID from_binary(const c_string &binary)
|
||||
CClientID FromBinary(const c_string &binary)
|
||||
|
||||
cdef cppclass CConfigID "ray::ConfigID"(CUniqueID):
|
||||
|
||||
@staticmethod
|
||||
CConfigID from_binary(const c_string &binary)
|
||||
CConfigID FromBinary(const c_string &binary)
|
||||
|
||||
cdef cppclass CFunctionID "ray::FunctionID"(CUniqueID):
|
||||
|
||||
@staticmethod
|
||||
CFunctionID from_binary(const c_string &binary)
|
||||
CFunctionID FromBinary(const c_string &binary)
|
||||
|
||||
cdef cppclass CDriverID "ray::DriverID"(CUniqueID):
|
||||
|
||||
@staticmethod
|
||||
CDriverID from_binary(const c_string &binary)
|
||||
CDriverID FromBinary(const c_string &binary)
|
||||
|
||||
cdef cppclass CTaskID "ray::TaskID"(CBaseID[CTaskID]):
|
||||
|
||||
@staticmethod
|
||||
CTaskID from_binary(const c_string &binary)
|
||||
CTaskID FromBinary(const c_string &binary)
|
||||
|
||||
@staticmethod
|
||||
const CTaskID nil()
|
||||
const CTaskID Nil()
|
||||
|
||||
@staticmethod
|
||||
size_t size()
|
||||
size_t Size()
|
||||
|
||||
cdef cppclass CObjectID" ray::ObjectID"(CBaseID[CObjectID]):
|
||||
|
||||
@staticmethod
|
||||
CObjectID from_binary(const c_string &binary)
|
||||
CObjectID FromBinary(const c_string &binary)
|
||||
|
||||
@staticmethod
|
||||
const CObjectID nil()
|
||||
const CObjectID Nil()
|
||||
|
||||
@staticmethod
|
||||
CObjectID for_put(const CTaskID &task_id, int64_t index);
|
||||
CObjectID ForPut(const CTaskID &task_id, int64_t index);
|
||||
|
||||
@staticmethod
|
||||
CObjectID for_task_return(const CTaskID &task_id, int64_t index);
|
||||
CObjectID ForTaskReturn(const CTaskID &task_id, int64_t index);
|
||||
|
||||
@staticmethod
|
||||
size_t size()
|
||||
size_t Size()
|
||||
|
||||
c_bool is_put()
|
||||
|
||||
int64_t object_index() const
|
||||
int64_t ObjectIndex() const
|
||||
|
||||
CTaskID task_id() const
|
||||
CTaskID TaskId() const
|
||||
|
||||
cdef cppclass CWorkerID "ray::WorkerID"(CUniqueID):
|
||||
|
||||
@staticmethod
|
||||
CWorkerID from_binary(const c_string &binary)
|
||||
CWorkerID FromBinary(const c_string &binary)
|
||||
|
||||
@@ -97,7 +97,7 @@ cdef class UniqueID(BaseID):
|
||||
|
||||
def __init__(self, id):
|
||||
check_id(id)
|
||||
self.data = CUniqueID.from_binary(id)
|
||||
self.data = CUniqueID.FromBinary(id)
|
||||
|
||||
@classmethod
|
||||
def from_binary(cls, id_bytes):
|
||||
@@ -107,27 +107,27 @@ cdef class UniqueID(BaseID):
|
||||
|
||||
@classmethod
|
||||
def nil(cls):
|
||||
return cls(CUniqueID.nil().binary())
|
||||
return cls(CUniqueID.Nil().Binary())
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_random(cls):
|
||||
return cls(os.urandom(CUniqueID.size()))
|
||||
return cls(os.urandom(CUniqueID.Size()))
|
||||
|
||||
def size(self):
|
||||
return CUniqueID.size()
|
||||
return CUniqueID.Size()
|
||||
|
||||
def binary(self):
|
||||
return self.data.binary()
|
||||
return self.data.Binary()
|
||||
|
||||
def hex(self):
|
||||
return decode(self.data.hex())
|
||||
return decode(self.data.Hex())
|
||||
|
||||
def is_nil(self):
|
||||
return self.data.is_nil()
|
||||
return self.data.IsNil()
|
||||
|
||||
cdef size_t hash(self):
|
||||
return self.data.hash()
|
||||
return self.data.Hash()
|
||||
|
||||
|
||||
cdef class ObjectID(BaseID):
|
||||
@@ -135,78 +135,78 @@ cdef class ObjectID(BaseID):
|
||||
|
||||
def __init__(self, id):
|
||||
check_id(id)
|
||||
self.data = CObjectID.from_binary(<c_string>id)
|
||||
self.data = CObjectID.FromBinary(<c_string>id)
|
||||
|
||||
cdef CObjectID native(self):
|
||||
return <CObjectID>self.data
|
||||
|
||||
def size(self):
|
||||
return CObjectID.size()
|
||||
return CObjectID.Size()
|
||||
|
||||
def binary(self):
|
||||
return self.data.binary()
|
||||
return self.data.Binary()
|
||||
|
||||
def hex(self):
|
||||
return decode(self.data.hex())
|
||||
return decode(self.data.Hex())
|
||||
|
||||
def is_nil(self):
|
||||
return self.data.is_nil()
|
||||
return self.data.IsNil()
|
||||
|
||||
cdef size_t hash(self):
|
||||
return self.data.hash()
|
||||
return self.data.Hash()
|
||||
|
||||
@classmethod
|
||||
def nil(cls):
|
||||
return cls(CObjectID.nil().binary())
|
||||
return cls(CObjectID.Nil().Binary())
|
||||
|
||||
@classmethod
|
||||
def from_random(cls):
|
||||
return cls(os.urandom(CObjectID.size()))
|
||||
return cls(os.urandom(CObjectID.Size()))
|
||||
|
||||
|
||||
cdef class TaskID(BaseID):
|
||||
cdef CTaskID data
|
||||
|
||||
def __init__(self, id):
|
||||
check_id(id, CTaskID.size())
|
||||
self.data = CTaskID.from_binary(<c_string>id)
|
||||
check_id(id, CTaskID.Size())
|
||||
self.data = CTaskID.FromBinary(<c_string>id)
|
||||
|
||||
cdef CTaskID native(self):
|
||||
return <CTaskID>self.data
|
||||
|
||||
def size(self):
|
||||
return CTaskID.size()
|
||||
return CTaskID.Size()
|
||||
|
||||
def binary(self):
|
||||
return self.data.binary()
|
||||
return self.data.Binary()
|
||||
|
||||
def hex(self):
|
||||
return decode(self.data.hex())
|
||||
return decode(self.data.Hex())
|
||||
|
||||
def is_nil(self):
|
||||
return self.data.is_nil()
|
||||
return self.data.IsNil()
|
||||
|
||||
cdef size_t hash(self):
|
||||
return self.data.hash()
|
||||
return self.data.Hash()
|
||||
|
||||
@classmethod
|
||||
def nil(cls):
|
||||
return cls(CTaskID.nil().binary())
|
||||
return cls(CTaskID.Nil().Binary())
|
||||
|
||||
@classmethod
|
||||
def size(cla):
|
||||
return CTaskID.size()
|
||||
return CTaskID.Size()
|
||||
|
||||
@classmethod
|
||||
def from_random(cls):
|
||||
return cls(os.urandom(CTaskID.size()))
|
||||
return cls(os.urandom(CTaskID.Size()))
|
||||
|
||||
|
||||
cdef class ClientID(UniqueID):
|
||||
|
||||
def __init__(self, id):
|
||||
check_id(id)
|
||||
self.data = CClientID.from_binary(<c_string>id)
|
||||
self.data = CClientID.FromBinary(<c_string>id)
|
||||
|
||||
cdef CClientID native(self):
|
||||
return <CClientID>self.data
|
||||
@@ -216,7 +216,7 @@ cdef class DriverID(UniqueID):
|
||||
|
||||
def __init__(self, id):
|
||||
check_id(id)
|
||||
self.data = CDriverID.from_binary(<c_string>id)
|
||||
self.data = CDriverID.FromBinary(<c_string>id)
|
||||
|
||||
cdef CDriverID native(self):
|
||||
return <CDriverID>self.data
|
||||
@@ -226,7 +226,7 @@ cdef class ActorID(UniqueID):
|
||||
|
||||
def __init__(self, id):
|
||||
check_id(id)
|
||||
self.data = CActorID.from_binary(<c_string>id)
|
||||
self.data = CActorID.FromBinary(<c_string>id)
|
||||
|
||||
cdef CActorID native(self):
|
||||
return <CActorID>self.data
|
||||
@@ -236,7 +236,7 @@ cdef class ActorHandleID(UniqueID):
|
||||
|
||||
def __init__(self, id):
|
||||
check_id(id)
|
||||
self.data = CActorHandleID.from_binary(<c_string>id)
|
||||
self.data = CActorHandleID.FromBinary(<c_string>id)
|
||||
|
||||
cdef CActorHandleID native(self):
|
||||
return <CActorHandleID>self.data
|
||||
@@ -246,7 +246,7 @@ cdef class ActorCheckpointID(UniqueID):
|
||||
|
||||
def __init__(self, id):
|
||||
check_id(id)
|
||||
self.data = CActorCheckpointID.from_binary(<c_string>id)
|
||||
self.data = CActorCheckpointID.FromBinary(<c_string>id)
|
||||
|
||||
cdef CActorCheckpointID native(self):
|
||||
return <CActorCheckpointID>self.data
|
||||
@@ -256,7 +256,7 @@ cdef class FunctionID(UniqueID):
|
||||
|
||||
def __init__(self, id):
|
||||
check_id(id)
|
||||
self.data = CFunctionID.from_binary(<c_string>id)
|
||||
self.data = CFunctionID.FromBinary(<c_string>id)
|
||||
|
||||
cdef CFunctionID native(self):
|
||||
return <CFunctionID>self.data
|
||||
@@ -266,7 +266,7 @@ cdef class ActorClassID(UniqueID):
|
||||
|
||||
def __init__(self, id):
|
||||
check_id(id)
|
||||
self.data = CActorClassID.from_binary(<c_string>id)
|
||||
self.data = CActorClassID.FromBinary(<c_string>id)
|
||||
|
||||
cdef CActorClassID native(self):
|
||||
return <CActorClassID>self.data
|
||||
|
||||
Reference in New Issue
Block a user