From 30ccb369a6aeb33854915c7dd7dbeda676d11c29 Mon Sep 17 00:00:00 2001 From: Krzysztof Findeisen Date: Fri, 2 Feb 2024 11:49:40 -0800 Subject: [PATCH] Fixup to "Move rbClassify definitions to ApPipe." 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. --- python/lsst/ap/verify/testPipeline.py | 11 ++++++++++ tests/MockApPipe.yaml | 12 +++++++++++ tests/test_testPipeline.py | 29 ++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/python/lsst/ap/verify/testPipeline.py b/python/lsst/ap/verify/testPipeline.py index b328bfbe..23370481 100644 --- a/python/lsst/ap/verify/testPipeline.py +++ b/python/lsst/ap/verify/testPipeline.py @@ -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 @@ -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. """ diff --git a/tests/MockApPipe.yaml b/tests/MockApPipe.yaml index 73b0aa80..95d5b84e 100644 --- a/tests/MockApPipe.yaml +++ b/tests/MockApPipe.yaml @@ -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: @@ -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 diff --git a/tests/test_testPipeline.py b/tests/test_testPipeline.py index 0fb840cc..ae91ace7 100644 --- a/tests/test_testPipeline.py +++ b/tests/test_testPipeline.py @@ -38,7 +38,7 @@ from lsst.ap.verify.testPipeline import MockIsrTask, MockCharacterizeImageTask, \ MockCalibrateTask, MockGetTemplateTask, \ MockAlardLuptonSubtractTask, MockDetectAndMeasureTask, MockTransformDiaSourceCatalogTask, \ - MockDiaPipelineTask + MockRBTransiNetTask, MockDiaPipelineTask class MockTaskTestSuite(unittest.TestCase): @@ -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( @@ -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() @@ -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)