Coverage for python/lsst/ctrl/execute/allocatorParser.py : 22%

Hot-keys 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 AllocatorParser:
29 """An argument parser for node allocation requests.
31 Parameters
32 ----------
33 basename : `str`
34 The name used to identify the running program
35 """
37 def __init__(self, basename):
38 """Construct an AllocatorParser
39 @param argv: list containing the command line arguments
40 @return: the parser options and remaining arguments
41 """
43 self.defaults = {}
45 self.args = []
47 self.args = self.parseArgs(basename)
49 def parseArgs(self, basename):
50 """Parse command line, and test for required arguments
52 Parameters
53 ----------
54 argv: `list`
55 list of strings containing the command line arguments
57 Returns
58 -------
59 The parser options and remaining arguments
60 """
62 parser = argparse.ArgumentParser(prog=basename)
63 parser.add_argument("platform", help="node allocation platform")
64 parser.add_argument("-n", "--node-count", action="store", default=None,
65 dest="nodeCount", help="number of nodes to use", type=int, required=True)
66 parser.add_argument("-c", "--cpus", action="store", default=None, dest="cpus",
67 help="cpus per node (WAS '-s' (--slots) option)", type=int, required=True)
68 parser.add_argument("-m", "--maximum-wall-clock", action="store", dest="maximumWallClock",
69 default=None, help="maximum wall clock time", type=str, required=True)
70 parser.add_argument("-N", "--node-set", action="store",
71 dest="nodeSet", default=None, help="node set name")
72 parser.add_argument("-q", "--queue", action="store", dest="queue",
73 default="debug", help="queue name")
74 parser.add_argument("-e", "--email", action="store_true", dest="email",
75 default=None, help="email notification flag")
76 parser.add_argument("-O", "--output-log", action="store", dest="outputLog",
77 default=None, help="Output log filename")
78 parser.add_argument("-E", "--error-log", action="store", dest="errorLog",
79 default=None, help="Error log filename")
80 parser.add_argument("-g", "--glidein-shutdown", action="store", dest="glideinShutdown",
81 type=int, default=None, help="glide-in inactivity shutdown time in seconds")
82 parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", help="verbose")
83 parser.add_argument("-r", "--reservation", action="store", dest="reservation",
84 default=None, help="run id")
85 parser.add_argument("-d", "--dynamic", const='__default__', nargs='?', action="store",
86 dest="dynamic", type=str, default=None, help="configure to use dynamic slots")
88 self.args = parser.parse_args()
90 return self.args
92 def getArgs(self):
93 """Accessor method to get arguments left after standard parsed options
94 are initialized.
96 Returns
97 -------
98 args: `list`
99 remaining command line arguments
100 """
101 return self.args
103 def getPlatform(self):
104 """Accessor method to retrieve the "platform" that was specified on
105 the command line.
107 Returns
108 -------
109 platform: `str`
110 the name of the "platform"
111 """
112 return self.args.platform