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, 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.
  • Loading branch information
TallJimbo committed Jun 22, 2023
1 parent f9b488b commit e6bc020
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

Check warning on line 30 in python/lsst/pipe/base/tests/no_dimensions.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/no_dimensions.py#L30

Added line #L30 was not covered by tests
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

Check warning on line 55 in python/lsst/pipe/base/tests/no_dimensions.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/no_dimensions.py#L55

Added line #L55 was not covered by tests

def __init__(self, *, config: PipelineTaskConfig | None = None):

Check warning on line 57 in python/lsst/pipe/base/tests/no_dimensions.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/no_dimensions.py#L57

Added line #L57 was not covered by tests
if self.config.outputSC != "StructuredDataDict":
self.output = dataclasses.replace(self.output, storageClass=self.config.outputSC)

Check warning on line 59 in python/lsst/pipe/base/tests/no_dimensions.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/no_dimensions.py#L59

Added line #L59 was not covered by tests


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")

Check warning on line 67 in python/lsst/pipe/base/tests/no_dimensions.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/no_dimensions.py#L67

Added line #L67 was not covered by tests


class NoDimensionsTestTask(PipelineTask):
Expand Down

0 comments on commit e6bc020

Please sign in to comment.