[Core]Fix get workrer table bug (#11516)

* fix get_worker_table bug

* fix lint

* fix comment

* remove actor table

* fix comment

* fix get alive worker

* remove unused python import
This commit is contained in:
DK.Pino
2020-10-31 05:48:29 +08:00
committed by GitHub
parent 71c5089854
commit b10871a1f5
5 changed files with 20 additions and 1 deletions
+1
View File
@@ -110,6 +110,7 @@ __all__ = [
"get_runtime_context",
"actor",
"actors",
"workers",
"available_resources",
"cancel",
"cluster_resources",
@@ -112,7 +112,7 @@ cdef class GlobalStateAccessor:
def get_worker_table(self):
cdef c_vector[c_string] result
with nogil:
self.inner.get().GetAllWorkerInfo()
result = self.inner.get().GetAllWorkerInfo()
return result
def get_worker_info(self, worker_id):
+9
View File
@@ -876,6 +876,15 @@ def nodes():
return state.node_table()
def workers():
"""Get a list of the workers in the cluster.
Returns:
Information about the Ray workers in the cluster.
"""
return state.workers()
def current_node_id():
"""Return the node id of the current node.
+8
View File
@@ -110,6 +110,14 @@ def test_global_state_actor_table(ray_start_regular):
assert get_state() == dead_state
def test_global_state_worker_table(ray_start_regular):
# Get worker table from gcs.
workers_data = ray.state.workers()
assert len(workers_data) == 1
def test_global_state_actor_entry(ray_start_regular):
@ray.remote
class Actor: