Skip to content

Commit

Permalink
Make NoDimensionsTask test utility consistent about storage classes.
Browse files Browse the repository at this point in the history
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.

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.
  • Loading branch information
TallJimbo committed Jun 22, 2023
1 parent f9b488b commit c6e640c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/lsst/pipe/base/tests/no_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"NoDimensionsTestTask",
)

import dataclasses
from typing import cast

from lsst.pex.config import Field
Expand All @@ -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):
Expand Down

0 comments on commit c6e640c

Please sign in to comment.