ray/benchmarks/distributed/wait_cluster.py
Balaji Veeramani 7f1bacc7dc
[CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes.
2022-01-29 18:41:57 -08:00

24 lines
510 B
Python

import click
import ray
import time
def num_alive_nodes():
n = 0
for node in ray.nodes():
if node["Alive"]:
n += 1
return n
@click.command()
@click.option("--num-nodes", required=True, type=int, help="The target number of nodes")
def wait_cluster(num_nodes: int):
ray.init(address="auto")
while num_alive_nodes() != num_nodes:
print(f"Waiting for nodes: {num_alive_nodes()}/{num_nodes}")
time.sleep(5)
if __name__ == "__main__":
wait_cluster()