Skip to content

feature: enable passing custom default response class#440

Closed
AleksanderWWW wants to merge 3 commits intoLightning-AI:mainfrom
AleksanderWWW:main
Closed

feature: enable passing custom default response class#440
AleksanderWWW wants to merge 3 commits intoLightning-AI:mainfrom
AleksanderWWW:main

Conversation

@AleksanderWWW
Copy link
Copy Markdown

@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
fastapi >=0.100
uvicorn[standard] >=0.29.0
pyzmq >=22.0.0
orjson==3.10.15
Copy link
Copy Markdown
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
Copy Markdown
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?

@self.app.get(self.info_path, dependencies=[Depends(self.setup_auth())])
async def info(request: Request) -> Response:
return JSONResponse(
return ORJSONResponse(
Copy link
Copy Markdown
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
Copy Markdown
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

@codecov
Copy link
Copy Markdown

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
Copy Markdown
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?

uvloop
tenacity
jsonargparse
orjson==3.10.15
Copy link
Copy Markdown
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
Copy Markdown
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

pillow
numpy <2.0
pytest-retry>=1.6.3
orjson==3.10.15
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same as above

@stale
Copy link
Copy Markdown

stale bot commented Jul 19, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the won't fix label Jul 19, 2025
@aniketmaurya
Copy link
Copy Markdown
Collaborator

Closing since inactive for a long time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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