mirror of
https://github.com/wassname/ray.git
synced 2026-08-05 13:21:03 +08:00
Deprecate experimental / dynamic resources (#13019)
This commit is contained in:
@@ -1,35 +1,6 @@
|
||||
import ray
|
||||
|
||||
|
||||
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 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.
|
||||
node_id (str): The NodeID of the node where the resource is to be
|
||||
set.
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
Raises:
|
||||
ValueError: This exception is raised when a non-negative capacity is
|
||||
specified.
|
||||
"""
|
||||
if node_id is not None:
|
||||
node_id_obj = ray.NodeID(ray.utils.hex_to_binary(node_id))
|
||||
else:
|
||||
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, node_id_obj)
|
||||
raise DeprecationWarning(
|
||||
"Dynamic custom resources are deprecated. Consider using placement "
|
||||
"groups instead (docs.ray.io/en/master/placement-group.html). You "
|
||||
"can also specify resources at Ray start time with the 'resources' "
|
||||
"field in the cluster autoscaler.")
|
||||
|
||||
Reference in New Issue
Block a user