diff --git a/doc/source/advanced.rst b/doc/source/advanced.rst index ea431bb24..bfc2161f9 100644 --- a/doc/source/advanced.rst +++ b/doc/source/advanced.rst @@ -190,36 +190,6 @@ appear as the task name in the logs. .. image:: images/task_name_dashboard.png -Dynamic Custom Resources ------------------------- - -Ray enables explicit developer control with respect to the task and actor placement by using custom resources. Further, users are able to dynamically adjust custom resources programmatically with ``ray.experimental.set_resource``. This allows the Ray application to implement virtually any scheduling policy, including task affinity, data locality, anti-affinity, -load balancing, gang scheduling, and priority-based scheduling. - - -.. code-block:: python - - ray.init() - resource_name = "test_resource" - resource_capacity = 1.0 - - @ray.remote - def set_resource(resource_name, resource_capacity): - ray.experimental.set_resource(resource_name, resource_capacity) - - ray.get(set_resource.remote(resource_name, resource_capacity)) - - available_resources = ray.available_resources() - cluster_resources = ray.cluster_resources() - - assert available_resources[resource_name] == resource_capacity - assert cluster_resources[resource_name] == resource_capacity - - -.. autofunction:: ray.experimental.set_resource - :noindex: - - Accelerator Types ------------------ diff --git a/python/ray/experimental/dynamic_resources.py b/python/ray/experimental/dynamic_resources.py index 0abb9cd13..8594e6d7e 100644 --- a/python/ray/experimental/dynamic_resources.py +++ b/python/ray/experimental/dynamic_resources.py @@ -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.")