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

27 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-10-12 09:45 +0000

1#!/usr/bin/env python 

2 

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# 

24 

25import argparse 

26 

27 

28class AllocatorParser: 

29 """An argument parser for node allocation requests. 

30 

31 Parameters 

32 ---------- 

33 basename : `str` 

34 The name used to identify the running program 

35 """ 

36 

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 """ 

42 

43 self.defaults = {} 

44 

45 self.args = [] 

46 

47 self.args = self.parseArgs(basename) 

48 

49 def parseArgs(self, basename): 

50 """Parse command line, and test for required arguments 

51 

52 Parameters 

53 ---------- 

54 argv: `list` 

55 list of strings containing the command line arguments 

56 

57 Returns 

58 ------- 

59 The parser options and remaining arguments 

60 """ 

61 

62 parser = argparse.ArgumentParser(prog=basename) 

63 parser.add_argument("platform", help="node allocation platform") 

64 parser.add_argument( 

65 "-n", 

66 "--node-count", 

67 action="store", 

68 default=None, 

69 dest="nodeCount", 

70 help="number of glideins to submit; these are chunks of a node, size the number of cores/cpus", 

71 type=int, 

72 required=True, 

73 ) 

74 parser.add_argument( 

75 "-c", 

76 "--cpus", 

77 action="store", 

78 default=None, 

79 dest="cpus", 

80 help="cores / cpus per glidein", 

81 type=int, 

82 required=True, 

83 ) 

84 parser.add_argument( 

85 "-a", 

86 "--account", 

87 action="store", 

88 default="rubin:developers", 

89 dest="account", 

90 help="Slurm account for glidein job", 

91 type=str, 

92 ) 

93 parser.add_argument( 

94 "-s", 

95 "--qos", 

96 action="store", 

97 default="normal", 

98 dest="qos", 

99 help="Slurm qos or glidein job", 

100 type=str, 

101 ) 

102 parser.add_argument( 

103 "-m", 

104 "--maximum-wall-clock", 

105 action="store", 

106 dest="maximumWallClock", 

107 default=None, 

108 help="maximum wall clock time; e.g., 3600, 10:00:00, 6-00:00:00, etc", 

109 type=str, 

110 required=True, 

111 ) 

112 parser.add_argument( 

113 "-q", 

114 "--queue", 

115 action="store", 

116 dest="queue", 

117 default="roma,milano", 

118 help="queue / partition name", 

119 ) 

120 parser.add_argument( 

121 "-O", 

122 "--output-log", 

123 action="store", 

124 dest="outputLog", 

125 default=None, 

126 help="Output log filename; this option for PBS, unused with Slurm", 

127 ) 

128 parser.add_argument( 

129 "-E", 

130 "--error-log", 

131 action="store", 

132 dest="errorLog", 

133 default=None, 

134 help="Error log filename; this option for PBS, unused with Slurm", 

135 ) 

136 parser.add_argument( 

137 "-g", 

138 "--glidein-shutdown", 

139 action="store", 

140 dest="glideinShutdown", 

141 type=int, 

142 default=None, 

143 help="glide-in inactivity shutdown time in seconds", 

144 ) 

145 parser.add_argument( 

146 "-v", "--verbose", action="store_true", dest="verbose", help="verbose" 

147 ) 

148 parser.add_argument( 

149 "-r", 

150 "--reservation", 

151 action="store", 

152 dest="reservation", 

153 default=None, 

154 help="target a particular Slurm reservation", 

155 ) 

156 parser.add_argument( 

157 "-d", 

158 "--dynamic", 

159 const="__default__", 

160 nargs="?", 

161 action="store", 

162 dest="dynamic", 

163 type=str, 

164 default="__default__", 

165 help="configure to use dynamic/partitionable slot; legacy option: this is always enabled now", 

166 ) 

167 

168 self.args = parser.parse_args() 

169 

170 return self.args 

171 

172 def getArgs(self): 

173 """Accessor method to get arguments left after standard parsed options 

174 are initialized. 

175 

176 Returns 

177 ------- 

178 args: `list` 

179 remaining command line arguments 

180 """ 

181 return self.args 

182 

183 def getPlatform(self): 

184 """Accessor method to retrieve the "platform" that was specified on 

185 the command line. 

186 

187 Returns 

188 ------- 

189 platform: `str` 

190 the name of the "platform" 

191 """ 

192 return self.args.platform