From e6dbd6153afc380fa67e1710b41b99b2c4d9857f Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 3 Jan 2024 11:38:55 -0700 Subject: [PATCH 1/2] Use ConfigDict to configure pydantic dataclass This is the pydantic v2 interface. --- python/lsst/pipe/tasks/fit_multiband.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/lsst/pipe/tasks/fit_multiband.py b/python/lsst/pipe/tasks/fit_multiband.py index e70cb7280..9225f9759 100644 --- a/python/lsst/pipe/tasks/fit_multiband.py +++ b/python/lsst/pipe/tasks/fit_multiband.py @@ -22,7 +22,7 @@ __all__ = ["CatalogExposure", "CatalogExposureConfig", ] from functools import cached_property -from pydantic import Field +from pydantic import Field, ConfigDict from pydantic.dataclasses import dataclass import lsst.afw.image as afwImage @@ -30,8 +30,7 @@ import lsst.daf.butler as dafButler -class CatalogExposureConfig: - arbitrary_types_allowed = True +CatalogExposureConfig = ConfigDict(arbitrary_types_allowed=True) @dataclass(frozen=True, kw_only=True, config=CatalogExposureConfig) From d9cd81debd351999eac3dbed3609ac7eab11fb3f Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 3 Jan 2024 11:48:30 -0700 Subject: [PATCH 2/2] Modify directory cleanup to avoid ResourceWarning Deleting the variable does trigger the clean up of the temporary directory but it also issues a warning: ResourceWarning: Implicitly cleaning up Replace the tearDown with an explicit cleanup() call. Also ensure that any errors in clean up do not cause the tests to fail. --- tests/test_calibrateImage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_calibrateImage.py b/tests/test_calibrateImage.py index a4db76eba..ed6d4092a 100644 --- a/tests/test_calibrateImage.py +++ b/tests/test_calibrateImage.py @@ -310,7 +310,7 @@ def setUp(self): detector = 42 # Create a and populate a test butler for runQuantum tests. - self.repo_path = tempfile.TemporaryDirectory() + self.repo_path = tempfile.TemporaryDirectory(ignore_cleanup_errors=True) self.repo = butlerTests.makeTestRepo(self.repo_path.name) # dataIds for fake data @@ -366,7 +366,7 @@ def setUp(self): self.butler.put(afwTable.SimpleCatalog(), "ps1_pv3_3pi_20170110", self.htm_id) def tearDown(self): - del self.repo_path # this removes the temporary directory + self.repo_path.cleanup() def test_runQuantum(self): task = CalibrateImageTask()