def test_real_ray_fallback(ray_start_regular_shared): with ray_start_client_server() as ray: @ray.remote def get_nodes_real(): import ray as real_ray return real_ray.nodes() nodes = ray.get(get_nodes_real.remote()) assert len(nodes) == 1, nodes @ray.remote def get_nodes(): # Can access the full Ray API in remote methods. return ray.nodes() nodes = ray.get(get_nodes.remote()) assert len(nodes) == 1, nodes with pytest.raises(NotImplementedError): print(ray.nodes())
def test_real_ray_fallback(ray_start_regular_shared): server = ray_client_server.serve("localhost:50051") ray.connect("localhost:50051") @ray.remote def get_nodes_real(): import ray as real_ray return real_ray.nodes() nodes = ray.get(get_nodes_real.remote()) assert len(nodes) == 1, nodes @ray.remote def get_nodes(): return ray.nodes() # Can access the full Ray API in remote methods. nodes = ray.get(get_nodes.remote()) assert len(nodes) == 1, nodes with pytest.raises(NotImplementedError): print(ray.nodes()) server.stop(0)
def get_nodes(): # Can access the full Ray API in remote methods. return ray.nodes()
print(x, type(fact)) if x <= 0: return 1 # This hits the "nested tasks" issue # https://github.com/ray-project/ray/issues/3644 # So we're on the right track! return ray.get(fact.remote(x - 1)) * x @ray.remote def get_nodes(): return ray.nodes() # Can access the full Ray API in remote methods. print("Cluster nodes", ray.get(get_nodes.remote())) print(ray.nodes()) objectref = ray.put("hello world") # `ClientObjectRef(...)` print(objectref) # `hello world` print(ray.get(objectref)) ref2 = plus2.remote(234) # `ClientObjectRef(...)` print(ref2) # `236` print(ray.get(ref2))