mirror of
https://github.com/wassname/ray.git
synced 2026-07-20 12:40:20 +08:00
Automatically create custom node id resource (#5882)
* node id * comment * comments * fix tests
This commit is contained in:
@@ -13,6 +13,10 @@ import ray.ray_constants as ray_constants
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Prefix for the node id resource that is automatically added to each node.
|
||||
# For example, a node may have id `node:172.23.42.1`.
|
||||
NODE_ID_PREFIX = "node:"
|
||||
|
||||
|
||||
class ResourceSpec(
|
||||
namedtuple("ResourceSpec", [
|
||||
@@ -127,6 +131,10 @@ class ResourceSpec(
|
||||
assert "memory" not in resources, resources
|
||||
assert "object_store_memory" not in resources, resources
|
||||
|
||||
# Automatically create a node id resource on each node. This is
|
||||
# queryable with ray.state.node_ids() and ray.state.current_node_id().
|
||||
resources[NODE_ID_PREFIX + ray.services.get_node_ip_address()] = 1.0
|
||||
|
||||
num_cpus = self.num_cpus
|
||||
if num_cpus is None:
|
||||
num_cpus = multiprocessing.cpu_count()
|
||||
|
||||
Reference in New Issue
Block a user