Skip to content

feat: Replace ORJSONResponse with Pydantic response models for faster JSON serialization#6142

Merged
ntkathole merged 1 commit intofeast-dev:masterfrom
ntkathole:fix_orjson
Mar 23, 2026
Merged

feat: Replace ORJSONResponse with Pydantic response models for faster JSON serialization#6142
ntkathole merged 1 commit intofeast-dev:masterfrom
ntkathole:fix_orjson

Conversation

@ntkathole
Copy link
Copy Markdown
Member

@ntkathole ntkathole commented Mar 23, 2026

What this PR does / why we need it:

  • Replace ORJSONResponse with Pydantic response_model on /get-online-features and /retrieve-online-documents endpoints, leveraging FastAPI's native Rust-based JSON serialization via Pydantic V2 for optimal performance
  • Remove orjson as a direct dependency from pyproject.toml (and regenerated lock files)
  • Fix Pixi deprecation warning by replacing [project] with [workspace] in infra/scripts/pixi/pixi.toml

FastAPI docs recommend using Pydantic response_model over custom response classes like ORJSONResponse for JSON serialization performance:

With response_model, FastAPI serializes directly to JSON bytes via Pydantic's Rust-based serializer skipping the jsonable_encoder intermediate step that ORJSONResponse still required. Pydantic V2 uses the same underlying Rust mechanisms as orjson, so this is at least as fast while also providing automatic response validation and OpenAPI schema documentation.

Which issue(s) this PR fixes:

Fixes #6139


Open with Devin

@ntkathole ntkathole self-assigned this Mar 23, 2026
@ntkathole ntkathole requested a review from a team as a code owner March 23, 2026 11:13
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Member

@franciscojavierarceo franciscojavierarceo left a comment

Choose a reason for hiding this comment

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

nice

… JSON serialization

Signed-off-by: ntkathole <nikhilkathole2683@gmail.com>
@ntkathole ntkathole merged commit 65cf03c into feast-dev:master Mar 23, 2026
31 checks passed
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.

ORJSONResponse is deprecated

2 participants