mirror of
https://github.com/wassname/ray.git
synced 2026-07-06 05:16:30 +08:00
Add global state accessor of jobs (#8401)
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
from libcpp.string cimport string as c_string
|
||||
from libcpp cimport bool as c_bool
|
||||
from libcpp.vector cimport vector as c_vector
|
||||
|
||||
cdef extern from "ray/gcs/gcs_client/global_state_accessor.h" nogil:
|
||||
cdef cppclass CGlobalStateAccessor "ray::gcs::GlobalStateAccessor":
|
||||
CGlobalStateAccessor(const c_string &redis_address,
|
||||
const c_string &redis_password,
|
||||
c_bool is_test)
|
||||
c_bool Connect()
|
||||
void Disconnect()
|
||||
c_vector[c_string] GetAllJobInfo()
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
from ray.includes.global_state_accessor cimport (
|
||||
CGlobalStateAccessor,
|
||||
)
|
||||
|
||||
cdef class GlobalStateAccessor:
|
||||
"""Cython wrapper class of C++ `ray::gcs::GlobalStateAccessor`."""
|
||||
cdef:
|
||||
unique_ptr[CGlobalStateAccessor] inner
|
||||
|
||||
def __init__(self, redis_address, redis_password, c_bool is_test_client=False):
|
||||
if not redis_password:
|
||||
redis_password = ""
|
||||
self.inner.reset(
|
||||
new CGlobalStateAccessor(redis_address.encode("ascii"),
|
||||
redis_password.encode("ascii"), is_test_client))
|
||||
|
||||
def connect(self):
|
||||
return self.inner.get().Connect()
|
||||
|
||||
def disconnect(self):
|
||||
self.inner.get().Disconnect()
|
||||
|
||||
def get_job_table(self):
|
||||
return self.inner.get().GetAllJobInfo()
|
||||
Reference in New Issue
Block a user