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
Notes
- Branch off
main. Standalone change.
Migrated from the internal tracker, where it was #26, opened 2026-07-24.
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 + Nrequests.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.POST /collections/{collection_id}/datasets/{dataset_id}(bodyless;CollectionService.add_datasettakes a singledataset_id). There is no bulk path.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.)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
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.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.add_datasetchecks).uv run --all-extras pytestgreen;prek run --all-filesclean.Notes
main. Standalone change.Migrated from the internal tracker, where it was #26, opened 2026-07-24.