Skip to content
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

[Serve] Pin the fastapi & starlette version to avoid breaking proxy #42740

Merged
merged 6 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/docker/min.build.wanda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ build_args:
- PYTHON_VERSION
- EXTRA_DEPENDENCY
tags:
- cr.ray.io/rayproject/minbuild-$EXTRA_DEPENDENCY-py$PYTHON_VERSION
- cr.ray.io/rayproject/minbuild-$EXTRA_DEPENDENCY-py$PYTHON_VERSION
17 changes: 14 additions & 3 deletions python/ray/serve/_private/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Type

import grpc
import starlette
import starlette.routing
import uvicorn
from packaging import version
from starlette.datastructures import MutableHeaders
from starlette.middleware import Middleware
from starlette.types import Receive
Expand Down Expand Up @@ -1211,9 +1213,18 @@ def __init__(
self.wrapped_http_proxy = self.http_proxy

for middleware in http_middlewares:
self.wrapped_http_proxy = middleware.cls(
self.wrapped_http_proxy, **middleware.options
)
if version.parse(starlette.__version__) < version.parse("0.35.0"):
self.wrapped_http_proxy = middleware.cls(
self.wrapped_http_proxy, **middleware.options
)
else:
# In starlette >= 0.35.0, middleware.options does not exist:
# https://github.com/encode/starlette/pull/2381.
self.wrapped_http_proxy = middleware.cls(
self.wrapped_http_proxy,
*middleware.args,
**middleware.kwargs,
)

# Start running the HTTP server on the event loop.
# This task should be running forever. We track it in case of failure.
Expand Down
2 changes: 1 addition & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pyyaml
rich
gpustat>=1.0.0
opentelemetry-sdk
fastapi
fastapi<=0.108.0
gymnasium==0.28.1
virtualenv!=20.21.1,>=20.0.24
opentelemetry-api
Expand Down
4 changes: 2 additions & 2 deletions python/requirements/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cloudpickle==2.2.0
# Keep in sync with `ci/build/upload_build_info.sh`
cryptography==38.0.1
cython==0.29.32
fastapi==0.104.0
fastapi==0.108.0
feather-format==0.4.1
# Keep compatible with Werkzeug
flask==2.1.3
Expand Down Expand Up @@ -93,7 +93,7 @@ importlib-metadata==4.10.0
# Some packages have downstream dependencies that we have to specify here to resolve conflicts.
# Feel free to add (or remove!) packages here liberally.
tensorboardX==2.6.0
starlette==0.27.0
starlette==0.29.0
h11==0.12.0
markdown-it-py==1.1.0
attrs==21.4.0
Expand Down
4 changes: 2 additions & 2 deletions python/requirements_compiled.txt
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ fairscale==0.4.6
# via -r /ray/ci/../python/requirements/ml/tune-test-requirements.txt
farama-notifications==0.0.4
# via gymnasium
fastapi==0.104.0
fastapi==0.108.0
# via
# -r /ray/ci/../python/requirements.txt
# -r /ray/ci/../python/requirements/test-requirements.txt
Expand Down Expand Up @@ -2175,7 +2175,7 @@ sshpubkeys==3.3.1
# via moto
stack-data==0.6.3
# via ipython
starlette==0.27.0
starlette==0.29.0
# via
# -r /ray/ci/../python/requirements.txt
# -r /ray/ci/../python/requirements/test-requirements.txt
Expand Down
3 changes: 2 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ def get_packages(self):
"uvicorn[standard]",
"requests",
"starlette",
"fastapi",
# Tracking issue: https://github.com/tiangolo/fastapi/discussions/10948
"fastapi <= 0.108.0",
"aiorwlock",
"watchfiles",
],
Expand Down
Loading