Skip to content

Commit

Permalink
Merge pull request #76 from lsst-sitcom/tickets/DM-40512
Browse files Browse the repository at this point in the history
DM-40512: fix bitrot in QuickLookIsrConnections
  • Loading branch information
TallJimbo authored Dec 12, 2023
2 parents c69f3f1 + bbfad32 commit 63133e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
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

0 comments on commit 63133e9

Please sign in to comment.