Skip to content

Conversation

@bencap
Copy link
Collaborator

@bencap bencap commented Nov 10, 2025

This pull request refactors the endpoints in score_sets.py that return annotated variant data for a score set. Instead of returning the entire result as a single JSON object, these endpoints now stream results as newline-delimited JSON (NDJSON), improving performance and scalability for large datasets. The implementation introduces a reusable streaming generator and updates endpoint documentation, response headers, and eager loading of related data.

Streaming and API Response Refactor:

  • Introduced _stream_generated_annotations, a generator function that streams annotation results as NDJSON, including progress logging and summary information. This function is now used by all three annotation endpoints. (F51675eeR479)
  • Updated the three annotation endpoints (/annotated-variants/pathogenicity-evidence-line, /functional-impact-statement, /functional-study-result) to return a StreamingResponse with NDJSON instead of a single JSON object, and added appropriate response headers for metadata and CORS. (F51675eeR568, F51675eeR681, F51675eeR792, F51675eeR874)

Query and Performance Improvements:

  • Refactored database queries for mapped variants in all three endpoints to use .join and .options with contains_eager and selectinload for more efficient eager loading of related data (e.g., publications, users, licenses, experiments). (F51675eeR624, F51675eeR735, F51675eeR850)

Documentation and Typing:

  • Expanded endpoint docstrings to clearly describe the new streaming NDJSON response format, headers, and error handling. (F51675eeR489, F51675eeR603)
  • Added TypedDict response types for each annotation stream to clarify response structure. (F51675eeR479, F51675eeR648, F51675eeR759)

Code Clean-up and Import Sorting:

  • Improved import organization and sorted imports for clarity and consistency. [1] [2] [3] [4]
  • Minor update to test utility imports for consistency.

…genicity evidence and functional impact statements
@bencap bencap merged commit 7b4a20c into release-2025.5.0 Nov 11, 2025
6 checks passed
@bencap bencap deleted the feature/bencap/560/optimize-va-spec-download branch November 11, 2025 18:57
@bencap bencap mentioned this pull request Nov 13, 2025
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.

Optimize VA-Spec Object Creation

2 participants