From e4f4c7925256b5f55bdc6a096539398de4601711 Mon Sep 17 00:00:00 2001 From: Yi Cheng <74173148+iycheng@users.noreply.github.com> Date: Mon, 27 Sep 2021 21:52:13 -0700 Subject: [PATCH] Revert "[Serve] [doc] Improve runtime env doc (#18782)" (#18935) This reverts commit d4d71985d5fccb88284355c94657663eac7ab4d6. --- .buildkite/pipeline.macos.yml | 2 +- .buildkite/pipeline.yml | 4 +-- doc/source/serve/core-apis.rst | 32 ++++++++++------------ python/ray/serve/BUILD | 8 ------ python/ray/serve/backend_state.py | 5 ++-- python/ray/serve/examples/doc/conda_env.py | 23 ++++++++-------- 6 files changed, 29 insertions(+), 45 deletions(-) diff --git a/.buildkite/pipeline.macos.yml b/.buildkite/pipeline.macos.yml index 4efee1df1..592347d44 100644 --- a/.buildkite/pipeline.macos.yml +++ b/.buildkite/pipeline.macos.yml @@ -64,7 +64,7 @@ steps: commands: - *prelude_commands - TORCH_VERSION=1.6 ./ci/travis/install-dependencies.sh - - bazel test --config=ci --test_env=CI $(./scripts/bazel_export_options) --build_tests_only --test_tag_filters=-flaky,-flaky-mac,-post_wheel_build -- + - bazel test --config=ci --test_env=CI $(./scripts/bazel_export_options) --build_tests_only --test_tag_filters=-flaky,-flaky-mac -- //:all python/ray/serve/... python/ray/dashboard/... -rllib/... -core_worker_test - *epilogue_commands diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 70862d1f3..c0f6ccda2 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -182,9 +182,7 @@ - TORCH_VERSION=1.6 ./ci/travis/install-dependencies.sh - ./dashboard/tests/run_ui_tests.sh - bazel test --config=ci $(./scripts/bazel_export_options) python/ray/dashboard/... - - bazel test --config=ci $(./scripts/bazel_export_options) - --test_tag_filters=-post_wheel_build - python/ray/serve/... + - bazel test --config=ci $(./scripts/bazel_export_options) python/ray/serve/... - label: ":python: Minimal install" conditions: ["RAY_CI_PYTHON_AFFECTED"] diff --git a/doc/source/serve/core-apis.rst b/doc/source/serve/core-apis.rst index 8d420f348..e5130821c 100644 --- a/doc/source/serve/core-apis.rst +++ b/doc/source/serve/core-apis.rst @@ -238,31 +238,27 @@ Ray Serve supports serving deployments with different (possibly conflicting) Python dependencies. For example, you can simultaneously serve one deployment that uses legacy Tensorflow 1 and another that uses Tensorflow 2. -This is supported on Mac OS and Linux using Ray's :ref:`runtime-environments` feature. -As with all other Ray actor options, pass the runtime environment in via ``ray_actor_options`` in -your deployment. Be sure to first run ``pip install "ray[default]"`` to ensure the -Runtime Environments feature is installed. +Currently this is supported on Mac OS and Linux using `conda `_ +via Ray's built-in ``runtime_env`` option for actors. +As with all other actor options, pass these in via ``ray_actor_options`` in +your deployment. +You must have a conda environment set up for each set of +dependencies you want to isolate. If using a multi-node cluster, the +desired conda environment must be present on all nodes. Also, the Python patch version +(e.g. 3.8.10) must be identical on all nodes (this is a requirement for any Ray cluster). +See :ref:`runtime-environments` for details. -Example: +Here's an example script. For it to work, first create a conda +environment named ``ray-tf1`` with Ray Serve and Tensorflow 1 installed, +and another named ``ray-tf2`` with Ray Serve and Tensorflow 2. The Ray and +Python versions must be the same in both environments. .. literalinclude:: ../../../python/ray/serve/examples/doc/conda_env.py -.. note:: - When using a Ray library (for example, Ray Serve) in a runtime environment, it must - explicitly be included in the dependencies, as in the above example. This is not - required when just using Ray Core. - -.. tip:: - Avoid dynamically installing packages that install from source: these can be slow and - use up all resources while installing, leading to problems with the Ray cluster. Consider - precompiling such packages in a private repository or Docker image. - The dependencies required in the deployment may be different than the dependencies installed in the driver program (the one running Serve API calls). In this case, you should use a delayed import within the class to avoid -importing unavailable packages in the driver. This applies even when not -using runtime environments. - +importing unavailable packages in the driver. Example: .. literalinclude:: ../../../python/ray/serve/examples/doc/imported_backend.py diff --git a/python/ray/serve/BUILD b/python/ray/serve/BUILD index f04d2095d..cfab56772 100644 --- a/python/ray/serve/BUILD +++ b/python/ray/serve/BUILD @@ -338,11 +338,3 @@ py_test( tags = ["exclusive", "team:serve"], deps = [":serve_lib"] ) - -py_test( - name = "conda_env", - size = "medium", - srcs = glob(["examples/doc/*.py"]), - tags = ["exclusive", "post_wheel_build", "team:serve"], - deps = [":serve_lib"] -) diff --git a/python/ray/serve/backend_state.py b/python/ray/serve/backend_state.py index 40b2d0857..2ab4c5e41 100644 --- a/python/ray/serve/backend_state.py +++ b/python/ray/serve/backend_state.py @@ -1073,9 +1073,8 @@ class BackendState: f"Deployment '{self._name}' has " f"{len(slow_start_replicas)} replicas that have taken " f"more than {SLOW_STARTUP_WARNING_S}s to start up. This " - "may be caused by waiting for the cluster to auto-scale, " - "waiting for a runtime environment to install, or a slow " - "constructor. Resources required " + "may be caused by waiting for the cluster to auto-scale " + "or because the constructor is slow. Resources required " f"for each replica: {required}, resources available: " f"{available}. component=serve deployment={self._name}") diff --git a/python/ray/serve/examples/doc/conda_env.py b/python/ray/serve/examples/doc/conda_env.py index 1607cf7d6..c431964bb 100644 --- a/python/ray/serve/examples/doc/conda_env.py +++ b/python/ray/serve/examples/doc/conda_env.py @@ -1,28 +1,27 @@ import requests from ray import serve +import tensorflow as tf serve.start() @serve.deployment -def requests_version(request): - return requests.__version__ +def tf_version(request): + return ("Tensorflow " + tf.__version__) -requests_version.options( - name="25", - ray_actor_options={ +tf_version.options( + name="tf1", ray_actor_options={ "runtime_env": { - "pip": ["ray[serve]", "requests==2.25.1"] + "conda": "ray-tf1" } }).deploy() -requests_version.options( - name="26", - ray_actor_options={ +tf_version.options( + name="tf2", ray_actor_options={ "runtime_env": { - "pip": ["ray[serve]", "requests==2.26.0"] + "conda": "ray-tf2" } }).deploy() -assert requests.get("http://127.0.0.1:8000/25").text == "2.25.1" -assert requests.get("http://127.0.0.1:8000/26").text == "2.26.0" +print(requests.get("http://127.0.0.1:8000/tf1").text) # Tensorflow 1.15.0 +print(requests.get("http://127.0.0.1:8000/tf2").text) # Tensorflow 2.3.0