feat(samples): support project, organism and pubmed on sample imports - #20
Conversation
The sample-import backend now accepts a project (alongside the already-supported organism), so surface it through both the library and the CLI. SampleImportSpec gains an optional project_id, sent on the wire as `project` and omitted when empty — mirroring how organism_id is handled. The CLI accession sheet gains a matching optional `project` column, forwarded per row. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@claude please review this PR |
|
Claude finished @mhusbynflow's task in 3m 19s —— View job Review:
|
The sample-import endpoint accepts a per-accession pubmed id (a bare PubMed number) alongside organism and project, so surface it through the library and the CLI too. SampleImportSpec gains an optional pubmed field, sent on the wire unchanged and omitted when empty. The CLI accession sheet gains a matching optional pubmed column, forwarded per row. Format is validated server-side, like the other fields. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@claude please re-review — added pubmed support to the sample-import flow (SampleImportSpec + accession sheet), mirroring project/organism. |
|
Claude finished @mhusbynflow's task in 2m 11s —— View job Re-review:
|
The end-to-end `samples import --sheet` test is the only one that drives the accession sheet through the CLI to a mocked request, so it's what catches a column being reserved in the parser but dropped before the request (or leaking into metadata). It didn't exercise the new project or pubmed columns. Add both to IMPORT_HEADERS, assert they reach the payload, and add a case proving blank cells are omitted from it. Also bring the _import_command docstring's server-validated field list in line with the module docstring. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@claude please re-review — addressed the blocking CLI-seam test gap (project + pubmed now covered end-to-end through |
|
Claude finished @mhusbynflow's task in 1m 45s —— View job Re-review: CLI-seam coverage (commit
|
Adding project and pubmed to the server-validated field list pushed the sentence boundary and left one line ragged against its neighbours. Re-wrap only; no wording change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…edId Two review-driven refinements to the sample-import payload: Invert the payload filter from an optional-field denylist to a required-field allowlist. `optional` had to grow in lockstep with every new field, and the docstring had to warn about the failure mode. Listing the two always-sent fields instead makes omit-when-empty the default, so a field added to SampleImportSpec is dropped-when-empty for free. Semantics are unchanged (required and optional together covered every field). Add a PubMedId named type (str, documented as a bare integer, validated server-side) alongside SampleTypeId, and apply it to SampleImportSpec.pubmed and the accession-sheet row — matching how SampleTypeId is already wrapped where the value is created. Exported from flowbio.v2. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The import section's "validated server-side" sentence listed only accession, sample type, and metadata — now that organism, project, and pubmed all go through the same server-side validation, name them too, in step with the module and command docstrings. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What changed
The v2 sample-import endpoint (
POST /v2/sample-imports) accepts per-accessionorganism,project, andpubmed.organismwas already wired up; this PR addsprojectandpubmedthrough both the library and the CLI.Verified against the backend (
flow-apisamples/schemas.py::SampleImportRequest): it acceptsorganism: OrganismId | None,project: ProjectId | None, andpubmed: PubMedId | None(a bare, digits-only PubMed number). All three are validated server-side.SampleImportSpecgainsproject_id(sent on the wire asproject) andpubmed(sent unchanged). Both are optional and omitted from the payload when empty, mirroring howorganism_idis handled.project_idis typedstrto match the rest of the client (Project.id,upload_sample); a numeric-string id coerces to the backend's integerProjectIdserver-side.projectandpubmedcolumns, parsed per row and forwarded viato_spec.--sheethelp, module docstrings, andsource/cli.rst(incl. the worked example) updated.0.10.0→0.11.0.Verification
samples import --sheetseam throughrun_cli(both fields reach the request; blank cells are omitted).Backwards-compatibility note (for release notes)
projectandpubmedare now reserved accession-sheet columns. An existing sheet with a metadata column literally namedprojectorpubmedwill have that value reinterpreted as the project/publication assignment instead of forwarded as metadata. Unlikely in practice, but worth calling out.Deferred to follow-ups
pubmedonupload_sample/ the reads sheet (imports and uploads are different endpoints; upload's GraphQL mutation does accept$pubmed).ProjectId/PubMedIdNewTypetyping sweep (touches pre-existing bare-strproject ids well outside this PR).🤖 Generated with Claude Code