mirror of
https://github.com/vale981/ray
synced 2025-03-06 18:41:40 -05:00

* start * check formatting * undo changes from base branch * Client builder API docs * indent * 8 * minor fixes * absolute path to runtime env docs * fix runtime_env link * Update worker.init docs * drop clientbuilder docs, link to 1.4.1 docs instead. Specify local:// behavior when address passed * add debug info for ray.init("local") * local:// attaches a driver directly * update ray.init return wording * remote init.connect() from example * drop local:// docs, add section on when to use ray client * link to 1.4.1 docs in code example instead of mentioning clientbuilder * fix backticks, doc mentions of ray.util.connect * remove ray.util.connect mentions from examples and comments * update tune example * wording * localhost:<port> also works if you're on the head node * add quotes * drop mentions of ray client from ray.init docstring * local->remote * fix section ref * update ray start output * fix section link * try to fix doc again * fix link wording * drop local:// from docs and special handling from code * update ray start message * lint * doc lint * remove local:// codepath * remove 'internal_config' * Update doc/source/cluster/ray-client.rst Co-authored-by: Ameer Haj Ali <ameerh@berkeley.edu> * doc suggestion * Update doc/source/cluster/ray-client.rst Co-authored-by: Ameer Haj Ali <ameerh@berkeley.edu>
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
from collections import Counter
|
|
import sys
|
|
import time
|
|
import ray
|
|
""" This script is meant to be run from a pod in the same Kubernetes namespace
|
|
as your Ray cluster.
|
|
"""
|
|
|
|
|
|
@ray.remote
|
|
def gethostname(x):
|
|
import platform
|
|
import time
|
|
time.sleep(0.01)
|
|
return x + (platform.node(), )
|
|
|
|
|
|
def wait_for_nodes(expected):
|
|
# Wait for all nodes to join the cluster.
|
|
while True:
|
|
resources = ray.cluster_resources()
|
|
node_keys = [key for key in resources if "node" in key]
|
|
num_nodes = sum(resources[node_key] for node_key in node_keys)
|
|
if num_nodes < expected:
|
|
print("{} nodes have joined so far, waiting for {} more.".format(
|
|
num_nodes, expected - num_nodes))
|
|
sys.stdout.flush()
|
|
time.sleep(1)
|
|
else:
|
|
break
|
|
|
|
|
|
def main():
|
|
wait_for_nodes(3)
|
|
|
|
# Check that objects can be transferred from each node to each other node.
|
|
for i in range(10):
|
|
print("Iteration {}".format(i))
|
|
results = [
|
|
gethostname.remote(gethostname.remote(())) for _ in range(100)
|
|
]
|
|
print(Counter(ray.get(results)))
|
|
sys.stdout.flush()
|
|
|
|
print("Success!")
|
|
sys.stdout.flush()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
ray.init("ray://example-cluster-ray-head:10001")
|
|
main()
|