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] proxy failed to start as starlette removed options attribute from starlette.middleware.Middleware #42370

Closed
ahmed-mahran opened this issue Jan 12, 2024 · 7 comments
Assignees
Labels
bug Something that is supposed to be working; but isn't P0 Issues that should be fixed in short order serve Ray Serve Related Issue v2.9.2-pick

Comments

@ahmed-mahran
Copy link
Contributor

What happened + What you expected to happen

Proxy failed to start with error

File "ray/serve/_private/proxy.py", line 1202, in __init__
self.wrapped_http_proxy, **middleware.options
AttributeError: 'Middleware' object has no attribute 'options'

Starelette has removed this attribute after version 0.34.0
https://github.com/encode/starlette/pull/2381/files#diff-861f6098c0edc67d2e328a0c76c86acf1cd1f4d86fc398a6838d18d69c2bdeaeL7

pip install "starlette<=0.34.0" has fixed it for me. requirements file may be updated accordingly https://github.com/ray-project/ray/blob/master/python/requirements.txt#L56

Versions / Dependencies

Ray version 2.9.0

Reproduction script

Run any serve app

Issue Severity

None

@ahmed-mahran ahmed-mahran added bug Something that is supposed to be working; but isn't triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Jan 12, 2024
@jingzhaoou
Copy link

jingzhaoou commented Jan 13, 2024

I just ran into the same error, which burned me an hour. Thanks so much for sharing it!

I resolved the issue by installing Starelette first. Below is my requirements.txt file:

starlette<=0.34.0
ray[serve,data]==2.9.0

@ratnopamc
Copy link
Contributor

Thanks much for sharing, saved a ton of time.

@GeneDer GeneDer added P1 Issue that should be fixed within a few weeks and removed triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Jan 16, 2024
@wpm
Copy link

wpm commented Jan 16, 2024

Unfortunately starlette 0.34.0 is incompatible with the latest fastapi.

pip install "ray[serve]"
pip install "starlette<=0.34.0"
...
Installing collected packages: starlette
  Attempting uninstall: starlette
    Found existing installation: starlette 0.35.1
    Uninstalling starlette-0.35.1:
      Successfully uninstalled starlette-0.35.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
fastapi 0.109.0 requires starlette<0.36.0,>=0.35.0, but you have starlette 0.34.0 which is incompatible.
Successfully installed starlette-0.34.0

I'm not sure if this affects Ray's functionality. I am able to successfully run the sample client/server application from Running a Ray Serve Application in this configuration.

@chenweisomebody126
Copy link

chenweisomebody126 commented Jan 17, 2024

You can degrade your fastapi to a low version such as pip install fastapi==0.104.1 which uses a version of starlette <= 0.34.0

@edoakes edoakes added P0 Issues that should be fixed in short order serve Ray Serve Related Issue v2.9.2-pick and removed P1 Issue that should be fixed within a few weeks labels Jan 24, 2024
@architkulkarni
Copy link
Contributor

@sihanwang41 is this issue closed now?

@wolvever
Copy link

Can ray plan a upgrade. This issue troubles anyone using newer version of FastAPI.

@edoakes
Copy link
Contributor

edoakes commented Mar 12, 2024

#42747

@edoakes edoakes closed this as completed Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to be working; but isn't P0 Issues that should be fixed in short order serve Ray Serve Related Issue v2.9.2-pick
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants