diff --git a/python/ray/test_utils.py b/python/ray/test_utils.py index 8c74f1314..b580a01e2 100644 --- a/python/ray/test_utils.py +++ b/python/ray/test_utils.py @@ -217,7 +217,7 @@ def wait_for_num_actors(num_actors, timeout=10): raise RayTestTimeoutException("Timed out while waiting for global state.") -def wait_for_condition(condition_predictor, timeout=30, retry_interval_ms=100): +def wait_for_condition(condition_predictor, timeout=10, retry_interval_ms=100): """Wait until a condition is met or time out with an exception. Args: @@ -394,7 +394,7 @@ def init_error_pubsub(): return p -def get_error_message(pub_sub, num, error_type=None, timeout=10): +def get_error_message(pub_sub, num, error_type=None, timeout=5): """Get errors through pub/sub.""" start_time = time.time() msgs = [] diff --git a/python/ray/tests/test_actor.py b/python/ray/tests/test_actor.py index 5e00e30aa..d5ff824ba 100644 --- a/python/ray/tests/test_actor.py +++ b/python/ray/tests/test_actor.py @@ -836,26 +836,5 @@ def test_actor_creation_latency(ray_start_regular_shared): actor_create_time - start, end - start)) -@pytest.mark.parametrize( - "ray_start_regular", [{ - "local_mode": True - }], indirect=True) -def test_detached_actor_local_mode(ray_start_regular): - RETURN_VALUE = 3 - - @ray.remote - class Y: - def f(self): - return RETURN_VALUE - - Y.options(name="test").remote() - y = ray.get_actor("test") - assert ray.get(y.f.remote()) == RETURN_VALUE - - ray.kill(y) - with pytest.raises(ValueError): - ray.get_actor("test") - - if __name__ == "__main__": sys.exit(pytest.main(["-v", __file__])) diff --git a/python/ray/tests/test_actor_advanced.py b/python/ray/tests/test_actor_advanced.py index 651a92c1b..1915d7f6d 100644 --- a/python/ray/tests/test_actor_advanced.py +++ b/python/ray/tests/test_actor_advanced.py @@ -733,6 +733,27 @@ while actor_status["State"] != ray.gcs_utils.ActorTableData.DEAD: create_and_kill_actor(dup_actor_name) +@pytest.mark.parametrize( + "ray_start_regular", [{ + "local_mode": True + }], indirect=True) +def test_detached_actor_local_mode(ray_start_regular): + RETURN_VALUE = 3 + + @ray.remote + class Y: + def f(self): + return RETURN_VALUE + + Y.options(name="test").remote() + y = ray.get_actor("test") + assert ray.get(y.f.remote()) == RETURN_VALUE + + ray.kill(y) + with pytest.raises(ValueError): + ray.get_actor("test") + + @pytest.mark.parametrize( "ray_start_cluster", [{ "num_cpus": 3, @@ -856,13 +877,16 @@ def test_actor_creation_task_crash(ray_start_regular): @pytest.mark.parametrize( "ray_start_regular", [{ "num_cpus": 2, - "num_gpus": 1 - }], indirect=True) + "resources": { + "a": 1 + } + }], + indirect=True) def test_pending_actor_removed_by_owner(ray_start_regular): # Verify when an owner of pending actors is killed, the actor resources # are correctly returned. - @ray.remote(num_cpus=1, num_gpus=1) + @ray.remote(num_cpus=1, resources={"a": 1}) class A: def __init__(self): self.actors = [] @@ -870,12 +894,12 @@ def test_pending_actor_removed_by_owner(ray_start_regular): def create_actors(self): self.actors = [B.remote() for _ in range(2)] - @ray.remote(num_gpus=1) + @ray.remote(resources={"a": 1}) class B: def ping(self): return True - @ray.remote(num_gpus=1) + @ray.remote(resources={"a": 1}) def f(): return True