diff --git a/doc/lsst.ap.verify/request.rst b/doc/lsst.ap.verify/request.rst new file mode 100644 index 00000000..8fed53a1 --- /dev/null +++ b/doc/lsst.ap.verify/request.rst @@ -0,0 +1,12 @@ +.. py:currentmodule:: lsst.ap.verify + +.. _ap-verify-request: + +######################################## +mpSkyEphemerisQueryTask external request +######################################## + +mpSkyEphemerisQueryTask +======================= + +The AP pipelines now run :py:class:`lsst.ap.association.MPSkyEphemerisQueryTask`, which includes a request to mpSky. mpSky is not expected to host ephemerides for all test datasets, so it will often (or always) fail. When requests fail, mpSkyEphemerisQuery should return an empty DataFrame, and no detections will be associated. diff --git a/python/lsst/ap/verify/testPipeline.py b/python/lsst/ap/verify/testPipeline.py index 978fdfce..fed9caf7 100644 --- a/python/lsst/ap/verify/testPipeline.py +++ b/python/lsst/ap/verify/testPipeline.py @@ -35,7 +35,8 @@ import lsst.afw.math as afwMath import lsst.afw.table as afwTable from lsst.ap.association import (TransformDiaSourceCatalogConfig, - DiaPipelineConfig, FilterDiaSourceCatalogConfig) + DiaPipelineConfig, FilterDiaSourceCatalogConfig, + MPSkyEphemerisQueryConfig) from lsst.pipe.base import PipelineTask, Struct from lsst.ip.isr import IsrTaskConfig from lsst.ip.diffim import (GetTemplateConfig, AlardLuptonSubtractConfig, @@ -517,6 +518,16 @@ def run(self, template, science, difference, diaSources, pretrainedModel=None): return Struct(classifications=afwTable.BaseCatalog(afwTable.Schema())) +class MockMPSkyEphemerisQueryTask(PipelineTask): + """A do-nothing substitute for MPSkyEphemerisQueryTask. + """ + _DefaultName = "notMPSkyEphemerisQuery" + ConfigClass = MPSkyEphemerisQueryConfig + + def run(self, predictedRegionTime): + return Struct(ssObjects=pandas.DataFrame()) + + class MockTransformDiaSourceCatalogTask(PipelineTask): """A do-nothing substitute for TransformDiaSourceCatalogTask. """ diff --git a/tests/test_testPipeline.py b/tests/test_testPipeline.py index 7bdd6a4d..795203b8 100644 --- a/tests/test_testPipeline.py +++ b/tests/test_testPipeline.py @@ -39,7 +39,10 @@ MockCalibrateTask, MockGetTemplateTask, \ MockAlardLuptonSubtractTask, MockDetectAndMeasureTask, MockTransformDiaSourceCatalogTask, \ MockRBTransiNetTask, MockDiaPipelineTask, MockFilterDiaSourceCatalogTask, \ - MockSpatiallySampledMetricsTask + MockSpatiallySampledMetricsTask, MockMPSkyEphemerisQueryTask +from lsst.daf.butler import Timespan +from lsst.sphgeom import Circle +from lsst.pipe.base.utils import RegionTimeInfo class MockTaskTestSuite(unittest.TestCase): @@ -53,7 +56,6 @@ class MockTaskTestSuite(unittest.TestCase): @classmethod def setUpClass(cls): super().setUpClass() - repoDir = tempfile.mkdtemp() cls.addClassCleanup(shutil.rmtree, repoDir, ignore_errors=True) cls.repo = butlerTests.makeTestRepo(repoDir) @@ -73,11 +75,13 @@ def setUpClass(cls): name=INSTRUMENT, visit_max=256, exposure_max=256, detector_max=128, class_name="lsst.obs.base.instrument_tests.DummyCam", ) + cls.repo.registry.syncDimensionData("instrument", instrumentRecord) butlerTests.addDataIdValue(cls.repo, "physical_filter", PHYSICAL, band=BAND) butlerTests.addDataIdValue(cls.repo, "subfilter", SUB_FILTER) butlerTests.addDataIdValue(cls.repo, "exposure", VISIT) butlerTests.addDataIdValue(cls.repo, "visit", VISIT) + butlerTests.addDataIdValue(cls.repo, "group", VISIT) butlerTests.addDataIdValue(cls.repo, "detector", CCD) butlerTests.addDataIdValue(cls.repo, "skymap", SKYMAP) butlerTests.addDataIdValue(cls.repo, "tract", TRACT) @@ -88,6 +92,8 @@ def setUpClass(cls): {"instrument": INSTRUMENT, "exposure": VISIT, "detector": CCD}) cls.visitId = cls.repo.registry.expandDataId( {"instrument": INSTRUMENT, "visit": VISIT, "detector": CCD}) + cls.groupId = cls.repo.registry.expandDataId( + {"instrument": INSTRUMENT, "group": VISIT, "detector": CCD}) cls.visitOnlyId = cls.repo.registry.expandDataId( {"instrument": INSTRUMENT, "visit": VISIT}) cls.skymapId = cls.repo.registry.expandDataId({"skymap": SKYMAP}) @@ -129,6 +135,8 @@ def setUpClass(cls): butlerTests.addDatasetType(cls.repo, "deepDiff_candidateDiaSrc", cls.visitId.dimensions, "SourceCatalog") butlerTests.addDatasetType(cls.repo, "visitSsObjects", cls.visitOnlyId.dimensions, "DataFrame") + butlerTests.addDatasetType(cls.repo, "preloaded_ssObjects", cls.groupId.dimensions, "DataFrame") + butlerTests.addDatasetType(cls.repo, "regionTimeInfo", cls.groupId.dimensions, "RegionTimeInfo") 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, @@ -324,6 +332,21 @@ def testMockRBTransiNetTask(self): }) pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False) + def testMockMPSkyEphemerisQueryTask(self): + task = MockMPSkyEphemerisQueryTask() + pipelineTests.assertValidInitOutput(task) + dummyRegionTimeInfo = RegionTimeInfo(timespan=Timespan.makeEmpty(), region=Circle()) + result = task.run(predictedRegionTime=dummyRegionTimeInfo) + pipelineTests.assertValidOutput(task, result) + + self.butler.put(dummyRegionTimeInfo, "regionTimeInfo", self.groupId) + quantum = pipelineTests.makeQuantum( + task, self.butler, self.groupId, + {"predictedRegionTime": self.groupId, + "ssObjects": self.groupId, + }) + pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False) + def testMockTransformDiaSourceCatalogTask(self): task = MockTransformDiaSourceCatalogTask(initInputs=afwTable.SourceCatalog()) pipelineTests.assertValidInitOutput(task) @@ -351,14 +374,14 @@ def testMockDiaPipelineTask(self): pipelineTests.assertValidOutput(task, result) self.butler.put(pandas.DataFrame(), "deepDiff_diaSrcTable", self.visitId) - self.butler.put(pandas.DataFrame(), "visitSsObjects", self.visitId) + self.butler.put(pandas.DataFrame(), "preloaded_ssObjects", self.groupId) self.butler.put(afwImage.ExposureF(), "deepDiff_differenceExp", self.visitId) self.butler.put(afwImage.ExposureF(), "calexp", self.visitId) self.butler.put(afwImage.ExposureF(), "deepDiff_templateExp", self.visitId) quantum = pipelineTests.makeQuantum( task, self.butler, self.visitId, {"diaSourceTable": self.visitId, - "solarSystemObjectTable": self.visitId, + "solarSystemObjectTable": self.visitOnlyId, "diffIm": self.visitId, "exposure": self.visitId, "template": self.visitId,