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

28 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-01 11:40 +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 "--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=None, 

85 dest="cpus", 

86 help="cores / cpus per glidein", 

87 type=int, 

88 required=True, 

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="normal", 

104 dest="qos", 

105 help="Slurm qos or 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 "-v", "--verbose", action="store_true", dest="verbose", help="verbose" 

153 ) 

154 parser.add_argument( 

155 "-r", 

156 "--reservation", 

157 action="store", 

158 dest="reservation", 

159 default=None, 

160 help="target a particular Slurm reservation", 

161 ) 

162 parser.add_argument( 

163 "-d", 

164 "--dynamic", 

165 const="__default__", 

166 nargs="?", 

167 action="store", 

168 dest="dynamic", 

169 type=str, 

170 default="__default__", 

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

172 ) 

173 

174 self.args = parser.parse_args() 

175 

176 return self.args 

177 

178 def getArgs(self): 

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

180 are initialized. 

181 

182 Returns 

183 ------- 

184 args: `list` 

185 remaining command line arguments 

186 """ 

187 return self.args 

188 

189 def getPlatform(self): 

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

191 the command line. 

192 

193 Returns 

194 ------- 

195 platform: `str` 

196 the name of the "platform" 

197 """ 

198 return self.args.platform