DatasetRecordStorageManager

class lsst.daf.butler.registry.interfaces.DatasetRecordStorageManager

Bases: abc.ABC

An interface that manages the tables that describe datasets.

DatasetRecordStorageManager primarily serves as a container and factory for DatasetRecordStorage instances, which each provide access to the records for a different DatasetType.

Methods Summary

addDatasetForeignKey(tableSpec, *, name, …) Add a foreign key (field and constraint) referencing the dataset table.
find(name) Return an object that provides access to the records associated with the given DatasetType, if one exists.
getDatasetRef(id, *, universe) Return a DatasetRef for the given dataset primary key value.
initialize(db, context, *, collections, universe) Construct an instance of the manager.
refresh(*, universe) Ensure all other operations on this manager are aware of any dataset types that may have been registered by other clients since it was initialized or last refreshed.
register(datasetType) Ensure that this Registry can hold records for the given DatasetType, creating new tables as necessary.

Methods Documentation

classmethod addDatasetForeignKey(tableSpec: lsst.daf.butler.core.ddl.TableSpec, *, name: str = 'dataset', constraint: bool = True, onDelete: Optional[str] = None, **kwargs) → lsst.daf.butler.core.ddl.FieldSpec

Add a foreign key (field and constraint) referencing the dataset table.

Parameters:
tableSpec : ddl.TableSpec

Specification for the table that should reference the dataset table. Will be modified in place.

name: `str`, optional

A name to use for the prefix of the new field; the full name is {name}_id.

onDelete: `str`, optional

One of “CASCADE” or “SET NULL”, indicating what should happen to the referencing row if the collection row is deleted. None indicates that this should be an integrity error.

constraint: `bool`, optional

If False (True is default), add a field that can be joined to the dataset primary key, but do not add a foreign key constraint.

**kwargs

Additional keyword arguments are forwarded to the ddl.FieldSpec constructor (only the name and dtype arguments are otherwise provided).

Returns:
idSpec : ddl.FieldSpec

Specification for the ID field.

find(name: str) → Optional[lsst.daf.butler.registry.interfaces._datasets.DatasetRecordStorage]

Return an object that provides access to the records associated with the given DatasetType, if one exists.

Parameters:
name : str

Name of the dataset type.

Returns:
records : DatasetRecordStorage or None

The object representing the records for the given dataset type, or None if there are no records for that dataset type.

Notes

Dataset types registered by another client of the same repository since the last call to initialize or refresh may not be found.

getDatasetRef(id: int, *, universe: DimensionUniverse) → Optional[DatasetRef]

Return a DatasetRef for the given dataset primary key value.

Parameters:
id : int

Autoincrement primary key value for the dataset.

universe : DimensionUniverse

All known dimensions.

Returns:
ref : DatasetRef or None

Object representing the dataset, or None if no dataset with the given primary key values exists in this layer.

classmethod initialize(db: Database, context: StaticTablesContext, *, collections: CollectionManager, universe: DimensionUniverse) → DatasetRecordStorageManager

Construct an instance of the manager.

Parameters:
db : Database

Interface to the underlying database engine and namespace.

context : StaticTablesContext

Context object obtained from Database.declareStaticTables; used to declare any tables that should always be present.

collections: `CollectionManager`

Manager object for the collections in this Registry.

universe : DimensionUniverse

Universe graph containing all dimensions known to this Registry.

Returns:
manager : DatasetRecordStorageManager

An instance of a concrete DatasetRecordStorageManager subclass.

refresh(*, universe: DimensionUniverse) → None

Ensure all other operations on this manager are aware of any dataset types that may have been registered by other clients since it was initialized or last refreshed.

register(datasetType: lsst.daf.butler.core.datasets.type.DatasetType) → Tuple[lsst.daf.butler.registry.interfaces._datasets.DatasetRecordStorage, bool]

Ensure that this Registry can hold records for the given DatasetType, creating new tables as necessary.

Parameters:
datasetType : DatasetType

Dataset type for which a table should created (as necessary) and an associated DatasetRecordStorage returned.

Returns:
records : DatasetRecordStorage

The object representing the records for the given dataset type.

inserted : bool

True if the dataset type did not exist in the registry before.

Notes

This operation may not be invoked within a Database.transaction context.