Files
kuberay/ray-operator/config/samples/config-map-ray-code.yaml
Xiaoyu ZhaiandGitHub 55ee4468c8 Update samples yaml (#102)
* Update samples yaml

* Remove configmap volumn part to keep the mini one clean
2021-11-21 21:06:59 +08:00

25 lines
740 B
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: ray-code
data:
sample_code.py: |
import ray
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._private.services.get_node_ip_address()
values=set(ray.get([f.remote() for _ in range(1000)]))
print("Ray Nodes: ",str(values))
file = open("/tmp/ray_nodes.txt","a")
file.write("available nodes: %s\n" % str(values))
file.close()
end = time.time()
print("Execution time = ",end - start)