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

29 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-05-01 04:03 -0700

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

66 action="store_true", 

67 dest="auto", 

68 help="use automatic detection of jobs to determine glide-ins", 

69 ) 

70 parser.add_argument( 

71 "-n", 

72 "--node-count", 

73 action="store", 

74 default=None, 

75 dest="nodeCount", 

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

77 type=int, 

78 required=True, 

79 ) 

80 parser.add_argument( 

81 "-c", 

82 "--cpus", 

83 action="store", 

84 default=16, 

85 dest="cpus", 

86 help="cores / cpus per glidein", 

87 type=int, 

88 required=False, 

89 ) 

90 parser.add_argument( 

91 "-a", 

92 "--account", 

93 action="store", 

94 default="rubin:developers", 

95 dest="account", 

96 help="Slurm account for glidein job", 

97 type=str, 

98 ) 

99 parser.add_argument( 

100 "-s", 

101 "--qos", 

102 action="store", 

103 default=None, 

104 dest="qos", 

105 help="Slurm qos for glidein job", 

106 type=str, 

107 ) 

108 parser.add_argument( 

109 "-m", 

110 "--maximum-wall-clock", 

111 action="store", 

112 dest="maximumWallClock", 

113 default=None, 

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

115 type=str, 

116 required=True, 

117 ) 

118 parser.add_argument( 

119 "-q", 

120 "--queue", 

121 action="store", 

122 dest="queue", 

123 default="roma,milano", 

124 help="queue / partition name", 

125 ) 

126 parser.add_argument( 

127 "-O", 

128 "--output-log", 

129 action="store", 

130 dest="outputLog", 

131 default=None, 

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

133 ) 

134 parser.add_argument( 

135 "-E", 

136 "--error-log", 

137 action="store", 

138 dest="errorLog", 

139 default=None, 

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

141 ) 

142 parser.add_argument( 

143 "-g", 

144 "--glidein-shutdown", 

145 action="store", 

146 dest="glideinShutdown", 

147 type=int, 

148 default=None, 

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

150 ) 

151 parser.add_argument( 

152 "-p", 

153 "--pack", 

154 action="store_true", 

155 dest="packnodes", 

156 help="encourage nodes to pack jobs rather than spread", 

157 ) 

158 parser.add_argument( 

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

160 ) 

161 parser.add_argument( 

162 "-r", 

163 "--reservation", 

164 action="store", 

165 dest="reservation", 

166 default=None, 

167 help="target a particular Slurm reservation", 

168 ) 

169 parser.add_argument( 

170 "-d", 

171 "--dynamic", 

172 const="__default__", 

173 nargs="?", 

174 action="store", 

175 dest="dynamic", 

176 type=str, 

177 default="__default__", 

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

179 ) 

180 

181 self.args = parser.parse_args() 

182 

183 return self.args 

184 

185 def getArgs(self): 

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

187 are initialized. 

188 

189 Returns 

190 ------- 

191 args: `list` 

192 remaining command line arguments 

193 """ 

194 return self.args 

195 

196 def getPlatform(self): 

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

198 the command line. 

199 

200 Returns 

201 ------- 

202 platform: `str` 

203 the name of the "platform" 

204 """ 

205 return self.args.platform