ButlerCollections¶
- class lsst.daf.butler.ButlerCollections¶
- 
Methods for working with collections stored in the Butler. Attributes Summary Collection defaults associated with this butler. Methods Summary extend_chain(parent_collection_name, ...)Add children to the end of a CHAINED collection. get_info(name[, include_parents, ...])Obtain information for a specific collection. prepend_chain(parent_collection_name, ...)Add children to the beginning of a CHAINED collection. query(expression[, collection_types, ...])Query the butler for collections matching an expression. query_info(expression[, collection_types, ...])Query the butler for collections matching an expression and return detailed information about those collections. redefine_chain(parent_collection_name, ...)Replace the contents of a CHAINED collection with new children. register(name[, type, doc])Add a new collection if one with the given name does not exist. remove_from_chain(parent_collection_name, ...)Remove children from a CHAINED collection. x_remove(name)Remove the given collection from the registry. Attributes Documentation - defaults¶
- Collection defaults associated with this butler. 
 Methods Documentation - abstract extend_chain(parent_collection_name: str, child_collection_names: str | Iterable[str]) None¶
- Add children to the end of a CHAINED collection. - If any of the children already existed in the chain, they will be moved to the new position at the end of the chain. - Parameters:
- Raises:
- MissingCollectionError
- If any of the specified collections do not exist. 
- CollectionTypeError
- If the parent collection is not a CHAINED collection. 
- CollectionCycleError
- If this operation would create a collection cycle. 
 
 - Notes - If this function is called within a call to - Butler.transaction, it will hold a lock that prevents other processes from modifying the parent collection until the end of the transaction. Keep these transactions short.
 - abstract get_info(name: str, include_parents: bool = False, include_summary: bool = False) CollectionInfo¶
- Obtain information for a specific collection. - Parameters:
- Returns:
- infoCollectionInfo
- Information on the requested collection. 
 
- info
 
 - abstract prepend_chain(parent_collection_name: str, child_collection_names: str | Iterable[str]) None¶
- Add children to the beginning of a CHAINED collection. - If any of the children already existed in the chain, they will be moved to the new position at the beginning of the chain. - Parameters:
- Raises:
- MissingCollectionError
- If any of the specified collections do not exist. 
- CollectionTypeError
- If the parent collection is not a CHAINED collection. 
- CollectionCycleError
- If this operation would create a collection cycle. 
 
 - Notes - If this function is called within a call to - Butler.transaction, it will hold a lock that prevents other processes from modifying the parent collection until the end of the transaction. Keep these transactions short.
 - query(expression: str | Iterable[str], collection_types: Set[CollectionType] | CollectionType | None = None, flatten_chains: bool = False, include_chains: bool | None = None) Sequence[str]¶
- Query the butler for collections matching an expression. - Parameters:
- expressionstrorIterable[str]
- One or more collection names or globs to include in the search. 
- collection_typesset[CollectionType],CollectionTypeorNone
- Restrict the types of collections to be searched. If - Noneall collection types are searched.
- flatten_chainsbool, optional
- If - True(- Falseis default), recursively yield the child collections of matching- CHAINEDcollections.
- include_chainsboolorNone, optional
- If - True, yield records for matching- CHAINEDcollections. Default is the opposite of- flatten_chains: include either CHAINED collections or their children, but not both.
 
- expression
- Returns:
 - Notes - The order in which collections are returned is unspecified, except that the children of a - CHAINEDcollection are guaranteed to be in the order in which they are searched. When multiple parent- CHAINEDcollections match the same criteria, the order in which the two lists appear is unspecified, and the lists of children may be incomplete if a child has multiple parents.- The default implementation is a wrapper around - x_query_info.
 - abstract query_info(expression: str | Iterable[str], collection_types: Set[CollectionType] | CollectionType | None = None, flatten_chains: bool = False, include_chains: bool | None = None, include_parents: bool = False, include_summary: bool = False, include_doc: bool = False, summary_datasets: Iterable[DatasetType] | Iterable[str] | None = None) Sequence[CollectionInfo]¶
- Query the butler for collections matching an expression and return detailed information about those collections. - Parameters:
- expressionstrorIterable[str]
- One or more collection names or globs to include in the search. 
- collection_typesset[CollectionType],CollectionTypeorNone
- Restrict the types of collections to be searched. If - Noneall collection types are searched.
- flatten_chainsbool, optional
- If - True(- Falseis default), recursively yield the child collections of matching- CHAINEDcollections.
- include_chainsboolorNone, optional
- If - True, yield records for matching- CHAINEDcollections. Default is the opposite of- flatten_chains: include either CHAINED collections or their children, but not both.
- include_parentsbool, optional
- Whether the returned information includes parents. 
- include_summarybool, optional
- Whether the returned information includes dataset type and governor information for the collections. 
- include_docbool, optional
- Whether the returned information includes collection documentation string. 
- summary_datasetsIterable[DatasetType] orIterable[str], optional
- Dataset types to include in returned summaries. Only used if - include_summaryis- True. If not specified then all dataset types will be included.
 
- expression
- Returns:
- collectionsSequence[CollectionInfo]
- The names of collections that match - expression.
 
- collections
 - Notes - The order in which collections are returned is unspecified, except that the children of a - CHAINEDcollection are guaranteed to be in the order in which they are searched. When multiple parent- CHAINEDcollections match the same criteria, the order in which the two lists appear is unspecified, and the lists of children may be incomplete if a child has multiple parents.
 - abstract redefine_chain(parent_collection_name: str, child_collection_names: str | Iterable[str]) None¶
- Replace the contents of a CHAINED collection with new children. - Parameters:
- Raises:
- MissingCollectionError
- If any of the specified collections do not exist. 
- CollectionTypeError
- If the parent collection is not a CHAINED collection. 
- CollectionCycleError
- If this operation would create a collection cycle. 
 
 - Notes - If this function is called within a call to - Butler.transaction, it will hold a lock that prevents other processes from modifying the parent collection until the end of the transaction. Keep these transactions short.
 - abstract register(name: str, type: CollectionType = CollectionType.RUN, doc: str | None = None) bool¶
- Add a new collection if one with the given name does not exist. - Parameters:
- namestr
- The name of the collection to create. 
- typeCollectionType, optional
- Enum value indicating the type of collection to create. Default is to create a RUN collection. 
- docstr, optional
- Documentation string for the collection. 
 
- name
- Returns:
- registeredbool
- Boolean indicating whether the collection was already registered or was created by this call. 
 
- registered
 - Notes - This method cannot be called within transactions, as it needs to be able to perform its own transaction to be concurrent 
 - abstract remove_from_chain(parent_collection_name: str, child_collection_names: str | Iterable[str]) None¶
- Remove children from a CHAINED collection. - Parameters:
- Raises:
- MissingCollectionError
- If any of the specified collections do not exist. 
- CollectionTypeError
- If the parent collection is not a CHAINED collection. 
 
 - Notes - If this function is called within a call to - Butler.transaction, it will hold a lock that prevents other processes from modifying the parent collection until the end of the transaction. Keep these transactions short.
 - abstract x_remove(name: str) None¶
- Remove the given collection from the registry. - This is an experimental interface that can change at any time. - Parameters:
- namestr
- The name of the collection to remove. 
 
- name
- Raises:
- lsst.daf.butler.registry.MissingCollectionError
- Raised if no collection with the given name exists. 
- lsst.daf.butler.registry.OrphanedRecordError
- Raised if the database rows associated with the collection are still referenced by some other table, such as a dataset in a datastore (for - RUNcollections only) or a- CHAINEDcollection of which this collection is a child.
 
 - Notes - If this is a - RUNcollection, all datasets and quanta in it will removed from the- Registrydatabase. This requires that those datasets be removed (or at least trashed) from any datastores that hold them first.- A collection may not be deleted as long as it is referenced by a - CHAINEDcollection; the- CHAINEDcollection must be deleted or redefined first.