From 11ed937fa050a2d7e21637672d6695bbeae864a8 Mon Sep 17 00:00:00 2001 From: Hsin-Fang Chiang Date: Fri, 30 Aug 2024 12:36:30 -0700 Subject: [PATCH] Update the deprecated collection_chains with butler.collections --- python/activator/middleware_interface.py | 10 +++++----- tests/test_middleware_interface.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/activator/middleware_interface.py b/python/activator/middleware_interface.py index db7f98de..e2c377e4 100644 --- a/python/activator/middleware_interface.py +++ b/python/activator/middleware_interface.py @@ -816,7 +816,7 @@ def _transfer_data(self, datasets, calibs): # Temporary workarounds until we have a prompt-processing default top-level collection # in shared repos, and raw collection in dev repo, and then we can organize collections # without worrying about DRP use cases. - self.butler.collection_chains.prepend_chain( + self.butler.collections.prepend_chain( self.instrument.makeUmbrellaCollectionName(), [self._collection_template, self.instrument.makeDefaultRawIngestRunName(), @@ -904,7 +904,7 @@ def _export_calib_associations(self, calib_collection, datasets): calib_latest = self._get_local_calib_collection(calib_collection) new = self.butler.registry.registerCollection(calib_latest, CollectionType.CALIBRATION) if new: - self.butler.collection_chains.prepend_chain(calib_collection, [calib_latest]) + self.butler.collections.prepend_chain(calib_collection, [calib_latest]) # VALIDITY-HACK: real associations are expensive to query. Just apply # arbitrary ones and assume that the first collection in the chain is @@ -1617,7 +1617,7 @@ def _chain_exports(self, output_chain: str, output_runs: collections.abc.Iterabl self.central_butler.registry.registerCollection(output_chain, CollectionType.CHAINED) try: - self.central_butler.collection_chains.prepend_chain(output_chain, output_runs) + self.central_butler.collections.prepend_chain(output_chain, output_runs) except sqlalchemy.exc.IntegrityError as e: # HACK: I don't know of a better way to distinguish exceptions # blended by SQLAlchemy. To be removed on DM-43316. @@ -1707,7 +1707,7 @@ def clean_local_repo(self, exposure_ids: set[int]) -> None: calib_chain, flattenChains=True, collectionTypes=CollectionType.RUN) - self.butler.collection_chains.redefine_chain(calib_chain, []) + self.butler.collections.redefine_chain(calib_chain, []) self.butler.pruneDatasets(calib_refs, disassociate=True, unstore=True, purge=True) for member in calib_taggeds: self.butler.registry.removeCollection(member) @@ -1888,5 +1888,5 @@ def _remove_run_completely(butler, run): The run to remove. """ for chain in butler.registry.getCollectionParentChains(run): - butler.collection_chains.remove_from_chain(chain, [run]) + butler.collections.remove_from_chain(chain, [run]) butler.removeRuns([run], unstore=True) diff --git a/tests/test_middleware_interface.py b/tests/test_middleware_interface.py index fe049a18..58b16839 100644 --- a/tests/test_middleware_interface.py +++ b/tests/test_middleware_interface.py @@ -1268,7 +1268,7 @@ def test_extra_collection(self): """ central_butler = Butler(self.central_repo.name, writeable=True) central_butler.registry.registerCollection("emptyrun", CollectionType.RUN) - central_butler.collection_chains.prepend_chain("refcats", ["emptyrun"]) + central_butler.collections.prepend_chain("refcats", ["emptyrun"]) # Avoid collisions with other calls to prep_butler with make_local_repo(tempfile.gettempdir(), central_butler, instname) as local_repo: