Export remote functions when first used and also fix bug in which rem… (#4844)

* Export remote functions when first used and also fix bug in which remote functions and actor classes are not exported from workers during subsequent ray sessions.

* Documentation update

* Fix tests.

* Fix grammar
This commit is contained in:
Robert Nishihara
2019-05-24 13:44:39 -07:00
committed by Philipp Moritz
parent 4e281ba938
commit 49fe894e22
7 changed files with 66 additions and 52 deletions
+31
View File
@@ -303,6 +303,23 @@ def test_complex_serialization(ray_start_regular):
assert_equal(obj, ray.get(ray.put(obj)))
def test_nested_functions(ray_start_regular):
# Make sure that remote functions can use other values that are defined
# after the remote function but before the first function invocation.
@ray.remote
def f():
return g(), ray.get(h.remote())
def g():
return 1
@ray.remote
def h():
return 2
assert ray.get(f.remote()) == (1, 2)
def test_ray_recursive_objects(ray_start_regular):
class ClassA(object):
pass
@@ -2968,3 +2985,17 @@ def test_export_after_shutdown(ray_start_regular):
ray.get(f.remote())
a = Actor.remote()
ray.get(a.method.remote())
ray.shutdown()
# Start Ray again and make sure that these definitions can be exported from
# workers.
ray.init(num_cpus=2)
@ray.remote
def export_definitions_from_worker(remote_function, actor_class):
ray.get(remote_function.remote())
actor_handle = actor_class.remote()
ray.get(actor_handle.method.remote())
ray.get(export_definitions_from_worker.remote(f, Actor))