Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch: add flag to control verbosity in batch script #10

Merged
merged 1 commit into from
Jan 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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