CollectionQuery¶
- class lsst.daf.butler.registry.wildcards.CollectionQuery(search: CollectionSearch | ellipsis = Ellipsis, patterns: Tuple[Pattern, ...] = ())¶
Bases:
objectAn unordered query for collections and dataset type restrictions.
The
fromExpressionmethod should almost always be used to construct instances, as the regular constructor performs no checking of inputs (and that can lead to confusing error messages downstream).- Parameters:
- search
CollectionSearchor An object representing an ordered search for explicitly-named collections (to be interpreted here as unordered), or the special value
indicating all collections.must be accompanied bypatterns=None.- patterns
tupleofre.Pattern Regular expression patterns to match against collection names.
- universe
DimensionUniverse Object managing all dimensions.
- search
Notes
A
CollectionQueryis used to find all matching datasets in any number of collections, or to find collections themselves.CollectionQueryis expected to be rarely used outside ofRegistry(which uses it to back several of its “query” methods that take general expressions for collections), but it may occassionally be useful outsideRegistryas a way to preprocess expressions that contain single-pass iterators into a form that can be used to call thoseRegistrymethods multiple times.Methods Summary
Iterate over collection names that were specified explicitly.
fromExpression(expression)Process a general expression to construct a
CollectionQueryinstance.iter(manager, *[, collectionTypes, ...])Iterate over collection records that match this instance and the given criteria, in an arbitrary order.
Methods Documentation
- classmethod fromExpression(expression: Any) CollectionQuery¶
Process a general expression to construct a
CollectionQueryinstance.- Parameters:
- expression
- May be:
a
strcollection name;an
re.Patterninstance to match (withre.Pattern.fullmatch) against collection names;any iterable containing any of the above;
a
CollectionSearchinstance;another
CollectionQueryinstance (passed through unchanged).
Duplicate collection names will be removed (preserving the first appearance of each collection name).
- Returns:
- collections
CollectionQuery A
CollectionQueryinstance.
- collections
- iter(manager: CollectionManager, *, collectionTypes: AbstractSet[CollectionType] = frozenset({CollectionType.RUN, CollectionType.TAGGED, CollectionType.CHAINED, CollectionType.CALIBRATION}), flattenChains: bool = True, includeChains: bool | None = None) Iterator[CollectionRecord]¶
Iterate over collection records that match this instance and the given criteria, in an arbitrary order.
This method is primarily intended for internal use by
Registry; other callers should generally preferRegistry.queryDatasetsor otherRegistryquery methods.- Parameters:
- manager
CollectionManager Object responsible for managing the collection tables in a
Registry.- collectionTypes
AbstractSet[CollectionType], optional If provided, only yield collections of these types.
- flattenChains
bool, optional If
True(default) recursively yield the child collections ofCHAINEDcollections.- includeChains
bool, optional If
False, return records forCHAINEDcollections themselves. The default is the opposite offlattenChains: either return records for CHAINED collections or their children, but not both.
- manager
- Yields:
- record
CollectionRecord Matching collection records.
- record