Allow passing member dataset ids when creating a Collection
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 arename / 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_datasettakes a singledataset_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 toCollectionCreate:dataset_ids: list[int] | None = None.CollectionServicecreate path — after creating the collection, add each id indataset_idsas a member, reusing the existingadd_datasetvalidation (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}/datasetswith 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_idsin the create call (replacing the per-dataset loop). File isdocs/data-model/collection.mdon thedocs/examples-in-conceptsbranch, ordocs/concepts/data-model.mdonmain— edit whichever exists. - Optionally switch
demo/seed_metadata.pycollection creation to the one-call form.
Acceptance criteria
-
POST /collectionswith{"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_datasetchecks). - Existing single-POST membership endpoint unchanged.
- Collection docs example updated to the one-call form.
-
uv run --all-extras pytestgreen;prek run --all-filesclean.
Notes
- Branch off
main. Standalone change.
Migrated from the internal tracker, where it was #26, opened 2026-07-24.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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