Coverage for python/lsst/ctrl/execute/allocatorParser.py: 17%
35 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-10-11 01:45 -0700
« prev ^ index » next coverage.py v7.10.6, created at 2025-10-11 01:45 -0700
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 = {}
44 self.args = self.parseArgs(basename)
46 def parseArgs(self, basename) -> argparse.Namespace:
47 """Parse command line, and test for required arguments
49 Parameters
50 ----------
51 argv: `list`
52 list of strings containing the command line arguments
54 Returns
55 -------
56 The parser options and remaining arguments
57 """
59 parser = argparse.ArgumentParser(prog=basename)
60 parser.add_argument("platform", type=str, default="s3df", help="node allocation platform")
61 parser.add_argument(
62 "--auto",
63 action="store_true",
64 dest="auto",
65 help="use automatic detection of jobs to determine glide-ins",
66 )
67 parser.add_argument(
68 "-n",
69 "--node-count",
70 action="store",
71 default=None,
72 dest="nodeCount",
73 help="number of glideins to submit; these are chunks of a node, size the number of cores/cpus",
74 type=int,
75 required=True,
76 )
77 parser.add_argument(
78 "-c",
79 "--cpus",
80 action="store",
81 default=16,
82 dest="cpus",
83 help="cores / cpus per glidein",
84 type=int,
85 required=False,
86 )
87 parser.add_argument(
88 "-a",
89 "--account",
90 action="store",
91 default="rubin:developers",
92 dest="account",
93 help="Slurm account for glidein job",
94 type=str,
95 )
96 parser.add_argument(
97 "--collector",
98 action="store",
99 default=None,
100 dest="collector",
101 help="machine name of nondefault htcondor collector",
102 type=str,
103 required=False,
104 )
105 parser.add_argument(
106 "--collector-port",
107 action="store",
108 default=9618,
109 dest="collectorport",
110 help="port used for nondefault htcondor collector",
111 type=int,
112 required=False,
113 )
114 parser.add_argument(
115 "-s",
116 "--qos",
117 action="store",
118 default=None,
119 dest="qos",
120 help="Slurm qos for glidein job",
121 type=str,
122 )
123 parser.add_argument(
124 "-m",
125 "--maximum-wall-clock",
126 action="store",
127 dest="maximumWallClock",
128 default=None,
129 help="maximum wall clock time; e.g., 3600, 10:00:00, 6-00:00:00, etc",
130 type=str,
131 required=True,
132 )
133 parser.add_argument(
134 "-q",
135 "--queue",
136 action="store",
137 dest="queue",
138 default="roma,milano",
139 help="queue / partition name",
140 )
141 parser.add_argument(
142 "-O",
143 "--output-log",
144 action="store",
145 dest="outputLog",
146 default=None,
147 help="Output log filename; this option for PBS, unused with Slurm",
148 )
149 parser.add_argument(
150 "-E",
151 "--error-log",
152 action="store",
153 dest="errorLog",
154 default=None,
155 help="Error log filename; this option for PBS, unused with Slurm",
156 )
157 parser.add_argument(
158 "-g",
159 "--glidein-shutdown",
160 action="store",
161 dest="glideinShutdown",
162 type=int,
163 default=None,
164 help="glide-in inactivity shutdown time in seconds",
165 )
166 parser.add_argument(
167 "--openfiles",
168 action="store",
169 dest="openfiles",
170 type=int,
171 default=20480,
172 help="set the limit on number of open files (fd) per process",
173 )
174 parser.add_argument(
175 "-p",
176 "--pack",
177 action="store_true",
178 dest="packnodes",
179 help="encourage nodes to pack jobs rather than spread",
180 )
181 parser.add_argument(
182 "--exclude",
183 action="store",
184 default=None,
185 dest="exclude",
186 help="machine name(s) to exclude Slurm jobs from",
187 type=str,
188 required=False,
189 )
190 parser.add_argument(
191 "--nodelist",
192 action="store",
193 default=None,
194 dest="nodelist",
195 help="machine name(s) to target Slurm jobs toward",
196 type=str,
197 required=False,
198 )
199 parser.add_argument(
200 "--exclusive",
201 action="store_true",
202 dest="exclusive",
203 default=None,
204 help="glidein will be an exclusive batch job; the glidein will be "
205 "the only job on the node, and have all available cores, memory."
206 "Settings for the number of cores -c are ignored, overridden.",
207 )
208 parser.add_argument(
209 "--exclusive-user",
210 action="store_true",
211 dest="exclusiveUser",
212 default=None,
213 help="glidein will be an exclusive to the user batch job; only "
214 " other jobs of the same user will share the node with the glidein",
215 )
216 parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", help="verbose")
217 parser.add_argument(
218 "-r",
219 "--reservation",
220 action="store",
221 dest="reservation",
222 default=None,
223 help="target a particular Slurm reservation",
224 )
225 parser.add_argument(
226 "-d",
227 "--dynamic",
228 const="__default__",
229 nargs="?",
230 action="store",
231 dest="dynamic",
232 type=str,
233 default="__default__",
234 help="configure to use dynamic/partitionable slot; legacy option: this is always enabled now",
235 )
237 self.args = parser.parse_args()
239 return self.args
241 def getArgs(self):
242 """Accessor method to get arguments left after standard parsed options
243 are initialized.
245 Returns
246 -------
247 args: `argparse.Namespace`
248 remaining command line arguments
249 """
250 return self.args
252 def getPlatform(self):
253 """Accessor method to retrieve the "platform" that was specified on
254 the command line.
256 Returns
257 -------
258 platform: `str`
259 the name of the "platform"
260 """
261 return self.args.platform