Coverage for python/lsst/ctrl/execute/runOrcaParser.py: 12%
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python
3#
4# LSST Data Management System
5# Copyright 2008-2016 LSST Corporation.
6#
7# This product includes software developed by the
8# LSST Project (http://www.lsst.org/).
9#
10# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the LSST License Statement and
21# the GNU General Public License along with this program. If not,
22# see <http://www.lsstcorp.org/LegalNotices/>.
23#
25import argparse
28class RunOrcaParser:
29 """An argument parser for the orchestration config file generation
30 and execution
31 """
33 def __init__(self, basename):
34 """Construct a RunOrcaParser
35 @param argv: list containing the command line arguments
36 @return: the parser options and remaining arguments
37 """
38 self.defaults = {}
40 self.args = []
42 self.args = self.parseArgs(basename)
44 def parseArgs(self, basename):
45 """Parse command line, and test for required arguments
46 @param argv: list containing the command line arguments
47 @return: the parser options and remaining arguments
48 """
50 parser = argparse.ArgumentParser(prog=basename, usage="[-h] -p PLATFORM -e EUPSPATH \
51 ((-c COMMAND -i INPUTDATAFILE) | (-D DAGSCRIPT -I INPUTSCRIPT)) \
52 [-N NODESET] \
53 [-n IDSPERJOB] \
54 [-r DEFAULTROOT] \
55 [-l LOCALSCRATCH] \
56 [-d DATADIRECTORY] \
57 [-F FILESYSTEMDOMAIN] \
58 [-u USER_NAME] \
59 [-H USER_HOME] \
60 [-P PLATFORMCONFIG] \
61 [-R RUNID] \
62 [-v] [-s SETUP SETUP]")
63 parser.add_argument("-p", "--platform", action="store", dest="platform",
64 default=None, help="platform", required=True)
66 command_group = parser.add_argument_group("parallel command")
67 command_group.add_argument("-c", "--command", action="store", dest="command",
68 default=None, help="command")
69 command_group.add_argument("-i", "--id-file", action="store", dest="inputDataFile",
70 default=None, help="list of ids")
72 dag_group = parser.add_argument_group("dag script")
73 dag_group.add_argument("-D", "--dag-script", action="store", dest="dagscript",
74 default=None, help="dag script")
75 dag_group.add_argument("-I", "--input-script", action="store", dest="inputscript",
76 default=None, help="input script")
78 parser.add_argument("-e", "--eups-path", action="store", dest="eupsPath",
79 default=None, help="eups path", required=True)
80 parser.add_argument("-N", "--node-set", action="store",
81 default=None, dest="nodeSet",
82 help="name of collection of nodes to use (required by some platforms)",
83 required=False)
84 parser.add_argument("-n", "--ids-per-job", action="store",
85 default=None, dest="idsPerJob", help="ids per job")
86 parser.add_argument("-r", "--default-root", action="store", dest="defaultRoot",
87 default=None, help="remote working directory for Condor")
88 parser.add_argument("-l", "--local-scratch", action="store", dest="localScratch",
89 default=None, help="local staging directory for Condor")
90 parser.add_argument("-d", "--data-directory", action="store", dest="dataDirectory",
91 default=None, help="where the data is located")
93 parser.add_argument("-F", "--file-system-domain", action="store", dest="fileSystemDomain",
94 default=None, help="file system domain")
95 parser.add_argument("-u", "--user-name", action="store", dest="user_name", default=None, help="user")
96 parser.add_argument("-H", "--user-home", action="store", dest="user_home", default=None, help="home")
97 parser.add_argument("-R", "--run-id", action="store", dest="runid", default=None, help="run id")
98 parser.add_argument("-v", "--verbose", action="store_true", dest="verbose",
99 default=False, help="verbose")
100 parser.add_argument("-s", "--setup", action="append", nargs=2, help="setup")
101 parser.add_argument("-P", "--platformconfig", action="store", dest="platformConfig",
102 default=None, help="platform configuration file")
104 args = parser.parse_args()
106 if args.dagscript is None:
107 if args.command is None or args.inputDataFile is None:
108 parser.print_help()
109 parser.exit()
110 return args
112 def getArgs(self):
113 """Accessor method to get options set on initialization
114 @return opts: command line options
115 """
116 return self.args