Implement Detached Actor (#6036)

* Arg propagation works

* Implement persistent actor

* Add doc

* Initialize is_persistent_

* Rename persistent->detached

* Address comment

* Make test passes

* Address comment

* Python2 compatiblity

* Fix naming, py2

* Lint
This commit is contained in:
Simon Mo
2019-11-01 10:28:23 -07:00
committed by GitHub
parent f7455839bf
commit 7f5b3502da
16 changed files with 164 additions and 27 deletions
+37 -6
View File
@@ -21,12 +21,9 @@ import ray.ray_constants as ray_constants
import ray.tests.utils
import ray.tests.cluster_utils
from ray.tests.conftest import generate_internal_config_map
from ray.tests.utils import (
relevant_errors,
wait_for_condition,
wait_for_errors,
wait_for_pid_to_exit,
)
from ray.tests.utils import (relevant_errors, wait_for_condition,
wait_for_errors, wait_for_pid_to_exit,
run_string_as_driver)
@pytest.fixture
@@ -2816,3 +2813,37 @@ def test_ray_wait_dead_actor(ray_start_cluster):
failure_detected = False
while not failure_detected:
failure_detected = ray.get(parent_actor.wait.remote())
def test_detached_actor(ray_start_regular):
@ray.remote
class DetachedActor(object):
def ping(self):
return "pong"
with pytest.raises(Exception, match="Detached actors must be named"):
DetachedActor._remote(detached=True)
with pytest.raises(ValueError, match="Please use a different name"):
_ = DetachedActor._remote(name="d_actor")
DetachedActor._remote(name="d_actor")
redis_address = ray_start_regular["redis_address"]
actor_name = "DetachedActor"
driver_script = """
import ray
ray.init(address="{}")
@ray.remote
class DetachedActor(object):
def ping(self):
return "pong"
actor = DetachedActor._remote(name="{}", detached=True)
ray.get(actor.ping.remote())
""".format(redis_address, actor_name)
run_string_as_driver(driver_script)
detached_actor = ray.experimental.get_actor(actor_name)
assert ray.get(detached_actor.ping.remote()) == "pong"