From 283c1cf68f55ee5c202cde1331515b1c0ca93661 Mon Sep 17 00:00:00 2001 From: Orion Eiger Date: Fri, 10 Jan 2025 15:26:01 -0800 Subject: [PATCH] Fix linting and formatting and switch to lsst.utils.tests.TestCase --- .../analysis/tools/tasks/gatherResourceUsage.py | 3 ++- tests/test_gatherResourceUsage.py | 17 ++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/python/lsst/analysis/tools/tasks/gatherResourceUsage.py b/python/lsst/analysis/tools/tasks/gatherResourceUsage.py index 09fed5383..e170e8272 100644 --- a/python/lsst/analysis/tools/tasks/gatherResourceUsage.py +++ b/python/lsst/analysis/tools/tasks/gatherResourceUsage.py @@ -291,7 +291,8 @@ class GatherResourceUsageTask(PipelineTask): - ``init_time``: the time spent in task construction; - ``run_time``: the time spent executing the task's runQuantum method. - - ``wall_time`` : the total elapsed real time time spent executing the task. + - ``wall_time`` : the total elapsed real time time spent executing the + task. - ``{method}``: the time spent in a particular task or subtask method decorated with `lsst.utils.timer.timeMethod`. diff --git a/tests/test_gatherResourceUsage.py b/tests/test_gatherResourceUsage.py index 1a75a7f40..d4c13d571 100644 --- a/tests/test_gatherResourceUsage.py +++ b/tests/test_gatherResourceUsage.py @@ -22,14 +22,13 @@ from __future__ import annotations import os -from unittest import TestCase, main +from unittest import main import lsst.utils.tests - +from lsst.analysis.tools.tasks import GatherResourceUsageConfig, GatherResourceUsageTask from lsst.daf.butler import Butler, DatasetType, DeferredDatasetHandle -from lsst.pipe.base import TaskMetadata from lsst.daf.butler.tests.utils import makeTestTempDir, removeTestTempDir -from lsst.analysis.tools.tasks import GatherResourceUsageConfig, GatherResourceUsageTask +from lsst.pipe.base import TaskMetadata TESTDIR = os.path.abspath(os.path.dirname(__file__)) @@ -45,7 +44,7 @@ """ -class TestGatherResourceUsage(TestCase): +class TestGatherResourceUsage(lsst.utils.tests.TestCase): """Tests for the gatherResourceUsage class and methods.""" def setUp(self): @@ -72,10 +71,10 @@ def test_gatherResourceUsage(self): universe=self.butler.dimensions, input_metadata=input_metadata ).getDict()["output_table"] print(type(ru_output["init_time"].values)) - self.assertEqual(ru_output["memory"].values[0], 1.23456789e+09) - self.assertEqual(ru_output["init_time"].values[0], 2.0) - self.assertEqual(ru_output["run_time"].values[0], 25.0) - self.assertAlmostEqual(ru_output["wall_time"].values[0], 45.0) + self.assertFloatsAlmostEqual(ru_output["memory"].values[0], 1.23456789e09, atol=1e-3, rtol=1e-4) + self.assertFloatsAlmostEqual(ru_output["init_time"].values[0], 2.0, atol=1e-3, rtol=1e-4) + self.assertFloatsAlmostEqual(ru_output["run_time"].values[0], 25.0, atol=1e-3, rtol=1e-4) + self.assertFloatsAlmostEqual(ru_output["wall_time"].values[0], 45.0, atol=1e-3, rtol=1e-4) if __name__ == "__main__":