From d2a9315e7c33f633d5f8e0176ac8ee7e9004e62d Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Fri, 16 Aug 2024 16:25:09 -0700 Subject: [PATCH] Force collections to a list to ensure compatibility In old butler it's only a Sequence but in new butler it's a ButlerCollection which has no __eq__ implementation. List works for both. --- python/lsst/obs/base/_instrument.py | 2 +- python/lsst/obs/base/defineVisits.py | 2 +- tests/test_defineVisits.py | 2 +- tests/test_ingest.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/lsst/obs/base/_instrument.py b/python/lsst/obs/base/_instrument.py index 9b43c199..9ecbea0f 100644 --- a/python/lsst/obs/base/_instrument.py +++ b/python/lsst/obs/base/_instrument.py @@ -713,7 +713,7 @@ def loadCamera(butler: Butler, dataId: DataId, *, collections: Any = None) -> tu Raised when ``dataId`` does not specify a valid data ID. """ if collections is None: - collections = butler.collections + collections = list(butler.collections) # Registry would do data ID expansion internally if we didn't do it first, # but we might want an expanded data ID ourselves later, so we do it here # to ensure it only happens once. diff --git a/python/lsst/obs/base/defineVisits.py b/python/lsst/obs/base/defineVisits.py index db801e36..3e3def4d 100644 --- a/python/lsst/obs/base/defineVisits.py +++ b/python/lsst/obs/base/defineVisits.py @@ -1214,7 +1214,7 @@ def computeExposureBounds( sphere representing that detector's corners projected onto the sky. """ if collections is None: - collections = self.butler.collections + collections = list(self.butler.collections) camera, versioned = loadCamera(self.butler, exposure.dataId, collections=collections) if not versioned and self.config.requireVersionedCamera: raise LookupError(f"No versioned camera found for exposure {exposure.dataId}.") diff --git a/tests/test_defineVisits.py b/tests/test_defineVisits.py index 3eab55c1..9355358e 100644 --- a/tests/test_defineVisits.py +++ b/tests/test_defineVisits.py @@ -197,7 +197,7 @@ def testPickleTask(self): self.assertEqual(self.task.log.name, copy.log.name) self.assertEqual(self.task.config, copy.config) self.assertEqual(self.task.butler._config, copy.butler._config) - self.assertEqual(self.task.butler.collections, copy.butler.collections) + self.assertEqual(list(self.task.butler.collections), list(copy.butler.collections)) self.assertEqual(self.task.butler.run, copy.butler.run) self.assertEqual(self.task.universe, copy.universe) diff --git a/tests/test_ingest.py b/tests/test_ingest.py index 174f2efe..089c0975 100644 --- a/tests/test_ingest.py +++ b/tests/test_ingest.py @@ -467,7 +467,7 @@ def testPickleTask(self): self.assertEqual(self.task.log.name, copy.log.name) self.assertEqual(self.task.config, copy.config) self.assertEqual(self.task.butler._config, copy.butler._config) - self.assertEqual(self.task.butler.collections, copy.butler.collections) + self.assertEqual(list(self.task.butler.collections), list(copy.butler.collections)) self.assertEqual(self.task.butler.run, copy.butler.run) self.assertEqual(self.task.universe, copy.universe) self.assertEqual(self.task.datasetType, copy.datasetType)