RepoExportContext¶
- class lsst.daf.butler.RepoExportContext(butler: DirectButler, backend: RepoExportBackend, *, directory: ResourcePathExpression | None = None, transfer: str | None = None)¶
- Bases: - object- Public interface for exporting a subset of a data repository. - Instances of this class are obtained by calling - Butler.exportas the value returned by that context manager:- with butler.export(filename="export.yaml") as export: export.saveDataIds(...) export.saveDatasets(...) - Parameters:
- butlerlsst.daf.butler.direct_butler.DirectButler
- Butler to export from. 
- backendRepoExportBackend
- Implementation class for a particular export file format. 
- directoryResourcePathExpression, optional
- Directory to pass to - Datastore.export. Can be- Noneto use the current working directory.
- transferstr, optional
- Transfer mode to pass to - Datastore.export.
 
- butler
 - Methods Summary - saveCollection(name)- Export the given collection. - saveDataIds(dataIds, *[, elements])- Export the dimension records associated with one or more data IDs. - saveDatasets(refs, *[, elements, rewrite])- Export one or more datasets. - saveDimensionData(element, records)- Export the given dimension records associated with one or more data IDs. - Methods Documentation - saveCollection(name: str) None¶
- Export the given collection. - Parameters:
- namestr
- Name of the collection. 
 
- name
 - Notes - RUNcollections are also exported automatically when any dataset referencing them is exported. They may also be explicitly exported this method to export the collection with no datasets. Duplicate exports of collections are ignored.- Exporting a - TAGGEDor- CALIBRATIONcollection will cause its associations with exported datasets to also be exported, but it does not export those datasets automatically.- Exporting a - CHAINEDcollection does not automatically export its child collections; these must be explicitly exported or already be present in the repository they are being imported into.
 - saveDataIds(dataIds: Iterable[DataCoordinate], *, elements: Iterable[str | DimensionElement] | None = None) None¶
- Export the dimension records associated with one or more data IDs. - Parameters:
- dataIdsiterable of DataCoordinate
- Data IDs to export. For large numbers of data IDs obtained by calls to - Registry.queryDataIds, it will be much more efficient if these are expanded to include records (i.e.- DataCoordinate.hasRecordsreturns- True) prior to the call to- saveDataIdsvia e.g.- Registry.queryDataIds(...).expanded().
- elementsiterable of DimensionElementorstr, optional
- Dimension elements whose records should be exported. If - None, records for all dimensions will be exported.
 
- dataIdsiterable of 
 
 - saveDatasets(refs: Iterable[DatasetRef], *, elements: Iterable[str | DimensionElement] | None = None, rewrite: Callable[[FileDataset], FileDataset] | None = None) None¶
- Export one or more datasets. - This automatically exports any - DatasetType,- RUNcollections, and dimension records associated with the datasets.- Parameters:
- refsiterable of DatasetRef
- References to the datasets to export. Their - DatasetRef.idattributes must not be- None. Duplicates are automatically ignored. Nested data IDs must have- DataCoordinate.hasRecordsreturn- True. If any reference is to a component dataset, the parent will be exported instead.
- elementsiterable of DimensionElementorstr, optional
- Dimension elements whose records should be exported; this is forwarded to - saveDataIdswhen exporting the data IDs of the given datasets.
- rewritecallable, optional
- A callable that takes a single - FileDatasetargument and returns a modified- FileDataset. This is typically used to rewrite the path generated by the datastore. If- None, the- FileDatasetreturned by- Datastore.exportwill be used directly.
 
- refsiterable of 
 - Notes - At present, this only associates datasets with - RUNcollections. Other collections will be included in the export in the future (once- Registryprovides a way to look up that information).
 - saveDimensionData(element: str | DimensionElement, records: Iterable[dict | DimensionRecord]) None¶
- Export the given dimension records associated with one or more data IDs. - Parameters:
- elementstrorDimensionElement
- DimensionElementor- strindicating the logical table these records are from.
- recordsIterable[DimensionRecordordict]
- Records to export, as an iterable containing - DimensionRecordor- dictinstances.
 
- element