-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new-style configs inside ap_verify.
This change removes ap_verify's dependency on the deprecated makeApdb function. Although the new configs allow better support for Cassandra APDBs, ap_verify itself only supports SQL (particularly SQLite), given its restricted scope.
- Loading branch information
1 parent
ffe20f2
commit fea709f
Showing
2 changed files
with
40 additions
and
38 deletions.
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
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 |
---|---|---|
|
@@ -46,7 +46,7 @@ def patchApPipeGen3(method): | |
""" | ||
@functools.wraps(method) | ||
def wrapper(self, *args, **kwargs): | ||
dbPatcher = unittest.mock.patch("lsst.ap.verify.pipeline_driver.makeApdb") | ||
dbPatcher = unittest.mock.patch("lsst.ap.verify.pipeline_driver._makeApdb") | ||
patchedMethod = dbPatcher(method) | ||
return patchedMethod(self, *args, **kwargs) | ||
return wrapper | ||
|
@@ -93,29 +93,24 @@ def testrunApPipeGen3Steps(self): | |
self.assertTrue(self.workspace.analysisButler.exists("apdb_marker", id)) | ||
self.assertTrue(self.workspace.analysisButler.exists("goodSeeingDiff_assocDiaSrc", id)) | ||
|
||
def _getCmdLineArgs(self, parseAndRunArgs): | ||
if parseAndRunArgs[0]: | ||
return parseAndRunArgs[0][0] | ||
elif "args" in parseAndRunArgs[1]: | ||
return parseAndRunArgs[1]["args"] | ||
def _getArgs(self, call_args): | ||
if call_args.args: | ||
return call_args.args[1] | ||
elif "args" in call_args.kwargs: | ||
return call_args.kwargs["args"] | ||
else: | ||
self.fail("No command-line args passed to parseAndRun!") | ||
self.fail(f"No APDB args passed to {call_args}!") | ||
|
||
@patchApPipeGen3 | ||
def testrunApPipeGen3WorkspaceDb(self, mockDb): | ||
"""Test that runApPipeGen3 places a database in the workspace location by default. | ||
""" | ||
pipeline_driver.runApPipeGen3(self.workspace, self.apPipeArgs) | ||
|
||
# Test the call to make_apdb.py | ||
mockDb.assert_called_once() | ||
cmdLineArgs = self._getCmdLineArgs(mockDb.call_args) | ||
self.assertIn("db_url=sqlite:///" + self.workspace.dbLocation, cmdLineArgs) | ||
|
||
# Test the call to the AP pipeline | ||
id = _getDataIds(self.workspace.analysisButler)[0] | ||
apdbConfig = self.workspace.analysisButler.get("apdb_marker", id) | ||
self.assertEqual(apdbConfig.db_url, "sqlite:///" + self.workspace.dbLocation) | ||
dbArgs = self._getArgs(mockDb.call_args) | ||
self.assertIn("db_url", dbArgs) | ||
self.assertEqual(dbArgs["db_url"], "sqlite:///" + self.workspace.dbLocation) | ||
|
||
@patchApPipeGen3 | ||
def testrunApPipeGen3WorkspaceCustom(self, mockDb): | ||
|
@@ -124,15 +119,10 @@ def testrunApPipeGen3WorkspaceCustom(self, mockDb): | |
self.apPipeArgs.db = "postgresql://[email protected]/custom_db" | ||
pipeline_driver.runApPipeGen3(self.workspace, self.apPipeArgs) | ||
|
||
# Test the call to make_apdb.py | ||
mockDb.assert_called_once() | ||
cmdLineArgs = self._getCmdLineArgs(mockDb.call_args) | ||
self.assertIn("db_url=" + self.apPipeArgs.db, cmdLineArgs) | ||
|
||
# Test the call to the AP pipeline | ||
id = _getDataIds(self.workspace.analysisButler)[0] | ||
apdbConfig = self.workspace.analysisButler.get("apdb_marker", id) | ||
self.assertEqual(apdbConfig.db_url, self.apPipeArgs.db) | ||
dbArgs = self._getArgs(mockDb.call_args) | ||
self.assertIn("db_url", dbArgs) | ||
self.assertEqual(dbArgs["db_url"], self.apPipeArgs.db) | ||
|
||
def testrunApPipeGen3Reuse(self): | ||
"""Test that runApPipeGen3 does not run the pipeline at all (not even with | ||
|