From 89ffb4825fb1ee57c5c42e73f713837bcb652212 Mon Sep 17 00:00:00 2001 From: Lonnie Liu Date: Wed, 14 Aug 2024 22:29:45 +0000 Subject: [PATCH] [serve] `__init__` functions have no return values even for serve deployments Signed-off-by: Lonnie Liu --- .../ray/serve/tests/test_constructor_failure.py | 15 ++++++--------- .../ray/serve/tests/test_controller_recovery.py | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/python/ray/serve/tests/test_constructor_failure.py b/python/ray/serve/tests/test_constructor_failure.py index 23ef14d2daa56..2faab2b6d1dbb 100644 --- a/python/ray/serve/tests/test_constructor_failure.py +++ b/python/ray/serve/tests/test_constructor_failure.py @@ -65,10 +65,8 @@ def __init__(self): else: with open(file_path) as f: content = f.read() - if content == serve.get_replica_context().replica_id.unique_id: - raise RuntimeError("Consistently throwing on same replica.") - else: - return True + if content == serve.get_replica_context().replica_id.unique_id: + raise RuntimeError("Consistently throwing on same replica.") async def serve(self, request): return "hi" @@ -92,11 +90,10 @@ def test_deploy_with_transient_constructor_failure(serve_instance): class TransientConstructorFailureDeployment: def __init__(self): if os.path.exists(file_path): - return True - else: - with open(file_path, "w") as f: - f.write("ONE") - raise RuntimeError("Intentionally throw on first try.") + return + with open(file_path, "w") as f: + f.write("ONE") + raise RuntimeError("Intentionally throw on first try.") async def serve(self, request): return "hi" diff --git a/python/ray/serve/tests/test_controller_recovery.py b/python/ray/serve/tests/test_controller_recovery.py index 5181a835dda81..eae85b20cad4e 100644 --- a/python/ray/serve/tests/test_controller_recovery.py +++ b/python/ray/serve/tests/test_controller_recovery.py @@ -45,7 +45,7 @@ def test_recover_start_from_replica_actor_names(serve_instance, deployment_optio ) class TransientConstructorFailureDeployment: def __init__(self): - return True + pass def __call__(self, *args): return "hii"