Skip to content

Commit

Permalink
Use new Butler.get_dataset_type and Butler.find_dataset APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Nov 3, 2023
1 parent e1ab719 commit 8d99273
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion python/lsst/pipe/base/prerequisite_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def find(
# and when that happens PrerequisiteFinder.find never gets
# called.
try:
ref = butler.registry.findDataset(
ref = butler.find_dataset(

Check warning on line 287 in python/lsst/pipe/base/prerequisite_helpers.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/prerequisite_helpers.py#L287

Added line #L287 was not covered by tests
self.dataset_type_node.dataset_type,
data_id.subset(self.constraint_dimensions),
collections=input_collections,
Expand Down
14 changes: 4 additions & 10 deletions python/lsst/pipe/base/quantum_graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ def __init__(
self.skip_existing_starts_with_output_run = False
self.existing_datasets = ExistingDatasets()
try:
packages_storage_class = butler.registry.getDatasetType(
acc.PACKAGES_INIT_OUTPUT_NAME
).storageClass_name
packages_storage_class = butler.get_dataset_type(acc.PACKAGES_INIT_OUTPUT_NAME).storageClass_name
except MissingDatasetTypeError:
packages_storage_class = acc.PACKAGES_INIT_OUTPUT_STORAGE_CLASS
self._global_init_output_types = {
Expand Down Expand Up @@ -941,9 +939,7 @@ def _find_empty_dimension_datasets(self) -> None:
# Dataset type is an overall input; we always need to try to
# find these.
try:
ref = self.butler.registry.findDataset(
dataset_type.name, collections=self.input_collections
)
ref = self.butler.find_dataset(dataset_type.name, collections=self.input_collections)

Check warning on line 942 in python/lsst/pipe/base/quantum_graph_builder.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/quantum_graph_builder.py#L942

Added line #L942 was not covered by tests
except MissingDatasetTypeError:
ref = None
if ref is not None:
Expand All @@ -953,9 +949,7 @@ def _find_empty_dimension_datasets(self) -> None:
# if only they're from previously executed quanta that we might
# skip...
try:
ref = self.butler.registry.findDataset(
dataset_type.name, collections=self.skip_existing_in
)
ref = self.butler.find_dataset(dataset_type.name, collections=self.skip_existing_in)

Check warning on line 952 in python/lsst/pipe/base/quantum_graph_builder.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/quantum_graph_builder.py#L952

Added line #L952 was not covered by tests
except MissingDatasetTypeError:
ref = None
if ref is not None:
Expand All @@ -966,7 +960,7 @@ def _find_empty_dimension_datasets(self) -> None:
# ...or if they're in the way and would need to be clobbered
# (and we haven't already found them in the previous block).
try:
ref = self.butler.registry.findDataset(dataset_type.name, collections=[self.output_run])
ref = self.butler.find_dataset(dataset_type.name, collections=[self.output_run])
except MissingDatasetTypeError:
ref = None
if ref is not None:
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/pipe/base/testUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,16 @@ def _refFromConnection(
_checkDimensionsMatch(universe, set(connection.dimensions), dataId.keys())
dataId = DataCoordinate.standardize(dataId, **kwargs, universe=universe)

datasetType = butler.registry.getDatasetType(connection.name)
datasetType = butler.get_dataset_type(connection.name)

try:
butler.registry.getDatasetType(datasetType.name)
butler.get_dataset_type(datasetType.name)
except KeyError:
raise ValueError(f"Invalid dataset type {connection.name}.") from None
if not butler.run:
raise ValueError("Can not create a resolved DatasetRef since the butler has no default run defined.")
try:
registry_ref = butler.registry.findDataset(datasetType, dataId, collections=[butler.run])
registry_ref = butler.find_dataset(datasetType, dataId, collections=[butler.run])
if registry_ref:
ref = registry_ref
else:
Expand Down

0 comments on commit 8d99273

Please sign in to comment.