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-11698: Let ap_verify support multiple --dataIdString arguments #60

Merged
merged 3 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/lsst.ap.verify/command-line-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Required arguments are :option:`--dataset` and :option:`--output`.

Specify data ID to process using data ID syntax.
For example, ``--id "visit=12345 ccd=1 filter=g"``.
Multiple copies of this argument are allowed.
If this argument is omitted, then all data IDs in the dataset will be processed.

.. option:: --dataset <dataset_name>
Expand Down
7 changes: 4 additions & 3 deletions python/lsst/ap/verify/pipeline_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ApPipeParser(argparse.ArgumentParser):
def __init__(self):
# Help and documentation will be handled by main program's parser
argparse.ArgumentParser.__init__(self, add_help=False)
self.add_argument('--id', dest='dataId', default="",
self.add_argument('--id', dest='dataIds', action='append', default=[],
help='An identifier for the data to process.')
self.add_argument("-j", "--processes", default=1, type=int,
help="Number of processes to use.")
Expand Down Expand Up @@ -74,8 +74,9 @@ def runApPipe(workspace, parsedCmdLine):
"--calib", workspace.calibRepo,
"--template", workspace.templateRepo]
args.extend(_getConfigArguments(workspace))
if parsedCmdLine.dataId:
args.extend(["--id", *parsedCmdLine.dataId.split(" ")])
if parsedCmdLine.dataIds:
kfindeisen marked this conversation as resolved.
Show resolved Hide resolved
for singleId in parsedCmdLine.dataIds:
args.extend(["--id", *singleId.split(" ")])
else:
args.extend(["--id"])
args.extend(["--processes", str(parsedCmdLine.processes)])
Expand Down
22 changes: 16 additions & 6 deletions tests/test_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,29 @@ def testMissingIngest(self):
def testMinimumMain(self):
"""Verify that a command line consisting only of required arguments parses correctly.
"""
args = '--dataset %s --output tests/output/foo --id "visit=54123"' % CommandLineTestSuite.datasetKey
args = '--dataset %s --output tests/output/foo' % CommandLineTestSuite.datasetKey
parsed = self._parseString(args)
self.assertIn('dataset', dir(parsed))
self.assertIn('output', dir(parsed))
self.assertIn('dataId', dir(parsed))
self.assertEqual(parsed.dataset.datasetRoot,
lsst.utils.getPackageDir(CommandLineTestSuite.testDataset))
self.assertEqual(parsed.output, "tests/output/foo")
self.assertEqual(parsed.dataIds, [])

def testMinimumIngest(self):
"""Verify that a command line consisting only of required arguments parses correctly.
"""
args = '--dataset %s --output tests/output/foo' % CommandLineTestSuite.datasetKey
parsed = self._parseString(args, ap_verify._IngestOnlyParser())
self.assertIn('dataset', dir(parsed))
self.assertIn('output', dir(parsed))
self.assertEqual(parsed.dataset.datasetRoot,
lsst.utils.getPackageDir(CommandLineTestSuite.testDataset))
self.assertEqual(parsed.output, "tests/output/foo")

def testDataId(self):
"""Verify that a command line consisting only of required arguments parses correctly.
"""
args = '--dataset %s --output tests/output/foo --id "visit=54123" --id "filter=x"' \
% CommandLineTestSuite.datasetKey
parsed = self._parseString(args)
self.assertEqual(parsed.dataIds, ["visit=54123", "filter=x"])

def testBadDataset(self):
"""Verify that a command line with an unregistered dataset is rejected.
Expand Down