Skip to content

Commit

Permalink
Fixup to "Move rbClassify definitions to ApPipe."
Browse files Browse the repository at this point in the history
This commit adds a mock RBTransiNetTaskTask. It is kept separate for
reviewer convenience, but should be squashed with the rbClassify move
to give a self-consistent view of the contents of ApPipe.
  • Loading branch information
kfindeisen committed Feb 2, 2024
1 parent 983482c commit 30ccb36
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
11 changes: 11 additions & 0 deletions python/lsst/ap/verify/testPipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from lsst.ip.diffim import GetTemplateConfig, AlardLuptonSubtractConfig, DetectAndMeasureConfig
from lsst.pipe.tasks.characterizeImage import CharacterizeImageConfig
from lsst.pipe.tasks.calibrate import CalibrateConfig
from lsst.meas.transiNet import RBTransiNetConfig
from lsst.ap.association import TransformDiaSourceCatalogConfig, DiaPipelineConfig


Expand Down Expand Up @@ -433,6 +434,16 @@ def run(self, science, matchedTemplate, difference,
)


class MockRBTransiNetTask(PipelineTask):
"""A do-nothing substitute for RBTransiNetTask.
"""
_DefaultName = "rbTransiNet"
ConfigClass = RBTransiNetConfig

def run(self, template, science, difference, diaSources, pretrainedModel=None):
return Struct(classifications=afwTable.BaseCatalog(afwTable.Schema()))


class MockTransformDiaSourceCatalogTask(PipelineTask):
"""A do-nothing substitute for TransformDiaSourceCatalogTask.
"""
Expand Down
12 changes: 12 additions & 0 deletions tests/MockApPipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ tasks:
config:
connections.coaddName: parameters.coaddName
doSkySources: True
rbClassify:
class: lsst.ap.verify.testPipeline.MockRBTransiNetTask
config:
modelPackageStorageMode: butler
connections.coaddName: parameters.coaddName
transformDiaSrcCat:
class: lsst.ap.verify.testPipeline.MockTransformDiaSourceCatalogTask
config:
Expand All @@ -58,11 +63,18 @@ contracts:
diaPipe.connections.ConnectionsClass(config=diaPipe).template.name
- subtractImages.connections.ConnectionsClass(config=subtractImages).science.name ==
diaPipe.connections.ConnectionsClass(config=diaPipe).exposure.name
- detectAndMeasure.connections.ConnectionsClass(config=detectAndMeasure).subtractedMeasuredExposure.name ==
rbClassify.connections.ConnectionsClass(config=rbClassify).difference.name
- detectAndMeasure.connections.ConnectionsClass(config=detectAndMeasure).diaSources.name ==
rbClassify.connections.ConnectionsClass(config=rbClassify).diaSources.name
- detectAndMeasure.connections.ConnectionsClass(config=detectAndMeasure).subtractedMeasuredExposure.name ==
transformDiaSrcCat.connections.ConnectionsClass(config=transformDiaSrcCat).diffIm.name
- detectAndMeasure.connections.ConnectionsClass(config=detectAndMeasure).diaSources.name ==
transformDiaSrcCat.connections.ConnectionsClass(config=transformDiaSrcCat).diaSourceCat.name
- detectAndMeasure.connections.ConnectionsClass(config=detectAndMeasure).subtractedMeasuredExposure.name ==
diaPipe.connections.ConnectionsClass(config=diaPipe).diffIm.name
- (not transformDiaSrcCat.doIncludeReliability) or
(rbClassify.connections.ConnectionsClass(config=rbClassify).classifications.name ==
transformDiaSrcCat.connections.ConnectionsClass(config=transformDiaSrcCat).reliability.name)
- transformDiaSrcCat.connections.ConnectionsClass(config=transformDiaSrcCat).diaSourceTable.name ==
diaPipe.connections.ConnectionsClass(config=diaPipe).diaSourceTable.name
29 changes: 28 additions & 1 deletion tests/test_testPipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from lsst.ap.verify.testPipeline import MockIsrTask, MockCharacterizeImageTask, \
MockCalibrateTask, MockGetTemplateTask, \
MockAlardLuptonSubtractTask, MockDetectAndMeasureTask, MockTransformDiaSourceCatalogTask, \
MockDiaPipelineTask
MockRBTransiNetTask, MockDiaPipelineTask


class MockTaskTestSuite(unittest.TestCase):
Expand Down Expand Up @@ -82,6 +82,7 @@ def setUpClass(cls):
butlerTests.addDataIdValue(cls.repo, "tract", TRACT)
butlerTests.addDataIdValue(cls.repo, "patch", PATCH)

cls.emptyId = cls.repo.registry.expandDataId({})
cls.exposureId = cls.repo.registry.expandDataId(
{"instrument": INSTRUMENT, "exposure": VISIT, "detector": CCD})
cls.visitId = cls.repo.registry.expandDataId(
Expand Down Expand Up @@ -124,6 +125,7 @@ def setUpClass(cls):
butlerTests.addDatasetType(cls.repo, "apdb_marker", cls.visitId.dimensions, "Config")
butlerTests.addDatasetType(cls.repo, "deepDiff_assocDiaSrc", cls.visitId.dimensions, "DataFrame")
butlerTests.addDatasetType(cls.repo, "deepDiff_longTrailedSrc", cls.visitId.dimensions, "DataFrame")
butlerTests.addDatasetType(cls.repo, "deepRealBogusSources", cls.visitId.dimensions, "Catalog")

def setUp(self):
super().setUp()
Expand Down Expand Up @@ -249,6 +251,31 @@ def testMockDetectAndMeasureTask(self):
})
pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)

def testMockRBTransiNetTask(self):
task = MockRBTransiNetTask()
pipelineTests.assertValidInitOutput(task)
result = task.run(template=afwImage.ExposureF(),
science=afwImage.ExposureF(),
difference=afwImage.ExposureF(),
diaSources=afwTable.SourceCatalog(),
)
pipelineTests.assertValidOutput(task, result)

self.butler.put(afwImage.ExposureF(), "calexp", self.visitId)
self.butler.put(afwImage.ExposureF(), "deepDiff_differenceExp", self.visitId)
self.butler.put(afwImage.ExposureF(), "deepDiff_templateExp", self.visitId)
self.butler.put(afwTable.SourceCatalog(), "deepDiff_diaSrc", self.visitId)
quantum = pipelineTests.makeQuantum(
task, self.butler, self.visitId,
{"template": self.visitId,
"science": self.visitId,
"difference": self.visitId,
"diaSources": self.visitId,
"pretrainedModel": self.emptyId,
"classifications": self.visitId,
})
pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)

def testMockTransformDiaSourceCatalogTask(self):
task = MockTransformDiaSourceCatalogTask(initInputs=afwTable.SourceCatalog())
pipelineTests.assertValidInitOutput(task)
Expand Down

0 comments on commit 30ccb36

Please sign in to comment.