-
Notifications
You must be signed in to change notification settings - Fork 7.2k
[Serve] Refactor ray.serve for compatibility #4759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e1ccca6
69b082e
0fcec26
50b9c37
41b9d52
2001245
024a7e1
46ccdab
413ccc5
64a9ebd
eeef9d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
| from pprint import pformat | ||
|
|
||
|
|
||
| def list_changed_files(commit_range): | ||
|
|
@@ -26,24 +28,37 @@ def list_changed_files(commit_range): | |
| return [s.strip() for s in out.decode().splitlines() if s is not None] | ||
|
|
||
|
|
||
| def print_and_log(s): | ||
| print(s) | ||
| sys.stderr.write(s) | ||
| sys.stderr.write("\n") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
| RAY_CI_TUNE_AFFECTED = 0 | ||
| RAY_CI_RLLIB_AFFECTED = 0 | ||
| RAY_CI_SERVE_AFFECTED = 0 | ||
| RAY_CI_JAVA_AFFECTED = 0 | ||
| RAY_CI_PYTHON_AFFECTED = 0 | ||
| RAY_CI_LINUX_WHEELS_AFFECTED = 0 | ||
| RAY_CI_MACOS_WHEELS_AFFECTED = 0 | ||
|
|
||
| RAY_CI_PY3 = 1 if sys.version_info >= (3, 5) else 0 | ||
|
|
||
| if os.environ["TRAVIS_EVENT_TYPE"] == "pull_request": | ||
|
|
||
| files = list_changed_files(os.environ["TRAVIS_COMMIT_RANGE"].replace( | ||
| "...", "..")) | ||
|
|
||
| skip_prefix_list = [ | ||
| "doc/", "examples/", "dev/", "docker/", "kubernetes/", "site/" | ||
| "doc/", "examples/", "dev/", "docker/", "kubernetes/", "site/", | ||
| "ci/", ".travis.yml" | ||
| ] | ||
|
|
||
| sys.stderr.write("Files Changed\n") | ||
| sys.stderr.write(pformat(files)) | ||
|
|
||
| for changed_file in files: | ||
| if changed_file.startswith("python/ray/tune/"): | ||
| RAY_CI_TUNE_AFFECTED = 1 | ||
|
|
@@ -54,6 +69,10 @@ def list_changed_files(commit_range): | |
| RAY_CI_RLLIB_AFFECTED = 1 | ||
| RAY_CI_LINUX_WHEELS_AFFECTED = 1 | ||
| RAY_CI_MACOS_WHEELS_AFFECTED = 1 | ||
| elif changed_file.startswith("python/ray/experimental/serve"): | ||
| RAY_CI_SERVE_AFFECTED = 1 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also need to add |
||
| RAY_CI_LINUX_WHEELS_AFFECTED = 1 | ||
| RAY_CI_MACOS_WHEELS_AFFECTED = 1 | ||
| elif changed_file.startswith("python/"): | ||
| RAY_CI_TUNE_AFFECTED = 1 | ||
| RAY_CI_RLLIB_AFFECTED = 1 | ||
|
|
@@ -89,11 +108,18 @@ def list_changed_files(commit_range): | |
| RAY_CI_LINUX_WHEELS_AFFECTED = 1 | ||
| RAY_CI_MACOS_WHEELS_AFFECTED = 1 | ||
|
|
||
| print("export RAY_CI_TUNE_AFFECTED={}".format(RAY_CI_TUNE_AFFECTED)) | ||
| print("export RAY_CI_RLLIB_AFFECTED={}".format(RAY_CI_RLLIB_AFFECTED)) | ||
| print("export RAY_CI_JAVA_AFFECTED={}".format(RAY_CI_JAVA_AFFECTED)) | ||
| print("export RAY_CI_PYTHON_AFFECTED={}".format(RAY_CI_PYTHON_AFFECTED)) | ||
| print("export RAY_CI_LINUX_WHEELS_AFFECTED={}" | ||
| .format(RAY_CI_LINUX_WHEELS_AFFECTED)) | ||
| print("export RAY_CI_MACOS_WHEELS_AFFECTED={}" | ||
| .format(RAY_CI_MACOS_WHEELS_AFFECTED)) | ||
| print_and_log("export RAY_CI_PY3={}".format(RAY_CI_PY3)) | ||
| print_and_log( | ||
| "export RAY_CI_TUNE_AFFECTED={}".format(RAY_CI_TUNE_AFFECTED)) | ||
| print_and_log( | ||
| "export RAY_CI_RLLIB_AFFECTED={}".format(RAY_CI_RLLIB_AFFECTED)) | ||
| print_and_log( | ||
| "export RAY_CI_SERVE_AFFECTED={}".format(RAY_CI_SERVE_AFFECTED)) | ||
| print_and_log( | ||
| "export RAY_CI_JAVA_AFFECTED={}".format(RAY_CI_JAVA_AFFECTED)) | ||
| print_and_log( | ||
| "export RAY_CI_PYTHON_AFFECTED={}".format(RAY_CI_PYTHON_AFFECTED)) | ||
| print_and_log("export RAY_CI_LINUX_WHEELS_AFFECTED={}".format( | ||
| RAY_CI_LINUX_WHEELS_AFFECTED)) | ||
| print_and_log("export RAY_CI_MACOS_WHEELS_AFFECTED={}".format( | ||
| RAY_CI_MACOS_WHEELS_AFFECTED)) | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,108 @@ | ||||||||||
| """ | ||||||||||
| This file contains example ray servable actors. These actors | ||||||||||
| are used for testing as well as demoing purpose. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| from __future__ import absolute_import, division, print_function | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| import time | ||||||||||
|
|
||||||||||
| import numpy as np | ||||||||||
|
|
||||||||||
| import ray | ||||||||||
| from ray.experimental.serve import RayServeMixin, batched_input | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @ray.remote | ||||||||||
| class VectorizedAdder(RayServeMixin): | ||||||||||
| """Actor that adds scaler_increment to input batch. | ||||||||||
|
|
||||||||||
| result = np.array(input_batch) + scaler_increment | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| def __init__(self, scaler_increment): | ||||||||||
| self.inc = scaler_increment | ||||||||||
|
|
||||||||||
| @batched_input | ||||||||||
| def __call__(self, input_batch): | ||||||||||
| arr = np.array(input_batch) | ||||||||||
| arr += self.inc | ||||||||||
| return arr.tolist() | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @ray.remote | ||||||||||
| class ScalerAdder(RayServeMixin): | ||||||||||
| """Actor that adds a scaler_increment to a single input.""" | ||||||||||
|
|
||||||||||
| def __init__(self, scaler_increment): | ||||||||||
| self.inc = scaler_increment | ||||||||||
|
|
||||||||||
| def __call__(self, input_scaler): | ||||||||||
| return input_scaler + self.inc | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @ray.remote | ||||||||||
| class VectorDouble(RayServeMixin): | ||||||||||
| """Actor that doubles the batched input.""" | ||||||||||
|
|
||||||||||
| @batched_input | ||||||||||
| def __call__(self, batched_vectors): | ||||||||||
| matrix = np.array(batched_vectors) | ||||||||||
| matrix *= 2 | ||||||||||
| return [v.tolist() for v in matrix] | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @ray.remote | ||||||||||
| class Counter(RayServeMixin): | ||||||||||
| """Return the query id. Used for testing router.""" | ||||||||||
|
|
||||||||||
| def __init__(self): | ||||||||||
| self.counter = 0 | ||||||||||
|
|
||||||||||
| def __call__(self, batched_input): | ||||||||||
| self.counter += 1 | ||||||||||
| return self.counter | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @ray.remote | ||||||||||
| class CustomCounter(RayServeMixin): | ||||||||||
| """Return the query id. Used for testing `serve_method` signature.""" | ||||||||||
|
|
||||||||||
| serve_method = "count" | ||||||||||
|
|
||||||||||
| @batched_input | ||||||||||
| def count(self, input_batch): | ||||||||||
| return [1 for _ in range(len(input_batch))] | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @ray.remote | ||||||||||
| class SleepOnFirst(RayServeMixin): | ||||||||||
| """Sleep on the first request, return batch size. | ||||||||||
|
|
||||||||||
| Used for testing the DeadlineAwareRouter. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| def __init__(self, sleep_time): | ||||||||||
| self.nap_time = sleep_time | ||||||||||
|
|
||||||||||
| @batched_input | ||||||||||
| def __call__(self, input_batch): | ||||||||||
| time.sleep(self.nap_time) | ||||||||||
| return [len(input_batch) for _ in range(len(input_batch))] | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @ray.remote | ||||||||||
| class SleepCounter(RayServeMixin): | ||||||||||
| """Sleep on input argument seconds, return the query id. | ||||||||||
|
|
||||||||||
| Used to test the DeadlineAwareRouter. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| def __init__(self): | ||||||||||
| self.counter = 0 | ||||||||||
|
|
||||||||||
| def __call__(self, inp): | ||||||||||
| time.sleep(inp) | ||||||||||
|
|
||||||||||
| self.counter += 1 | ||||||||||
| return self.counter | ||||||||||
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the
RAY_CI_PY3variable here.