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

25 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-10 10:16 +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 "-m", 

86 "--maximum-wall-clock", 

87 action="store", 

88 dest="maximumWallClock", 

89 default=None, 

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

91 type=str, 

92 required=True, 

93 ) 

94 parser.add_argument( 

95 "-q", 

96 "--queue", 

97 action="store", 

98 dest="queue", 

99 default="roma,milano", 

100 help="queue / partition name", 

101 ) 

102 parser.add_argument( 

103 "-O", 

104 "--output-log", 

105 action="store", 

106 dest="outputLog", 

107 default=None, 

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

109 ) 

110 parser.add_argument( 

111 "-E", 

112 "--error-log", 

113 action="store", 

114 dest="errorLog", 

115 default=None, 

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

117 ) 

118 parser.add_argument( 

119 "-g", 

120 "--glidein-shutdown", 

121 action="store", 

122 dest="glideinShutdown", 

123 type=int, 

124 default=None, 

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

126 ) 

127 parser.add_argument( 

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

129 ) 

130 parser.add_argument( 

131 "-r", 

132 "--reservation", 

133 action="store", 

134 dest="reservation", 

135 default=None, 

136 help="target a particular Slurm reservation", 

137 ) 

138 parser.add_argument( 

139 "-d", 

140 "--dynamic", 

141 const="__default__", 

142 nargs="?", 

143 action="store", 

144 dest="dynamic", 

145 type=str, 

146 default="__default__", 

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

148 ) 

149 

150 self.args = parser.parse_args() 

151 

152 return self.args 

153 

154 def getArgs(self): 

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

156 are initialized. 

157 

158 Returns 

159 ------- 

160 args: `list` 

161 remaining command line arguments 

162 """ 

163 return self.args 

164 

165 def getPlatform(self): 

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

167 the command line. 

168 

169 Returns 

170 ------- 

171 platform: `str` 

172 the name of the "platform" 

173 """ 

174 return self.args.platform