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-45677: Remove MockApPipe.yaml and tests that need it #235

Merged
merged 3 commits into from
Sep 3, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SConstruct
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because the files that were removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As stated in the commit message, no. This is an incidental problem I noticed while vetting ap_verify.table.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://github.com/lsst/templates/tree/main/project_templates/stack_package/example_pythononly for what a Python-only package is supposed to look like.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- python -*-
from lsst.sconsUtils import scripts
scripts.BasicSConstruct("ap_verify", disableCc=True)

# Python-only package
scripts.BasicSConstruct("ap_verify", disableCc=True, noCfgFile=True)
676 changes: 0 additions & 676 deletions python/lsst/ap/verify/testPipeline.py

This file was deleted.

99 changes: 0 additions & 99 deletions tests/MockApPipe.yaml

This file was deleted.

45 changes: 8 additions & 37 deletions tests/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,14 @@
from lsst.ap.verify import Dataset, WorkspaceGen3


TESTDIR = os.path.abspath(os.path.dirname(__file__))


def _getDataIds(butler):
return list(butler.registry.queryDataIds({"instrument", "visit", "detector"}, datasets="raw"))


def patchApPipeGen3(method):
"""Shortcut decorator for consistently patching AP code.
"""
@functools.wraps(method)
def wrapper(self, *args, **kwargs):
dbPatcher = unittest.mock.patch("lsst.ap.verify.pipeline_driver._makeApdb")
patchedMethod = dbPatcher(method)
pipePatcher = unittest.mock.patch("lsst.ap.verify.pipeline_driver.subprocess")
patchedMethod = dbPatcher(pipePatcher(method))
return patchedMethod(self, *args, **kwargs)
return wrapper

Expand All @@ -74,24 +68,7 @@ def setUp(self):
defineVisit = DefineVisitsTask(butler=self.workspace.workButler,
config=DefineVisitsTask.ConfigClass())
defineVisit.run(self.workspace.workButler.registry.queryDataIds("exposure", datasets="raw"))
ids = _getDataIds(self.workspace.workButler)
self.apPipeArgs = pipeline_driver.ApPipeParser().parse_args(
["--data-query", f"instrument = '{ids[0]['instrument']}' AND visit = {ids[0]['visit']}",
"--pipeline", os.path.join(TESTDIR, "MockApPipe.yaml")])

def testrunApPipeGen3Steps(self):
"""Test that runApPipeGen3 runs the entire pipeline.
"""
pipeline_driver.runApPipeGen3(self.workspace, self.apPipeArgs)

# Use datasets as a proxy for pipeline completion
id = _getDataIds(self.workspace.analysisButler)[0]
self.assertTrue(self.workspace.analysisButler.exists("calexp", id))
self.assertTrue(self.workspace.analysisButler.exists("src", id))
self.assertTrue(self.workspace.analysisButler.exists("goodSeeingDiff_differenceExp", id))
self.assertTrue(self.workspace.analysisButler.exists("goodSeeingDiff_diaSrc", id))
self.assertTrue(self.workspace.analysisButler.exists("apdb_marker", id))
self.assertTrue(self.workspace.analysisButler.exists("goodSeeingDiff_assocDiaSrc", id))
self.apPipeArgs = pipeline_driver.ApPipeParser().parse_args(["--pipeline", "foo.yaml"])

def _getArgs(self, call_args):
if call_args.args:
Expand All @@ -102,7 +79,7 @@ def _getArgs(self, call_args):
self.fail(f"No APDB args passed to {call_args}!")

@patchApPipeGen3
def testrunApPipeGen3WorkspaceDb(self, mockDb):
def testrunApPipeGen3WorkspaceDb(self, _mockPipe, mockDb):
"""Test that runApPipeGen3 places a database in the workspace location by default.
"""
pipeline_driver.runApPipeGen3(self.workspace, self.apPipeArgs)
Expand All @@ -113,7 +90,7 @@ def testrunApPipeGen3WorkspaceDb(self, mockDb):
self.assertEqual(dbArgs["db_url"], "sqlite:///" + self.workspace.dbLocation)

@patchApPipeGen3
def testrunApPipeGen3WorkspaceCustom(self, mockDb):
def testrunApPipeGen3WorkspaceCustom(self, _mockPipe, mockDb):
"""Test that runApPipeGen3 places a database in the specified location.
"""
self.apPipeArgs.db = "postgresql://[email protected]/custom_db"
Expand All @@ -124,20 +101,14 @@ def testrunApPipeGen3WorkspaceCustom(self, mockDb):
self.assertIn("db_url", dbArgs)
self.assertEqual(dbArgs["db_url"], self.apPipeArgs.db)

def testrunApPipeGen3Reuse(self):
@patchApPipeGen3
def testrunApPipeGen3Reuse(self, mockPipe, _mockDb):
"""Test that runApPipeGen3 does not run the pipeline at all (not even with
--skip-existing) if --skip-pipeline is provided.
"""
skipArgs = pipeline_driver.ApPipeParser().parse_args(["--skip-pipeline"])
pipeline_driver.runApPipeGen3(self.workspace, skipArgs)

# Use datasets as a proxy for pipeline completion.
# Depending on the overall test setup, the dataset may or may not be
# registered if the pipeline didn't run; check both cases.
id = _getDataIds(self.workspace.analysisButler)[0]
calexpQuery = set(self.workspace.analysisButler.registry.queryDatasetTypes("calexp"))
calexpExists = len(calexpQuery) > 0
self.assertFalse(calexpExists and self.workspace.analysisButler.exists("calexp", id))
mockPipe.assert_not_called()


class MemoryTester(lsst.utils.tests.MemoryTestCase):
Expand Down
Loading
Loading