-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bug] Misuse of Docker API and misunderstanding of Ray HA cause test_…
…ray_serve flaky (#650) Cleans up RayServe compatibility test. Co-authored-by: Ubuntu <azureuser@Ubuntu.pqxb1uggpgbehcpt4orv5untcb.rx.internal.cloudapp.net>
- Loading branch information
Showing
3 changed files
with
84 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import requests | ||
from starlette.requests import Request | ||
import ray | ||
from ray import serve | ||
import time | ||
import sys | ||
|
||
# 1: Define a Ray Serve model. | ||
@serve.deployment(route_prefix="/") | ||
class MyModelDeployment: | ||
def __init__(self, msg: str): | ||
self._msg = msg | ||
|
||
def __call__(self): | ||
return self._msg | ||
|
||
ray.init(address='ray://127.0.0.1:10001', namespace=sys.argv[1]) | ||
# 2: Deploy the model. | ||
handle = serve.run(MyModelDeployment.bind(msg="Hello world!")) | ||
# 3: Query the deployment and print the result. | ||
val = ray.get(handle.remote()) | ||
print(val) | ||
assert(val == "Hello world!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import ray | ||
import time | ||
import sys | ||
from ray import serve | ||
|
||
def retry_with_timeout(func, timeout=90): | ||
err = None | ||
for _ in range(timeout): | ||
try: | ||
return func() | ||
except BaseException as e: | ||
err = e | ||
finally: | ||
time.sleep(1) | ||
raise err | ||
|
||
retry_with_timeout(lambda: ray.init(address='ray://127.0.0.1:10001', namespace=sys.argv[1])) | ||
retry_with_timeout(lambda:serve.start(detached=True)) | ||
val = retry_with_timeout(lambda: ray.get(serve.get_deployment("MyModelDeployment").get_handle().remote())) | ||
print(val) | ||
assert(val == "Hello world!") | ||
|