Skip to content

Commit

Permalink
Merge pull request #1063 from lsst/tickets/DM-45919
Browse files Browse the repository at this point in the history
DM-45919: Make removeRuns much faster
  • Loading branch information
timj committed Aug 24, 2024
2 parents a31b046 + c44c336 commit 11dbc91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Binary file added python/lsst/daf/butler/.DS_Store
Binary file not shown.
10 changes: 9 additions & 1 deletion python/lsst/daf/butler/direct_butler/_direct_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,11 +1391,19 @@ def removeRuns(self, names: Iterable[str], unstore: bool = True) -> None:
raise TypeError("Butler is read-only.")
names = list(names)
refs: list[DatasetRef] = []
all_dataset_types = [dt.name for dt in self._registry.queryDatasetTypes(...)]
for name in names:
collectionType = self._registry.getCollectionType(name)
if collectionType is not CollectionType.RUN:
raise TypeError(f"The collection type of '{name}' is {collectionType.name}, not RUN.")
refs.extend(self._registry.queryDatasets(..., collections=name, findFirst=True))
with self._query() as query:
# Work out the dataset types that are relevant.
collections_info = self.collections.x_query_info(name, include_summary=True)
filtered_dataset_types = self.collections._filter_dataset_types(
all_dataset_types, collections_info
)
for dt in filtered_dataset_types:
refs.extend(query.datasets(dt, collections=name))
with self._datastore.transaction(), self._registry.transaction():
if unstore:
self._datastore.trash(refs)
Expand Down

0 comments on commit 11dbc91

Please sign in to comment.