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

Add FastAPI based serve functions #7205

Merged
merged 21 commits into from
Sep 2, 2024
Merged

Add FastAPI based serve functions #7205

merged 21 commits into from
Sep 2, 2024

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented Aug 29, 2024

Builds on top of bokeh-fastapi and adds two main user facing APIs:

  • panel.io.fastapi.serve: Mirrors the panel.serve API but launches a FastAPI backed uvicorn server (optionally on a separate thread).
  • panel.io.fastapi.add_applications: Adds Panel applications to an existing FastAPI application.
  • panel.io.fastapi.add_application: Decorator to add a function returning Panel objects to the FastAPI server.

@pmeier, thoughts and review appreciated. I'd like to get an initial cut of this in pretty soon but then we'll have about 1 - 1.5 weeks to add docs and more tests.

Copy link

codecov bot commented Aug 29, 2024

Codecov Report

Attention: Patch coverage is 78.06452% with 68 lines in your changes missing coverage. Please review.

Project coverage is 82.23%. Comparing base (647db1a) to head (121c109).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
panel/io/fastapi.py 63.15% 35 Missing ⚠️
panel/io/server.py 43.47% 13 Missing ⚠️
panel/io/application.py 83.07% 11 Missing ⚠️
panel/io/threads.py 85.71% 7 Missing ⚠️
panel/tests/test_server.py 96.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7205      +/-   ##
==========================================
- Coverage   82.24%   82.23%   -0.02%     
==========================================
  Files         331      337       +6     
  Lines       49420    50123     +703     
==========================================
+ Hits        40647    41217     +570     
- Misses       8773     8906     +133     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

panel/io/application.py Show resolved Hide resolved
panel/io/application.py Outdated Show resolved Hide resolved
panel/io/application.py Outdated Show resolved Hide resolved
panel/io/fastapi.py Outdated Show resolved Hide resolved
panel/io/fastapi.py Outdated Show resolved Hide resolved
panel/io/server.py Outdated Show resolved Hide resolved
panel/io/server.py Outdated Show resolved Hide resolved
panel/io/server.py Show resolved Hide resolved
panel/io/application.py Show resolved Hide resolved
panel/io/application.py Outdated Show resolved Hide resolved
panel/io/fastapi.py Outdated Show resolved Hide resolved
philippjfr and others added 2 commits August 30, 2024 09:58
Co-authored-by: Simon Høxbro Hansen <[email protected]>
Co-authored-by: Andrew <[email protected]>
panel/io/fastapi.py Outdated Show resolved Hide resolved
panel/io/fastapi.py Outdated Show resolved Hide resolved
philippjfr and others added 2 commits August 30, 2024 11:56
Co-authored-by: Philip Meier <[email protected]>
Co-authored-by: Philip Meier <[email protected]>
@MarcSkovMadsen
Copy link
Collaborator

If this make it very easy to add FAST API (REST) endpoints in general it would be of great value.

panel/tests/conftest.py Outdated Show resolved Hide resolved
panel/io/threads.py Outdated Show resolved Hide resolved
panel/io/fastapi.py Outdated Show resolved Hide resolved
panel/tests/test_server.py Outdated Show resolved Hide resolved
@philippjfr philippjfr merged commit 340ced3 into main Sep 2, 2024
16 checks passed
@philippjfr philippjfr deleted the fastapi_serve branch September 2, 2024 20:46
@philippjfr
Copy link
Member Author

This pull request has been mentioned on HoloViz Discourse. There might be relevant details there:

https://discourse.holoviz.org/t/how-to-integrate-a-panel-app-with-fastapi-on-the-same-port/7601/6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants