LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
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: