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

Method add_node

python/ray/cluster_utils.py:204–286  ·  view source on GitHub ↗

Adds a node to the local Ray Cluster. All nodes are by default started with the following settings: cleanup=True, num_cpus=1, object_store_memory=150 * 1024 * 1024 # 150 MiB Args: wait: Whether to wait until the node is alive.

(self, wait: bool = True, **node_args)

Source from the content-addressed store, hash-verified

202 self.connected = True
203
204 def add_node(self, wait: bool = True, **node_args):
205 """Adds a node to the local Ray Cluster.
206
207 All nodes are by default started with the following settings:
208 cleanup=True,
209 num_cpus=1,
210 object_store_memory=150 * 1024 * 1024 # 150 MiB
211
212 Args:
213 wait: Whether to wait until the node is alive.
214 node_args: Keyword arguments used in `start_ray_head` and
215 `start_ray_node`. Overrides defaults.
216
217 Returns:
218 Node object of the added Ray node.
219 """
220 default_kwargs = {
221 "num_cpus": 1,
222 "num_gpus": 0,
223 "object_store_memory": 150 * 1024 * 1024, # 150 MiB
224 "min_worker_port": 0,
225 "max_worker_port": 0,
226 }
227 ray_params = ray._private.parameter.RayParams(**node_args)
228 ray_params.update_if_absent(**default_kwargs)
229 with disable_client_hook():
230 if self.head_node is None:
231 node = ray._private.node.Node(
232 ray_params,
233 head=True,
234 shutdown_at_exit=self._shutdown_at_exit,
235 spawn_reaper=self._shutdown_at_exit,
236 )
237 self.head_node = node
238 self.redis_address = self.head_node.redis_address
239 self.redis_username = node_args.get(
240 "redis_username", ray_constants.REDIS_DEFAULT_USERNAME
241 )
242 self.redis_password = node_args.get(
243 "redis_password", ray_constants.REDIS_DEFAULT_PASSWORD
244 )
245 self.webui_url = self.head_node.webui_url
246 # Init global state accessor when creating head node.
247 gcs_options = GcsClientOptions.create(
248 node.gcs_address,
249 None,
250 allow_cluster_id_nil=True,
251 fetch_cluster_id_if_nil=False,
252 )
253 self.global_state._initialize_global_state(gcs_options)
254 # Write the Ray cluster address for convenience in unit
255 # testing. ray.init() and ray.init(address="auto") will connect
256 # to the local cluster.
257 ray._private.utils.write_ray_address(self.head_node.gcs_address)
258 else:
259 ray_params.update_if_absent(redis_address=self.redis_address)
260 ray_params.update_if_absent(gcs_address=self.gcs_address)
261 # We only need one log monitor per physical node.

Calls 7

update_if_absentMethod · 0.95
_wait_for_nodeMethod · 0.95
disable_client_hookFunction · 0.90
getMethod · 0.65
createMethod · 0.45
addMethod · 0.45