-
Notifications
You must be signed in to change notification settings - Fork 3
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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: | ||
|
@@ -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) | ||
|
@@ -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" | ||
|
@@ -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): | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.There was a problem hiding this comment.
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.