-
Notifications
You must be signed in to change notification settings - Fork 3
Add GET API routes for run/sample/annotation lookup #67
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
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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_dicthelper 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.
| with api_registry() as registry: | ||
| annotations = registry.get_annotations(sample_accession) |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
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.
| with api_registry() as registry: | ||
| run = registry.get_run(run_accession) |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
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.
| with api_registry() as registry: | ||
| run_accessions = registry.get_runs_by_data_uri(substring) |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
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.
| with api_registry() as registry: | ||
| samples = registry.get_samples(run_accession) |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
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.
Motivation
Description
api_model_to_dicthelper to serialize SQLAlchemy model instances to dictionaries for JSON responses.SampleRegistrylookup methods with input validation:GET /api/get_run(queryrun_accession),GET /api/get_runs_by_data_uri(querysubstring),GET /api/get_samples(queryrun_accession), andGET /api/get_annotations(querysample_accession).README.mdto document GET vs POST behavior, include the new GET routes in the endpoint list, and addcurl -Gexamples for read operations.tests/test_api.pywith tests that verify each new GET endpoint returns the expected JSON payload against the seeded test database.Testing
pytest -q tests/test_api.pywhich initially failed due to a missing runtime dependency (flask_sqlalchemy).python -m pip install -e .andpython -m pip install flask flask_sqlalchemyto prepare the test environment.pytest -q tests/test_api.pyand all tests passed:12 passed in 1.56s.Codex Task