Skip to content

feature: enable passing custom default response class #440

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AleksanderWWW
Copy link

@AleksanderWWW AleksanderWWW commented Feb 27, 2025

What does this PR do?

Fixes #436 .

Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

requirements.txt Outdated
@@ -1,3 +1,4 @@
fastapi >=0.100
uvicorn[standard] >=0.29.0
pyzmq >=22.0.0
orjson==3.10.15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep this dependency optional

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, right now I'm adding it to the test and perf requirements in the _requirements directory. Is there a better place for it?

@@ -414,7 +414,7 @@ async def health(request: Request) -> Response:

@self.app.get(self.info_path, dependencies=[Depends(self.setup_auth())])
async def info(request: Request) -> Response:
return JSONResponse(
return ORJSONResponse(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a performance critical section. I would suggest applying this to the predict method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! In the latest commit I'm hard-coding the ORJSONResponse class while registering the /predict endpoint, but it's only temporary for the sake of the benchmarks. In the target scenario this would be user's choice

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89%. Comparing base (90d7d10) to head (aef0017).
Report is 3 commits behind head on main.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #440   +/-   ##
===================================
- Coverage    89%    89%   -0%     
===================================
  Files        31     31           
  Lines      2041   2028   -13     
===================================
- Hits       1824   1805   -19     
- Misses      217    223    +6     
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AleksanderWWW
Copy link
Author

@aniketmaurya do I interpret correctly that the failing job means that it's not worth it to include the ORJSONResponse class in the project?

@@ -1,3 +1,4 @@
uvloop
tenacity
jsonargparse
orjson==3.10.15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requirements.txt contains the main dependency. These are optional.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You asked to make this dependency optional in one of the comments

@@ -15,3 +15,4 @@ openai>=1.12.0
pillow
numpy <2.0
pytest-retry>=1.6.3
orjson==3.10.15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

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.

Allow to pass default_response_class e.g. ORJSONResponse to LitServe server
2 participants