CollectionSearch¶
- 
class lsst.daf.butler.CollectionSearch(items: List[Tuple[str, lsst.daf.butler.registry.wildcards.DatasetTypeRestriction]])¶
- Bases: - object- An ordered search path of 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: - items : list[tuple[str,DatasetTypeRestriction] ]
- Tuples that relate a collection name to the restriction on dataset types to search for within it. This is not a mapping because the same collection name may appear multiple times with different restrictions. 
 - Notes - A - CollectionSearchis used to find a single dataset according to its dataset type and data ID, giving preference to collections in which the order they are specified. A- CollectionQuerycan be constructed from a broader range of expressions but does not order the collections to be searched.- CollectionSearchis iterable, yielding two-element tuples of- str(collection name) and- DatasetTypeRestriction.- A - CollectionSearchinstance constructed properly (e.g. via- fromExpression) is a unique representation of a particular search path; it is exactly the same internally and compares as equal to any- CollectionSearchconstructed from an equivalent expression, regardless of how different the original expressions appear.- Methods Summary - fromExpression(expression)- Process a general expression to construct a - CollectionSearchinstance.- iter(manager, *, datasetType, …)- Iterate over collection records that match this instance and the given criteria, in order. - iterPairs(manager, *, datasetType, …)- Like - iter, but yield pairs of- CollectionRecord,- DatasetTypeRestrictioninstead of just the former.- Methods Documentation - 
classmethod fromExpression(expression: Any) → lsst.daf.butler.registry.wildcards.CollectionSearch¶
- Process a general expression to construct a - CollectionSearchinstance.- Parameters: - expression
- May be:
- a strcollection name;
- a two-element tuplecontaining astrand any expression accepted byDatasetTypeRestriction.fromExpression;
- any non-mapping iterable containing either of the above;
- a mapping from strto any expression accepted byDatasetTypeRestriction.
- another CollectionSearchinstance (passed through unchanged).
 
- a 
 - Multiple consecutive entries for the same collection with different restrictions will be merged. Non-consecutive entries will not, because that actually represents a different search path. 
 - Returns: - collections : CollectionSearch
- A - CollectionSearchinstance.
 
 - 
iter(manager: CollectionManager, *, datasetType: Optional[DatasetType] = None, collectionType: Optional[CollectionType] = None, done: Optional[Set[str]] = None, flattenChains: bool = True, includeChains: Optional[bool] = None) → Iterator[CollectionRecord]¶
- Iterate over collection records that match this instance and the given criteria, in order. - This method is primarily intended for internal use by - Registry; other callers should generally prefer- Registry.findDatasetsor other- Registryquery methods.- Parameters: - manager : CollectionManager
- Object responsible for managing the collection tables in a - Registry.
- datasetType : DatasetType, optional
- If given, only yield collections whose dataset type restrictions include this dataset type. 
- collectionType : CollectionType, optional
- If given, only yield collections of this type. 
- done : set, optional
- A - setcontaining the names of all collections already yielded; any collections whose names are already present in this set will not be yielded again, and those yielded will be added to it while iterating. If not provided, an empty- setwill be created and used internally to avoid duplicates.
- flattenChains : bool, optional
- If - True(default) recursively yield the child collections of- CHAINEDcollections.
- includeChains : bool, optional
- If - False, return records for- CHAINEDcollections themselves. The default is the opposite of- flattenChains: either return records for CHAINED collections or their children, but not both.
 - Yields: - record : CollectionRecord
- Matching collection records. 
 
- manager : 
 - 
iterPairs(manager: CollectionManager, *, datasetType: Optional[DatasetType] = None, collectionType: Optional[CollectionType] = None, done: Optional[Set[str]] = None, flattenChains: bool = True, includeChains: Optional[bool] = None) → Iterator[Tuple[CollectionRecord, DatasetTypeRestriction]]¶
- Like - iter, but yield pairs of- CollectionRecord,- DatasetTypeRestrictioninstead of just the former.- See - iterfor all parameter descriptions.- Yields: - record : CollectionRecord
- Matching collection records. 
- restriction : DatasetTypeRestriction
- The given dataset type restriction. 
 
- record : 
 
- items :