mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 21:23:10 +08:00
[Core] Use map instead of list to represent resources in heartbeat message (#9294)
This commit is contained in:
@@ -97,15 +97,9 @@ class Monitor:
|
||||
message = ray.gcs_utils.HeartbeatBatchTableData.FromString(
|
||||
heartbeat_data)
|
||||
for heartbeat_message in message.batch:
|
||||
resource_load = dict(
|
||||
zip(heartbeat_message.resource_load_label,
|
||||
heartbeat_message.resource_load_capacity))
|
||||
total_resources = dict(
|
||||
zip(heartbeat_message.resources_total_label,
|
||||
heartbeat_message.resources_total_capacity))
|
||||
available_resources = dict(
|
||||
zip(heartbeat_message.resources_available_label,
|
||||
heartbeat_message.resources_available_capacity))
|
||||
resource_load = dict(heartbeat_message.resource_load)
|
||||
total_resources = dict(heartbeat_message.resources_total)
|
||||
available_resources = dict(heartbeat_message.resources_available)
|
||||
for resource in total_resources:
|
||||
available_resources.setdefault(resource, 0.0)
|
||||
|
||||
|
||||
+2
-5
@@ -703,12 +703,9 @@ class GlobalState:
|
||||
heartbeat_data = pub_message.data
|
||||
message = gcs_utils.HeartbeatTableData.FromString(heartbeat_data)
|
||||
# Calculate available resources for this client
|
||||
num_resources = len(message.resources_available_label)
|
||||
dynamic_resources = {}
|
||||
for i in range(num_resources):
|
||||
resource_id = message.resources_available_label[i]
|
||||
dynamic_resources[resource_id] = (
|
||||
message.resources_available_capacity[i])
|
||||
for resource_id, capacity in message.resources_available.items():
|
||||
dynamic_resources[resource_id] = capacity
|
||||
|
||||
# Update available resources for this client
|
||||
client_id = ray.utils.binary_to_hex(message.client_id)
|
||||
|
||||
Reference in New Issue
Block a user