Skip to content

Conversation

@Ulthran
Copy link
Contributor

@Ulthran Ulthran commented Jan 30, 2026

Motivation

  • Expose existing CLI workflows as HTTP endpoints so remote services can register and modify runs/samples via the web service.
  • Allow the web UI to remain read-only while using a writable database connection for API write operations.
  • Support uploading or embedding sample tables in API requests and reuse existing sample-table parsing/validation logic.
  • Provide consistent validation for sample accessions used by both CLI and API flows.

Description

  • Added helper utilities in sample_registry/app.py: api_registry() context manager to create a writable SampleRegistry from SQLALCHEMY_WRITE_URI, api_request_data(), api_error(), and api_sample_table_from_request() to parse/validate SampleTable payloads.
  • Implemented JSON/HTTP endpoints for CLI actions in sample_registry/app.py: POST /api/register_run, POST /api/register_illumina_file, POST /api/register_samples, POST /api/register_annotations, POST /api/unregister_samples, POST /api/modify_run, POST /api/modify_sample, and POST /api/modify_annotation, each using the writable registry and returning JSON success/error responses.
  • Preserved the web UI connection as read-only by setting SQLALCHEMY_DATABASE_URI with ?mode=ro while storing the original URI in SQLALCHEMY_WRITE_URI for API writes.
  • Added check_sample_accession to sample_registry/registrar.py to validate sample existence (used by several new API routes), and imported SampleTable, SampleRegistry, and IlluminaFastq where needed.

Testing

  • No automated tests were executed against these changes in this rollout.

Codex Task

Copilot AI review requested due to automatic review settings January 30, 2026 23:05
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 75.63452% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.42%. Comparing base (3a24f82) to head (47bf7a4).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
sample_registry/app.py 74.86% 47 Missing ⚠️
sample_registry/registrar.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #65      +/-   ##
==========================================
+ Coverage   63.83%   70.42%   +6.59%     
==========================================
  Files           9        9              
  Lines         719      886     +167     
==========================================
+ Hits          459      624     +165     
- Misses        260      262       +2     

☔ 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

Adds a JSON/HTTP API layer to expose existing registry CLI workflows via Flask routes, while keeping the existing web UI database access read-only and performing API writes through a separate writable registry session.

Changes:

  • Added helper utilities in sample_registry/app.py for API request parsing, error responses, and sample table ingestion/validation.
  • Implemented multiple POST /api/* endpoints that wrap SampleRegistry write operations and return JSON responses.
  • Added check_sample_accession() validation helper in SampleRegistry for sample-based API operations.

Reviewed changes

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

File Description
sample_registry/app.py Adds API utilities, sets up writable registry context, and implements new /api/* write endpoints while keeping the UI DB connection read-only.
sample_registry/registrar.py Adds check_sample_accession() to validate sample existence for modify flows.

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

@Ulthran Ulthran merged commit 8b2b7da into master Jan 31, 2026
9 checks passed
@Ulthran Ulthran deleted the codex/add-flask-api-routes-for-cli-commands-7266t1 branch January 31, 2026 16:07
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.

2 participants