DatasetRef¶
- class lsst.daf.butler.DatasetRef(datasetType: DatasetType, dataId: DataCoordinate, *, id: Optional[Union[int, UUID]] = None, run: Optional[str] = None, conform: bool = True)¶
- Bases: - object- Reference to a Dataset in a - Registry.- A - DatasetRefmay point to a Dataset that currently does not yet exist (e.g., because it is a predicted input for provenance).- Parameters:
- datasetTypeDatasetType
- The - DatasetTypefor this Dataset.
- dataIdDataCoordinate
- A mapping of dimensions that labels the Dataset within a Collection. 
- idDatasetId, optional
- The unique identifier assigned when the dataset is created. 
- runstr, optional
- The name of the run this dataset was associated with when it was created. Must be provided if - idis.
- conformbool, optional
- If - True(default), call- DataCoordinate.standardizeto ensure that the data ID’s dimensions are consistent with the dataset type’s.- DatasetRefinstances for which those dimensions are not equal should not be created in new code, but are still supported for backwards compatibility. New code should only pass- Falseif it can guarantee that the dimensions are already consistent.
 
- datasetType
- Raises:
- ValueError
- Raised if - runis provided but- idis not, or if- idis provided but- runis not.
 
 - Attributes Summary - A mapping of - Dimensionprimary key values that labels the dataset within a Collection (- DataCoordinate).- The definition of this dataset ( - DatasetType).- Dimensions associated with the underlying - DatasetType.- Primary key of the dataset ( - DatasetIdor- None).- The name of the run that produced the dataset. - Methods Summary - expanded(dataId)- Return a new - DatasetRefwith the given expanded data ID.- from_json(json_str[, universe, registry])- Convert from JSON to a pydantic model. - from_simple(simple[, universe, registry])- Construct a new object from simplified form. - Return - self.id, or raise if it is- None.- groupByType(refs)- Group an iterable of - DatasetRefby- DatasetType.- Indicate whether this - DatasetRefrefers to a component.- Boolean indicating whether this - DatasetRefis a composite type.- makeComponentRef(name)- Create a - DatasetRefthat corresponds to a component.- Create a - DatasetRefof the composite from a component ref.- resolved(id, run)- Return resolved - DatasetRef.- to_json([minimal])- Convert this class to JSON assuming that the - to_simple()returns a pydantic model.- to_simple([minimal])- Convert this class to a simple python type. - Return unresolved - DatasetRef.- Attributes Documentation - dataId: DataCoordinate¶
- A mapping of - Dimensionprimary key values that labels the dataset within a Collection (- DataCoordinate).- Cannot be changed after a - DatasetRefis constructed.
 - datasetType: DatasetType¶
- The definition of this dataset ( - DatasetType).- Cannot be changed after a - DatasetRefis constructed.
 - dimensions¶
- Dimensions associated with the underlying - DatasetType.
 - id: Optional[Union[int, UUID]]¶
- Primary key of the dataset ( - DatasetIdor- None).- Cannot be changed after a - DatasetRefis constructed; use- resolvedor- unresolvedto add or remove this information when creating a new- DatasetRef.
 - run: Optional[str]¶
- The name of the run that produced the dataset. - Cannot be changed after a - DatasetRefis constructed; use- resolvedor- unresolvedto add or remove this information when creating a new- DatasetRef.
 - Methods Documentation - expanded(dataId: DataCoordinate) DatasetRef¶
- Return a new - DatasetRefwith the given expanded data ID.- Parameters:
- dataIdDataCoordinate
- Data ID for the new - DatasetRef. Must compare equal to the original data ID.
 
- dataId
- Returns:
- refDatasetRef
- A new - DatasetRefwith the given data ID.
 
- ref
 
 - classmethod from_json(json_str: str, universe: Optional[DimensionUniverse] = None, registry: Optional[Registry] = None) SupportsSimple¶
- Convert from JSON to a pydantic model. 
 - classmethod from_simple(simple: SerializedDatasetRef, universe: Optional[DimensionUniverse] = None, registry: Optional[Registry] = None) DatasetRef¶
- Construct a new object from simplified form. - Generally this is data returned from the - to_simplemethod.- Parameters:
- simpledictof [str,Any]
- The value returned by - to_simple().
- universeDimensionUniverse
- The special graph of all known dimensions. Can be - Noneif a registry is provided.
- registrylsst.daf.butler.Registry, optional
- Registry to use to convert simple form of a DatasetRef to a full - DatasetRef. Can be- Noneif a full description of the type is provided along with a universe.
 
- simple
- Returns:
- refDatasetRef
- Newly-constructed object. 
 
- ref
 
 - getCheckedId() Union[int, UUID]¶
- Return - self.id, or raise if it is- None.- This trivial method exists to allow operations that would otherwise be natural list comprehensions to check that the ID is not - Noneas well.
 - static groupByType(refs: Iterable[DatasetRef]) NamedKeyDict[DatasetType, List[DatasetRef]]¶
- Group an iterable of - DatasetRefby- DatasetType.- Parameters:
- refsIterable[DatasetRef]
- DatasetRefinstances to group.
 
- refs
- Returns:
- groupedNamedKeyDict[DatasetType,list[DatasetRef] ]
- Grouped - DatasetRefinstances.
 
- grouped
 
 - isComponent() bool¶
- Indicate whether this - DatasetRefrefers to a component.- Returns:
- isComponentbool
- Trueif this- DatasetRefis a component,- Falseotherwise.
 
- isComponent
 
 - isComposite() bool¶
- Boolean indicating whether this - DatasetRefis a composite type.- Returns:
- isCompositebool
- Trueif this- DatasetRefis a composite type,- Falseotherwise.
 
- isComposite
 
 - makeComponentRef(name: str) DatasetRef¶
- Create a - DatasetRefthat corresponds to a component.- Parameters:
- namestr
- Name of the component. 
 
- name
- Returns:
- refDatasetRef
- A - DatasetRefwith a dataset type that corresponds to the given component, and the same ID and run (which may be- None, if they are- Nonein- self).
 
- ref
 
 - makeCompositeRef() DatasetRef¶
- Create a - DatasetRefof the composite from a component ref.- Requires that this - DatasetRefis a component.- Returns:
- refDatasetRef
- A - DatasetRefwith a dataset type that corresponds to the composite parent of this component, and the same ID and run (which may be- None, if they are- Nonein- self).
 
- ref
 
 - resolved(id: Union[int, UUID], run: str) DatasetRef¶
- Return resolved - DatasetRef.- This is a new - DatasetRefwith the same data ID and dataset type and the given ID and run.- Parameters:
- idDatasetId
- The unique identifier assigned when the dataset is created. 
- runstr
- The run this dataset was associated with when it was created. 
 
- id
- Returns:
- refDatasetRef
- A new - DatasetRef.
 
- ref
 
 - to_json(minimal: bool = False) str¶
- Convert this class to JSON assuming that the - to_simple()returns a pydantic model.
 - to_simple(minimal: bool = False) SerializedDatasetRef¶
- Convert this class to a simple python type. - This makes it suitable for serialization. 
 - unresolved() DatasetRef¶
- Return unresolved - DatasetRef.- This is a new - DatasetRefwith the same data ID and dataset type, but no ID or run.- Returns:
- refDatasetRef
- A new - DatasetRef.
 
- ref
 - Notes - This can be used to compare only the data ID and dataset type of a pair of - DatasetRefinstances, regardless of whether either is resolved:- if ref1.unresolved() == ref2.unresolved(): ...