DatasetRecordStorageManager¶
- class lsst.daf.butler.registry.interfaces.DatasetRecordStorageManager(*, registry_schema_version: VersionTuple | None = None)¶
Bases:
VersionedExtension
An interface that manages the tables that describe datasets.
DatasetRecordStorageManager
primarily serves as a container and factory forDatasetRecordStorage
instances, which each provide access to the records for a differentDatasetType
.- Parameters:
- registry_schema_version
VersionTuple
orNone
, optional Version of registry schema.
- registry_schema_version
Methods Summary
addDatasetForeignKey
(tableSpec, *[, name, ...])Add a foreign key (field and constraint) referencing the dataset table.
clone
(*, db, collections, dimensions, ...)Make an independent copy of this manager instance bound to new instances of
Database
and other managers.fetch_summaries
(collections[, dataset_types])Fetch collection summaries given their names and dataset types.
find
(name)Return an object that provides access to the records associated with the given
DatasetType
name, if one exists.getCollectionSummary
(collection)Return a summary for the given collection.
getDatasetRef
(id)Return a
DatasetRef
for the given dataset primary key value.Return type used for columns storing dataset IDs.
Return type of the
ingest_date
column.initialize
(db, context, *, collections, ...)Construct an instance of the manager.
refresh
()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 givenDatasetType
, creating new tables as necessary.remove
(name)Remove the dataset type.
resolve_wildcard
(expression[, missing, ...])Resolve a dataset type wildcard expression.
supportsIdGenerationMode
(mode)Test whether the given dataset ID generation mode is supported by
insert
.Methods Documentation
- abstract classmethod addDatasetForeignKey(tableSpec: TableSpec, *, name: str = 'dataset', constraint: bool = True, onDelete: str | None = None, **kwargs: Any) 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
.- 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.- 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.- **kwargs
Additional keyword arguments are forwarded to the
ddl.FieldSpec
constructor (only thename
anddtype
arguments are otherwise provided).
- tableSpec
- Returns:
- idSpec
ddl.FieldSpec
Specification for the ID field.
- idSpec
- abstract clone(*, db: Database, collections: CollectionManager, dimensions: DimensionRecordStorageManager, caching_context: CachingContext) DatasetRecordStorageManager ¶
Make an independent copy of this manager instance bound to new instances of
Database
and other managers.- Parameters:
- db
Database
New
Database
object to use when instantiating the manager.- collections
CollectionManager
New
CollectionManager
object to use when instantiating the manager.- dimensions
DimensionRecordStorageManager
New
DimensionRecordStorageManager
object to use when instantiating the manager.- caching_context
CachingContext
New
CachingContext
object to use when instantiating the manager.
- db
- Returns:
- instance
DatasetRecordStorageManager
New manager instance with the same configuration as this instance, but bound to a new Database object.
- instance
- abstract fetch_summaries(collections: Iterable[CollectionRecord], dataset_types: Iterable[DatasetType] | Iterable[str] | None = None) Mapping[Any, CollectionSummary] ¶
Fetch collection summaries given their names and dataset types.
- Parameters:
- collections
Iterable
[CollectionRecord
] Collection records to query.
- dataset_types
Iterable
[DatasetType
] orNone
Dataset types to include into returned summaries. If
None
then all dataset types will be included.
- collections
- Returns:
- summaries
Mapping
[Any
,CollectionSummary
] Collection summaries indexed by collection record key. This mapping will also contain all nested non-chained collections of the chained collections.
- summaries
- abstract find(name: str) DatasetRecordStorage | None ¶
Return an object that provides access to the records associated with the given
DatasetType
name, if one exists.- Parameters:
- name
str
Name of the dataset type.
- name
- Returns:
- records
DatasetRecordStorage
orNone
The object representing the records for the given dataset type, or
None
if there are no records for that dataset type.
- records
Notes
Dataset types registered by another client of the same repository since the last call to
initialize
orrefresh
may not be found.
- abstract getCollectionSummary(collection: CollectionRecord) CollectionSummary ¶
Return a summary for the given collection.
- Parameters:
- collection
CollectionRecord
Record describing the collection for which a summary is to be retrieved.
- collection
- Returns:
- summary
CollectionSummary
Summary of the dataset types and governor dimension values in this collection.
- summary
- abstract getDatasetRef(id: UUID) DatasetRef | None ¶
Return a
DatasetRef
for the given dataset primary key value.
- abstract classmethod getIdColumnType() type ¶
Return type used for columns storing dataset IDs.
This type is used for columns storing
DatasetRef.id
values, usually atype
subclass provided by SQLAlchemy.- Returns:
- dtype
type
Type used for dataset identification in database.
- dtype
- abstract classmethod initialize(db: Database, context: StaticTablesContext, *, collections: CollectionManager, dimensions: DimensionRecordStorageManager, caching_context: CachingContext, registry_schema_version: VersionTuple | None = None) 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
.- dimensions
DimensionRecordStorageManager
Manager object for the dimensions in this
Registry
.- caching_context
CachingContext
Object controlling caching of information returned by managers.
- registry_schema_version
VersionTuple
orNone
Schema version of this extension as defined in registry.
- db
- Returns:
- manager
DatasetRecordStorageManager
An instance of a concrete
DatasetRecordStorageManager
subclass.
- manager
- abstract refresh() 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.
- abstract register(datasetType: DatasetType) bool ¶
Ensure that this
Registry
can hold records for the givenDatasetType
, creating new tables as necessary.- Parameters:
- datasetType
DatasetType
Dataset type for which a table should created (as necessary) and an associated
DatasetRecordStorage
returned.
- datasetType
- Returns:
Notes
This operation may not be invoked within a
Database.transaction
context.
- abstract remove(name: str) None ¶
Remove the dataset type.
- Parameters:
- name
str
Name of the dataset type.
- name
- abstract resolve_wildcard(expression: Any, missing: list[str] | None = None, explicit_only: bool = False) list[lsst.daf.butler._dataset_type.DatasetType] ¶
Resolve a dataset type wildcard expression.
- Parameters:
- expression
Any
Expression to resolve. Will be passed to
DatasetTypeWildcard.from_expression
.- missing
list
ofstr
, optional String dataset type names that were explicitly given (i.e. not regular expression patterns) but not found will be appended to this list, if it is provided.
- explicit_only
bool
, optional If
True
, require explicitDatasetType
instances orstr
names, withre.Pattern
instances deprecated and...
prohibited.
- expression
- Returns:
- dataset_types
list
[DatasetType
] A list of resolved dataset types.
- dataset_types
- abstract classmethod supportsIdGenerationMode(mode: DatasetIdGenEnum) bool ¶
Test whether the given dataset ID generation mode is supported by
insert
.- Parameters:
- mode
DatasetIdGenEnum
Enum value for the mode to test.
- mode
- Returns:
- supported
bool
Whether the given mode is supported.
- supported