Conversation
added 3 commits
April 8, 2026 11:47
- Add optional run_barcode field to SampleCreate and SamplePublic models
- Enrich POST /projects/{pid}/samples to create SampleSequencingRun when
run_barcode is provided, eliminating the separate association call
- Build explicit SamplePublic in route to echo run_barcode in response
- Add robust error handling for malformed barcodes in add_sample_to_project
- Add BulkSampleCreateRequest/Response models and bulk route endpoint
…and tests - Add bulk_create_samples() in api/samples/services.py with: - Pre-validation: duplicate sample_ids, invalid barcodes, duplicate attr keys - Single-transaction creation loop with idempotent semantics - Resolve-or-create samples + optional SampleSequencingRun associations - Post-commit best-effort OpenSearch indexing - Robust error handling for malformed barcodes - Add comprehensive test suite (22 tests) in tests/api/test_bulk_samples.py: - Single-sample run_barcode: happy path, backward compat, invalid barcode - Bulk: basic, with run, attributes, mixed, idempotency, re-demux - Validation: empty list, duplicates, bad barcode, extra fields, nonexistent project
Wrap the post-commit add_object_to_index call in add_sample_to_project() with try/except, matching the bulk endpoint's behaviour. Since the DB is the source of truth and /reindex can resync, an OpenSearch outage should not cause a 500 after a successful database commit.
Add sections to SAMPLE_RUN_ASSOCIATIONS.md covering:
- POST /projects/{pid}/samples with optional run_barcode enrichment
- POST /projects/{pid}/samples/bulk with atomic batch semantics,
idempotency, and pre-validation error table
- Updated source files table with new service/test files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this PR adds the ability to associate a sample with a sequencing run at creation time, rather than requiring a second API call to do so. also - because we want a samplesheet to atomically succeed or fail, we add a bulk endpoint that validates and creates all records in a single transaction, reducing calls from 2N for N samples to 1; this is generalized and can be used for posting manifests also. tests are added for the bulk endpoint.
there is one minor bugfix - previously, for a single sample submission, if there was an error with opensearch indexing, the server could return a 500 despite having already added the sample to the database first. We now pass on exception since the relational db is the source of truth and opensearch can just be reindexed, ensuring the client correctly receives 201 Created.