Skip to content

Feature nwp 2117 sample file creation#219

Merged
golharam merged 3 commits intofeature-NWP-2117-sample-files-responsefrom
feature-NWP-2117-sample-file-creation
Apr 9, 2026
Merged

Feature nwp 2117 sample file creation#219
golharam merged 3 commits intofeature-NWP-2117-sample-files-responsefrom
feature-NWP-2117-sample-file-creation

Conversation

@accumb3ns
Copy link
Copy Markdown
Contributor

When parsing a manifest, we want to be able to atomically create a sample record with its associated files. This PR extends the single- and bulk- sample creation endpoints to allow submission of file records at the same time.

Importantly - we don't want to create duplicate records if the sample/file association already exists (eg a new manifest containing existing sample records) so we compare hashes first if available.

vasques1 added 3 commits April 8, 2026 22:22
…on models

- Add SampleFileInput: lightweight file input for inline file creation
  during sample creation (uri, tags, hashes, role, source, etc.)
- Add optional 'files' field to SampleCreate for both single and bulk endpoints
- Add files_created and files_skipped counters to BulkSampleItemResponse
  and BulkSampleCreateResponse for file creation reporting
…into both sample creation endpoints

- _create_sample_files(): shared helper creating File, FileProject,
  FileSample, FileHash, FileTag records within the caller's transaction
- Hash-aware dedup: if URI already linked to sample and hashes match
  (or no hashes provided), skip; if hashes differ, create new version
- bulk_create_samples(): calls helper per sample, accumulates file counts
- add_sample_to_project(): calls helper when sample_in.files is present
- TestBulkSampleWithFiles: happy path, idempotent resubmission (no hashes
  and matching hashes), hash mismatch creating new version, mixed samples
  with/without files, backward compatibility
- TestSingleSampleWithFiles: single sample with files, file dedup,
  backward compatibility without files
@accumb3ns accumb3ns requested a review from golharam April 9, 2026 02:36
@golharam golharam merged commit b56459c into feature-NWP-2117-sample-files-response Apr 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants