MCPcopy
hub / github.com/ray-project/ray / get_node_id

Method get_node_id

python/ray/runtime_context.py:98–116  ·  view source on GitHub ↗

Get the ID for the node that this process is running on. This can be called from within a driver, task, or actor. When called from a driver that is connected to a remote Ray cluster using Ray Client, this returns the ID of the head node. Returns: A node

(self)

Source from the content-addressed store, hash-verified

96 return node_id
97
98 def get_node_id(self) -> str:
99 """Get the ID for the node that this process is running on.
100
101 This can be called from within a driver, task, or actor.
102 When called from a driver that is connected to a remote Ray cluster using
103 Ray Client, this returns the ID of the head node.
104
105 Returns:
106 A node id in hex format for this worker or driver.
107
108 Raises:
109 RuntimeError: If Ray has not been initialized.
110 """
111 if not ray.is_initialized():
112 raise RuntimeError(
113 "Node ID is not available because Ray has not been initialized."
114 )
115 node_id = self.worker.current_node_id
116 return node_id.hex()
117
118 def get_temp_dir(self) -> str:
119 """Get the temp directory for the current node.

Callers

nothing calls this directly

Calls 2

is_initializedMethod · 0.45
hexMethod · 0.45

Tested by

no test coverage detected