Skip to content

Commit

Permalink
Add ability to add additional provenance info to dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jan 31, 2025
1 parent 4516542 commit a9da29c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions python/lsst/daf/butler/_dataset_provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class DatasetProvenance(pydantic.BaseModel):
"""The input datasets."""
quantum_id: uuid.UUID | None = None
"""Identifier of the Quantum that was executed."""
extras: dict[uuid.UUID, dict[str, int | float | str | bool]] = pydantic.Field(default_factory=dict)
"""Extra provenance information associated with a particular dataset."""
_uuids: set[uuid.UUID] = pydantic.PrivateAttr(default_factory=set)

@pydantic.model_validator(mode="after")
Expand All @@ -65,3 +67,20 @@ def add_input(self, ref: DatasetRef) -> None:
return
self._uuids.add(ref.id)
self.inputs.append(ref.to_simple())

def add_extra_provenance(self, dataset_id: uuid.UUID, extra: dict[str, int | float | str | bool]) -> None:
"""Attach extra provenance to a specific dataset.
Parameters
----------
dataset_id : `uuid.UUID`
The ID of the dataset to receive this provenance.
extra : `dict` [ `str`, `typing.Any` ]
The extra provenance information as a dictionary. The values
must be simple Python scalars.
"""
if dataset_id not in self._uuids:
raise ValueError(f"The given dataset ID {dataset_id} is not known to this provenance instance.")
if dataset_id not in self.extras:
self.extras[dataset_id] = {}
self.extras[dataset_id].update(extra)

0 comments on commit a9da29c

Please sign in to comment.