From e6bc020a54b28f43ca8557ab5bc01be8771d2cb4 Mon Sep 17 00:00:00 2001 From: Jim Bosch Date: Wed, 21 Jun 2023 12:04:44 -0400 Subject: [PATCH] Make NoDimensionsTask test utility consistent about storage classes. The config option provided by this task to change its output storage class actually only change the Python type returned, making that type inconsistent with the storage class it declared in its connections. This means we've long been testing essentially the wrong behavior, and I bet it's part of why we've had to be so defensive about storage class conversions in butler. This also switches the default for outputSC from 'dict' to 'StructuredDataDict', since it's supposed to be a storage class name, not a pytype. This wasn't causing trouble, but it was very confusing. --- python/lsst/pipe/base/tests/no_dimensions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/lsst/pipe/base/tests/no_dimensions.py b/python/lsst/pipe/base/tests/no_dimensions.py index c11c7abc..d753981a 100644 --- a/python/lsst/pipe/base/tests/no_dimensions.py +++ b/python/lsst/pipe/base/tests/no_dimensions.py @@ -27,6 +27,7 @@ "NoDimensionsTestTask", ) +import dataclasses from typing import cast from lsst.pex.config import Field @@ -51,13 +52,19 @@ class NoDimensionsTestConnections(PipelineTaskConnections, dimensions=set()): name="output", doc="some dict-y output data for testing", storageClass="StructuredDataDict" ) + config: NoDimensionsTestConfig + + def __init__(self, *, config: PipelineTaskConfig | None = None): + if self.config.outputSC != "StructuredDataDict": + self.output = dataclasses.replace(self.output, storageClass=self.config.outputSC) + class NoDimensionsTestConfig(PipelineTaskConfig, pipelineConnections=NoDimensionsTestConnections): """Configuration for `NoDimensionTestTask`.""" key = Field[str](doc="String key for the dict entry the task sets.", default="one") value = Field[int](doc="Integer value for the dict entry the task sets.", default=1) - outputSC = Field[str](doc="Output storage class requested", default="dict") + outputSC = Field[str](doc="Output Python type requested", default="StructuredDataDict") class NoDimensionsTestTask(PipelineTask):