Skip to content

Commit

Permalink
[serve] Unpin fastapi version (#43058)
Browse files Browse the repository at this point in the history
FastAPI has fixed the broken starlette interaction in 0.109.2: https://fastapi.tiangolo.com/release-notes/#01092

Starlette handling of root_path has changed in 0.33.0: encode/starlette#2352. Prior to this, it was incorrectly stripping the root_path from the path field (which we need to mirror). Added compatibility logic to handle both of these.

---------

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Lonnie Liu <95255098+aslonnie@users.noreply.github.com>
  • Loading branch information
edoakes and aslonnie committed Feb 12, 2024
1 parent b9de36d commit ca88ce7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
6 changes: 5 additions & 1 deletion python/ray/serve/_private/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,12 @@ def _get_response_handler_info(
route_path = proxy_request.route_path
if route_prefix != "/" and self.protocol == RequestProtocol.HTTP:
assert not route_prefix.endswith("/")
proxy_request.set_path(route_path.replace(route_prefix, "", 1))
proxy_request.set_root_path(proxy_request.root_path + route_prefix)
# NOTE(edoakes): starlette<0.33.0 expected the ASGI 'root_prefix'
# to be stripped from the 'path', which wasn't technically following
# the standard. See https://github.com/encode/starlette/pull/2352.
if version.parse(starlette.__version__) < version.parse("0.33.0"):
proxy_request.set_path(route_path.replace(route_prefix, "", 1))

handle, request_id = self.setup_request_context_and_handle(
app_name=handle.deployment_id.app,
Expand Down
2 changes: 1 addition & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ colorful
pyyaml
rich
opentelemetry-sdk
fastapi<=0.108.0
fastapi
gymnasium==0.28.1
virtualenv!=20.21.1,>=20.0.24
opentelemetry-api
Expand Down
3 changes: 1 addition & 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.108.0
fastapi==0.109.2
feather-format==0.4.1
# Keep compatible with Werkzeug
flask==2.1.3
Expand Down Expand Up @@ -93,7 +93,6 @@ 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.29.0
h11==0.12.0
markdown-it-py==1.1.0
attrs==21.4.0
Expand Down
6 changes: 3 additions & 3 deletions python/requirements_compiled.txt
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,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.108.0
fastapi==0.109.2
# via
# -r /ray/ci/../python/requirements.txt
# -r /ray/ci/../python/requirements/test-requirements.txt
Expand Down Expand Up @@ -2097,7 +2097,7 @@ sshpubkeys==3.3.1
# via moto
stack-data==0.6.3
# via ipython
starlette==0.29.0
starlette==0.36.3
# via
# -r /ray/ci/../python/requirements.txt
# -r /ray/ci/../python/requirements/test-requirements.txt
Expand Down Expand Up @@ -2499,4 +2499,4 @@ zoopt==0.4.1

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
# setuptools
3 changes: 1 addition & 2 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ def get_packages(self):
"uvicorn[standard]",
"requests",
"starlette",
# Tracking issue: https://github.com/tiangolo/fastapi/discussions/10948
"fastapi <= 0.108.0",
"fastapi",
"watchfiles",
],
"tune": ["pandas", "tensorboardX>=1.9", "requests", pyarrow_dep, "fsspec"],
Expand Down

0 comments on commit ca88ce7

Please sign in to comment.