LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | List of all members
lsst.ctrl.pool.parallel.BatchArgumentParser Class Reference
Inheritance diagram for lsst.ctrl.pool.parallel.BatchArgumentParser:

Public Member Functions

def __init__ (self, parent=None, *args, **kwargs)
 
def parse_args (self, config=None, args=None, namespace=None, **kwargs)
 
def makeBatch (self, args)
 
def format_help (self)
 
def format_usage (self)
 

Detailed Description

An argument parser to get relevant parameters for batch submission

We want to be able to display the help for a 'parent' ArgumentParser
along with the batch-specific options we introduce in this class, but
we don't want to swallow the parent (i.e., ArgumentParser(parents=[parent]))
because we want to save the list of arguments that this particular
BatchArgumentParser doesn't parse, so they can be passed on to a different
program (though we also want to parse them to check that they can be parsed).

Definition at line 298 of file parallel.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.ctrl.pool.parallel.BatchArgumentParser.__init__ (   self,
  parent = None,
args,
**  kwargs 
)

Definition at line 309 of file parallel.py.

309  def __init__(self, parent=None, *args, **kwargs):
310  super(BatchArgumentParser, self).__init__(*args, **kwargs)
311  self._parent = parent
312  group = self.add_argument_group("Batch submission options")
313  group.add_argument("--queue", help="Queue name")
314  group.add_argument("--job", help="Job name")
315  group.add_argument("--nodes", type=int, default=0, help="Number of nodes")
316  group.add_argument("--procs", type=int, default=0, help="Number of processors per node")
317  group.add_argument("--cores", type=int, default=0, help="Number of cores (Slurm/SMP only)")
318  group.add_argument("--time", type=float, default=0,
319  help="Expected execution time per element (sec)")
320  group.add_argument("--walltime", type=float, default=0,
321  help="Expected total execution walltime (sec); overrides cores & time")
322  group.add_argument("--batch-type", dest="batchType", choices=list(BATCH_TYPES.keys()), default="smp",
323  help="Batch system to use")
324  group.add_argument("--batch-verbose", dest="batchVerbose", action="store_true", default=False,
325  help=("Enable verbose output in batch script "
326  "(including system environment information at batch start)?"))
327  group.add_argument("--batch-output", dest="batchOutput", help="Output directory")
328  group.add_argument("--batch-submit", dest="batchSubmit", help="Batch submission command-line flags")
329  group.add_argument("--batch-options", dest="batchOptions", help="Header options for batch script")
330  group.add_argument("--batch-profile", dest="batchProfile", action="store_true", default=False,
331  help="Enable profiling on batch job?")
332  group.add_argument("--batch-stats", dest="batchStats", action="store_true", default=False,
333  help="Print process stats on completion (Linux only)?")
334  group.add_argument("--dry-run", dest="dryrun", default=False, action="store_true",
335  help="Dry run?")
336  group.add_argument("--do-exec", dest="doExec", default=False, action="store_true",
337  help="Exec script instead of submit to batch system?")
338  group.add_argument("--mpiexec", default="", help="mpiexec options")
339 
daf::base::PropertyList * list
Definition: fits.cc:913

Member Function Documentation

◆ format_help()

def lsst.ctrl.pool.parallel.BatchArgumentParser.format_help (   self)

Definition at line 378 of file parallel.py.

378  def format_help(self):
379  text = """This is a script for queue submission of a wrapped script.
380 
381 Use this program name and ignore that for the wrapped script (it will be
382 passed on to the batch system). Arguments for *both* this wrapper script or the
383 wrapped script are valid (if it is required for the wrapped script, it
384 is required for the wrapper as well).
385 
386 *** Batch system submission wrapper:
387 
388 """
389  text += super(BatchArgumentParser, self).format_help()
390  if self._parent is not None:
391  text += """
392 
393 *** Wrapped script:
394 
395 """
396  text += self._parent.format_help()
397  return text
398 

◆ format_usage()

def lsst.ctrl.pool.parallel.BatchArgumentParser.format_usage (   self)

Definition at line 399 of file parallel.py.

399  def format_usage(self):
400  if self._parent is not None:
401  prog = self._parent.prog
402  self._parent.prog = self.prog
403  usage = self._parent.format_usage()
404  self._parent.prog = prog
405  return usage
406  return super(BatchArgumentParser, self).format_usage()
407 
408 

◆ makeBatch()

def lsst.ctrl.pool.parallel.BatchArgumentParser.makeBatch (   self,
  args 
)
Create a Batch object from the command-line arguments

Definition at line 353 of file parallel.py.

353  def makeBatch(self, args):
354  """Create a Batch object from the command-line arguments"""
355  # argMapping is a dict that maps Batch init kwarg names to parsed arguments attribute *names*
356  argMapping = {'outputDir': 'batchOutput',
357  'numNodes': 'nodes',
358  'numProcsPerNode': 'procs',
359  'numCores': 'cores',
360  'walltime': 'time',
361  'queue': 'queue',
362  'jobName': 'job',
363  'dryrun': 'dryrun',
364  'doExec': 'doExec',
365  'mpiexec': 'mpiexec',
366  'submit': 'batchSubmit',
367  'options': 'batchOptions',
368  'verbose': 'batchVerbose',
369  }
370 
371  if BATCH_TYPES[args.batchType] is None:
372  return None
373 
374  # kwargs is a dict that maps Batch init kwarg names to parsed arguments attribute *values*
375  kwargs = {k: getattr(args, v) for k, v in argMapping.items()}
376  return BATCH_TYPES[args.batchType](**kwargs)
377 

◆ parse_args()

def lsst.ctrl.pool.parallel.BatchArgumentParser.parse_args (   self,
  config = None,
  args = None,
  namespace = None,
**  kwargs 
)

Definition at line 340 of file parallel.py.

340  def parse_args(self, config=None, args=None, namespace=None, **kwargs):
341  args, leftover = super(BatchArgumentParser, self).parse_known_args(args=args, namespace=namespace)
342  args.parent = None
343  args.leftover = None
344  if len(leftover) > 0:
345  # Save any leftovers for the parent
346  if self._parent is None:
347  self.error("Unrecognised arguments: %s" % leftover)
348  args.parent = self._parent.parse_args(config, args=leftover, **kwargs)
349  args.leftover = leftover
350  args.batch = self.makeBatch(args)
351  return args
352 

The documentation for this class was generated from the following file: