Rename fields/variables from client id to node id (#12457)

This commit is contained in:
Tao Wang
2020-11-30 14:33:36 +08:00
committed by GitHub
parent 3964defbe1
commit b85c6abc3e
43 changed files with 670 additions and 682 deletions
+7 -7
View File
@@ -1,20 +1,20 @@
import ray
def set_resource(resource_name, capacity, client_id=None):
def set_resource(resource_name, capacity, node_id=None):
""" Set a resource to a specified capacity.
This creates, updates or deletes a custom resource for a target NodeID.
If the resource already exists, it's capacity is updated to the new value.
If the capacity is set to 0, the resource is deleted.
If NodeID is not specified or set to None,
the resource is created on the local client where the actor is running.
the resource is created on the local node where the actor is running.
Args:
resource_name (str): Name of the resource to be created
capacity (int): Capacity of the new resource. Resource is deleted if
capacity is 0.
client_id (str): The NodeID of the node where the resource is to be
node_id (str): The NodeID of the node where the resource is to be
set.
Returns:
@@ -24,12 +24,12 @@ def set_resource(resource_name, capacity, client_id=None):
ValueError: This exception is raised when a non-negative capacity is
specified.
"""
if client_id is not None:
client_id_obj = ray.NodeID(ray.utils.hex_to_binary(client_id))
if node_id is not None:
node_id_obj = ray.NodeID(ray.utils.hex_to_binary(node_id))
else:
client_id_obj = ray.NodeID.nil()
node_id_obj = ray.NodeID.nil()
if (capacity < 0) or (capacity != int(capacity)):
raise ValueError(
"Capacity {} must be a non-negative integer.".format(capacity))
return ray.worker.global_worker.core_worker.set_resource(
resource_name, capacity, client_id_obj)
resource_name, capacity, node_id_obj)