Skip to content

Commit

Permalink
Batch: add flag to control verbosity in batch script
Browse files Browse the repository at this point in the history
This can be triggered with the "--batch-verbose" command-line
argument from the BatchArgumentParser. The default is now to
have minimal verbosity in the batch script.
  • Loading branch information
PaulPrice committed Jan 23, 2017
1 parent da8fc50 commit 376ba1c
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions python/lsst/ctrl/pool/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class Batch(object):
"""Base class for batch submission"""

def __init__(self, outputDir=None, numNodes=0, numProcsPerNode=0, numCores=0, queue=None, jobName=None,
walltime=None, dryrun=False, doExec=False, mpiexec="", submit=None, options=None):
walltime=None, dryrun=False, doExec=False, mpiexec="", submit=None, options=None,
verbose=False):
"""!Constructor
@param outputDir: output directory, or None
Expand All @@ -87,6 +88,7 @@ def __init__(self, outputDir=None, numNodes=0, numProcsPerNode=0, numCores=0, qu
@param mpiexec: options for mpiexec
@param submit: command-line options for batch submission (e.g., for qsub, sbatch)
@param options: options to append to script header (e.g., #PBS or #SBATCH)
@param verbose: produce verbose output?
"""
if (numNodes <= 0 or numProcsPerNode <= 0) and numCores <= 0:
raise RuntimeError("Must specify numNodes+numProcs or numCores")
Expand All @@ -103,6 +105,7 @@ def __init__(self, outputDir=None, numNodes=0, numProcsPerNode=0, numCores=0, qu
self.mpiexec = mpiexec
self.submit = submit
self.options = options
self.verbose = verbose

def shebang(self):
return "#!/bin/bash"
Expand All @@ -116,20 +119,24 @@ def preamble(self, command, walltime=None):

def execution(self, command):
"""Return execution string for script to be submitted"""
return "\n".join([exportEnv(),
"date",
"echo \"mpiexec is at: $(which mpiexec)\"",
"ulimit -a",
"umask %03o" % UMASK,
"echo 'umask: ' $(umask)",
"eups list -s",
"export",
"cd %s" % pipes.quote(os.getcwd()),
"date",
"mpiexec %s %s" % (self.mpiexec, command),
"date",
"echo Done.",
])
script = [exportEnv(),
"umask %03o" % UMASK,
"cd %s" % pipes.quote(os.getcwd()),
]
if self.verbose:
script += ["echo \"mpiexec is at: $(which mpiexec)\"",
"ulimit -a",
"echo 'umask: ' $(umask)",
"eups list -s",
"export",
"date",
]
script += ["mpiexec %s %s" % (self.mpiexec, command)]
if self.verbose:
script += ["date",
"echo Done.",
]
return "\n".join(script)

def createScript(self, command, walltime=None):
"""!Create script to be submitted
Expand Down Expand Up @@ -295,6 +302,9 @@ def __init__(self, parent=None, *args, **kwargs):
help="Expected execution time per element (sec)")
group.add_argument("--batch-type", dest="batchType", choices=list(BATCH_TYPES.keys()), default="smp",
help="Batch system to use")
group.add_argument("--batch-verbose", dest="batchVerbose", action="store_true", default=False,
help=("Enable verbose output in batch script "
"(including system environment information at batch start)?"))
group.add_argument("--batch-output", dest="batchOutput", help="Output directory")
group.add_argument("--batch-submit", dest="batchSubmit", help="Batch submission command-line flags")
group.add_argument("--batch-options", dest="batchOptions", help="Header options for batch script")
Expand Down Expand Up @@ -336,6 +346,7 @@ def makeBatch(self, args):
'mpiexec': 'mpiexec',
'submit': 'batchSubmit',
'options': 'batchOptions',
'verbose': 'batchVerbose',
}

if BATCH_TYPES[args.batchType] is None:
Expand Down

0 comments on commit 376ba1c

Please sign in to comment.