RepoExportContext¶
- class lsst.daf.butler.RepoExportContext(butler: DirectButler, backend: RepoExportBackend, *, directory: ResourcePathExpression | None = None, transfer: str | None = None)¶
Bases:
objectPublic 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:
- butler
lsst.daf.butler.direct_butler.DirectButler Butler to export from.
- backend
RepoExportBackend Implementation class for a particular export file format.
- directory
ResourcePathExpression, optional Directory to pass to
Datastore.export. Can beNoneto use the current working directory.- transfer
str, 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:
- name
str 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
TAGGEDorCALIBRATIONcollection 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.hasRecordsreturnsTrue) prior to the call tosaveDataIdsvia 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 beNone. Duplicates are automatically ignored. Nested data IDs must haveDataCoordinate.hasRecordsreturnTrue. 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 modifiedFileDataset. This is typically used to rewrite the path generated by the datastore. IfNone, theFileDatasetreturned byDatastore.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 (onceRegistryprovides 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:
- element
strorDimensionElement DimensionElementorstrindicating the logical table these records are from.- records
Iterable[DimensionRecordordict] Records to export, as an iterable containing
DimensionRecordordictinstances.
- element