ukaea / ukaea/fds

Allow passing member dataset ids when creating a Collection

Open
#49 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
0
Forks
1
Avg merge
26m
Merged PRs (30d)
24

Description

Summary

Let a Collection be created and populated in a single request by accepting an optional list of member dataset ids on create. Today, membership is add-one-at-a-time only, so creating a populated collection takes 1 + N requests.

Background

  • CollectionCreate (app/models/collection.py) has no way to include datasets — its fields are name / device_name / access_level / root_url / activity_id / shot_id / origin / required_scopes / allowed_idps.
  • The only way to add members is the per-dataset endpoint POST /collections/{collection_id}/datasets/{dataset_id} (bodyless; CollectionService.add_dataset takes a single dataset_id). There is no bulk path.
  • So clients (and the docs example) must create the collection, then loop the single-POST call once per dataset.

Change

  • app/models/collection.py — add to CollectionCreate: dataset_ids: list[int] | None = None.
  • CollectionService create path — after creating the collection, add each id in dataset_ids as a member, reusing the existing add_dataset validation (dataset exists, access authorised, dedupe). Recommend all-or-nothing semantics: if any id is missing/inaccessible, reject the whole request so you never get a half-populated collection. (Document whichever semantics are chosen.)
  • Keep the existing single-POST membership endpoint for incremental add/remove after creation.
  • Optional / decide if in scope: a companion bulk-add-to-existing endpoint (POST /collections/{id}/datasets with a list body) so the same convenience exists for already-created collections. The user's request was specifically about the create request, so this can be split out.

Docs & demo

  • Update the Collection example to pass dataset_ids in the create call (replacing the per-dataset loop). File is docs/data-model/collection.md on the docs/examples-in-concepts branch, or docs/concepts/data-model.md on main — edit whichever exists.
  • Optionally switch demo/seed_metadata.py collection creation to the one-call form.

Acceptance criteria

  • POST /collections with {"name": ..., "dataset_ids": [1, 2, 3]} creates the collection and adds those datasets as members in one call.
  • An invalid or inaccessible dataset id is rejected per chosen semantics (recommended: whole request fails, no partial collection).
  • Each dataset add still respects the caller's authorization (reuse add_dataset checks).
  • Existing single-POST membership endpoint unchanged.
  • Collection docs example updated to the one-call form.
  • uv run --all-extras pytest green; prek run --all-files clean.

Notes

  • Branch off main. Standalone change.

Migrated from the internal tracker, where it was #26, opened 2026-07-24.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with app/models/collection.py and trace the CollectionService create path and existing add_dataset validation. Check the current collection documentation at the branch-specific path named in the issue, then implement the specified create behavior while preserving the single-dataset endpoint. Done means the acceptance criteria pass, including authorization and failure semantics, with uv run --all-extras pytest green and prek run --all-files clean.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.