Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-40512: fix bitrot in QuickLookIsrConnections #76

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 6 additions & 17 deletions python/lsst/summit/utils/quickLook.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import dataclasses
import os
from lsst.ip.isr import IsrTask
from lsst.ip.isr.isrTask import IsrTaskConnections
Expand All @@ -33,17 +34,6 @@
__all__ = ['QuickLookIsrTask', 'QuickLookIsrTaskConfig']


def _getArgs(connection):
"""Get the all required args from a connection in order to reconstruct it.
"""
newArgs = {}
for attr in ("name", "storageClass", "multiple", "doc", "dimensions", "isCalibration", "deferLoad",
"minimum", "lookupFunction"):
if hasattr(connection, attr):
newArgs[attr] = getattr(connection, attr)
return newArgs


class QuickLookIsrTaskConnections(IsrTaskConnections):
"""Copy isrTask's connections, changing prereq min values to zero.

Expand All @@ -57,12 +47,11 @@ def __init__(self, *, config=None):
super().__init__(config=IsrTask.ConfigClass()) # need a dummy config, isn't used other than for ctor
for name, connection in self.allConnections.items():
if hasattr(connection, 'minimum'):
args = _getArgs(connection)
if name != "ccdExposure": # need one input image always
args['minimum'] = 0
newConnection = type(connection)(**args)
self.allConnections[name] = newConnection
setattr(self, name, newConnection)
setattr(
self,
name,
dataclasses.replace(connection, minimum=(0 if name != "ccdExposure" else 1)),
)

exposure = cT.Output( # called just "exposure" to mimic isrTask's return struct
name="quickLookExp",
Expand Down
10 changes: 10 additions & 0 deletions tests/test_bestEffortIsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import lsst.utils.tests

from lsst.summit.utils.bestEffort import BestEffortIsr
from lsst.summit.utils.quickLook import QuickLookIsrTask
import lsst.summit.utils.butlerUtils as butlerUtils
import lsst.afw.image as afwImage

Expand Down Expand Up @@ -78,6 +79,15 @@ def test_raises(self):
with self.assertRaises(ValueError):
self.bestEffortIsr.getExposure(dataId)

def test_quicklook_connections(self):
"""Test that various QuickLookIsrConnections inputs are no longer
required.
"""
connections = QuickLookIsrTask.ConfigClass.ConnectionsClass(config=QuickLookIsrTask.ConfigClass())
self.assertEqual(connections.bias.minimum, 0)
self.assertEqual(connections.flat.minimum, 0)
self.assertEqual(connections.ccdExposure.minimum, 1)


class TestMemory(lsst.utils.tests.MemoryTestCase):
pass
Expand Down