mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
Rename msft-operator to ray-operator. See https://github.com/ray-project/ray-contrib/issues/17 for more details Signed-off-by: Jiaxin Shan <[email protected]>
27 lines
817 B
YAML
27 lines
817 B
YAML
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: ray-code
|
|
data:
|
|
# note: /var should be writable to write to /var/ray_nodes.txt
|
|
code.py: |
|
|
import ray
|
|
from ray import services
|
|
from os import environ
|
|
redis_pass = environ.get("REDIS_PASSWORD")
|
|
print("trying to connect to Ray!")
|
|
ray.init(address="auto", _redis_password=redis_pass)
|
|
print("now executing some code with Ray!")
|
|
import time
|
|
start = time.time()
|
|
@ray.remote
|
|
def f():
|
|
time.sleep(0.01)
|
|
return ray.services.get_node_ip_address()
|
|
values=set(ray.get([f.remote() for _ in range(1000)]))
|
|
print("Ray Nodes: ",str(values))
|
|
file = open("/var/ray_nodes.txt","a")
|
|
file.write("available nodes: %s\n" % str(values))
|
|
file.close()
|
|
end = time.time()
|
|
print("Execution time = ",end - start) |