Skip to content

Conversation

@Ulthran
Copy link
Contributor

@Ulthran Ulthran commented Feb 5, 2026

Motivation

  • Expose existing registrar lookup methods via read-only HTTP endpoints so external clients can query runs, samples, and annotations.
  • Provide simple JSON serialization for SQLAlchemy models to return record data from the API.
  • Make the API behavior clear in the documentation with examples for read operations.

Description

  • Added api_model_to_dict helper to serialize SQLAlchemy model instances to dictionaries for JSON responses.
  • Implemented four GET endpoints that call SampleRegistry lookup methods with input validation: GET /api/get_run (query run_accession), GET /api/get_runs_by_data_uri (query substring), GET /api/get_samples (query run_accession), and GET /api/get_annotations (query sample_accession).
  • Updated README.md to document GET vs POST behavior, include the new GET routes in the endpoint list, and add curl -G examples for read operations.
  • Extended tests/test_api.py with tests that verify each new GET endpoint returns the expected JSON payload against the seeded test database.

Testing

  • Attempted pytest -q tests/test_api.py which initially failed due to a missing runtime dependency (flask_sqlalchemy).
  • Installed the package and dependencies with python -m pip install -e . and python -m pip install flask flask_sqlalchemy to prepare the test environment.
  • Re-ran pytest -q tests/test_api.py and all tests passed: 12 passed in 1.56s.

Codex Task

Copilot AI review requested due to automatic review settings February 5, 2026 16:30
@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 78.26087% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.03%. Comparing base (b38a2b3) to head (4753af4).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
sample_registry/app.py 78.26% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
+ Coverage   70.42%   71.03%   +0.60%     
==========================================
  Files           9        9              
  Lines         886      932      +46     
==========================================
+ Hits          624      662      +38     
- Misses        262      270       +8     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds four new GET API endpoints to expose existing SampleRegistry lookup methods via read-only HTTP interfaces. The changes enable external clients to query runs, samples, and annotations through simple JSON APIs.

Changes:

  • Added a api_model_to_dict helper function to serialize SQLAlchemy model instances to dictionaries for JSON responses
  • Implemented four GET endpoints (/api/get_run, /api/get_runs_by_data_uri, /api/get_samples, /api/get_annotations) with input validation
  • Updated README.md to document the new GET endpoints and provide curl examples
  • Added tests for each new GET endpoint verifying successful responses

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
sample_registry/app.py Added api_model_to_dict serialization helper and four new GET endpoints for querying runs, samples, and annotations
tests/test_api.py Added happy-path tests for each new GET endpoint
README.md Updated API documentation to distinguish GET vs POST endpoints and added curl examples for the new read operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +651 to +652
with api_registry() as registry:
annotations = registry.get_annotations(sample_accession)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The new GET endpoints lack error handling for exceptions that may be raised by the registry methods. The existing POST endpoints wrap registry calls in try-except blocks and call registry.session.rollback() on exceptions. While GET endpoints typically don't modify data, exceptions from the registry methods (e.g., database connection issues) should still be handled to provide consistent error responses rather than returning 500 Internal Server Error.

Copilot uses AI. Check for mistakes.
Comment on lines +597 to +598
with api_registry() as registry:
run = registry.get_run(run_accession)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The new GET endpoints lack error handling for exceptions that may be raised by the registry methods. The existing POST endpoints wrap registry calls in try-except blocks and call registry.session.rollback() on exceptions. While GET endpoints typically don't modify data, exceptions from the registry methods (e.g., database connection issues) should still be handled to provide consistent error responses rather than returning 500 Internal Server Error.

Copilot uses AI. Check for mistakes.
Comment on lines +614 to +615
with api_registry() as registry:
run_accessions = registry.get_runs_by_data_uri(substring)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The new GET endpoints lack error handling for exceptions that may be raised by the registry methods. The existing POST endpoints wrap registry calls in try-except blocks and call registry.session.rollback() on exceptions. While GET endpoints typically don't modify data, exceptions from the registry methods (e.g., database connection issues) should still be handled to provide consistent error responses rather than returning 500 Internal Server Error.

Copilot uses AI. Check for mistakes.
Comment on lines +630 to +631
with api_registry() as registry:
samples = registry.get_samples(run_accession)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The new GET endpoints lack error handling for exceptions that may be raised by the registry methods. The existing POST endpoints wrap registry calls in try-except blocks and call registry.session.rollback() on exceptions. While GET endpoints typically don't modify data, exceptions from the registry methods (e.g., database connection issues) should still be handled to provide consistent error responses rather than returning 500 Internal Server Error.

Copilot uses AI. Check for mistakes.
@Ulthran Ulthran merged commit e69e408 into master Feb 5, 2026
14 of 15 checks passed
@Ulthran Ulthran deleted the codex/add-get-routes-to-api branch February 5, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant