mirror of
https://github.com/wassname/ray.git
synced 2026-07-15 11:25:40 +08:00
Change Python's ObjectID to ObjectRef (#9353)
This commit is contained in:
+21
-20
@@ -131,7 +131,7 @@ class GlobalState:
|
||||
"""Execute a Redis command on the appropriate Redis shard based on key.
|
||||
|
||||
Args:
|
||||
key: The object ID or the task ID that the query is about.
|
||||
key: The object ref or the task ID that the query is about.
|
||||
args: The command to run.
|
||||
|
||||
Returns:
|
||||
@@ -155,11 +155,11 @@ class GlobalState:
|
||||
result.extend(list(client.scan_iter(match=pattern)))
|
||||
return result
|
||||
|
||||
def object_table(self, object_id=None):
|
||||
"""Fetch and parse the object table info for one or more object IDs.
|
||||
def object_table(self, object_ref=None):
|
||||
"""Fetch and parse the object table info for one or more object refs.
|
||||
|
||||
Args:
|
||||
object_id: An object ID to fetch information about. If this is
|
||||
object_ref: An object ref to fetch information about. If this is
|
||||
None, then the entire object table is fetched.
|
||||
|
||||
Returns:
|
||||
@@ -167,9 +167,10 @@ class GlobalState:
|
||||
"""
|
||||
self._check_connected()
|
||||
|
||||
if object_id is not None:
|
||||
object_id = ray.ObjectID(hex_to_binary(object_id))
|
||||
object_info = self.global_state_accessor.get_object_info(object_id)
|
||||
if object_ref is not None:
|
||||
object_ref = ray.ObjectRef(hex_to_binary(object_ref))
|
||||
object_info = self.global_state_accessor.get_object_info(
|
||||
object_ref)
|
||||
if object_info is None:
|
||||
return {}
|
||||
else:
|
||||
@@ -182,7 +183,7 @@ class GlobalState:
|
||||
for i in range(len(object_table)):
|
||||
object_location_info = gcs_utils.ObjectLocationInfo.FromString(
|
||||
object_table[i])
|
||||
results[binary_to_hex(object_location_info.object_id)] = \
|
||||
results[binary_to_hex(object_location_info.object_ref)] = \
|
||||
self._gen_object_info(object_location_info)
|
||||
return results
|
||||
|
||||
@@ -196,8 +197,8 @@ class GlobalState:
|
||||
locations.append(ray.utils.binary_to_hex(location.manager))
|
||||
|
||||
object_info = {
|
||||
"ObjectID": ray.utils.binary_to_hex(
|
||||
object_location_info.object_id),
|
||||
"ObjectRef": ray.utils.binary_to_hex(
|
||||
object_location_info.object_ref),
|
||||
"Locations": locations,
|
||||
}
|
||||
return object_info
|
||||
@@ -538,21 +539,21 @@ class GlobalState:
|
||||
|
||||
for event in items:
|
||||
if event["event_type"] == "transfer_send":
|
||||
object_id, remote_node_id, _, _ = event["extra_data"]
|
||||
object_ref, remote_node_id, _, _ = event["extra_data"]
|
||||
|
||||
elif event["event_type"] == "transfer_receive":
|
||||
object_id, remote_node_id, _, _ = event["extra_data"]
|
||||
object_ref, remote_node_id, _, _ = event["extra_data"]
|
||||
|
||||
elif event["event_type"] == "receive_pull_request":
|
||||
object_id, remote_node_id = event["extra_data"]
|
||||
object_ref, remote_node_id = event["extra_data"]
|
||||
|
||||
else:
|
||||
assert False, "This should be unreachable."
|
||||
|
||||
# Choose a color by reading the first couple of hex digits of
|
||||
# the object ID as an integer and turning that into a color.
|
||||
object_id_int = int(object_id[:2], 16)
|
||||
color = self._chrome_tracing_colors[object_id_int % len(
|
||||
# the object ref as an integer and turning that into a color.
|
||||
object_ref_int = int(object_ref[:2], 16)
|
||||
color = self._chrome_tracing_colors[object_ref_int % len(
|
||||
self._chrome_tracing_colors)]
|
||||
|
||||
new_event = {
|
||||
@@ -921,17 +922,17 @@ def actors(actor_id=None):
|
||||
return state.actor_table(actor_id=actor_id)
|
||||
|
||||
|
||||
def objects(object_id=None):
|
||||
"""Fetch and parse the object table info for one or more object IDs.
|
||||
def objects(object_ref=None):
|
||||
"""Fetch and parse the object table info for one or more object refs.
|
||||
|
||||
Args:
|
||||
object_id: An object ID to fetch information about. If this is None,
|
||||
object_ref: An object ref to fetch information about. If this is None,
|
||||
then the entire object table is fetched.
|
||||
|
||||
Returns:
|
||||
Information from the object table.
|
||||
"""
|
||||
return state.object_table(object_id=object_id)
|
||||
return state.object_table(object_ref=object_ref)
|
||||
|
||||
|
||||
def timeline(filename=None):
|
||||
|
||||
Reference in New Issue
Block a user