Commit e6560aac authored by laochailan's avatar laochailan

make loadl utility react to bad returncodes

and disable python backtraces because it mostly gets in the way of the user
parent 932dcf29
......@@ -6,6 +6,8 @@ import subprocess
from loadleveller import jobfile
import os
sys.excepthook = lambda exception_type, exception, traceback: print(f'{exception_type.__name__}: {exception}')
parser = argparse.ArgumentParser(description='Helper script for running and managing loadleveller Monte Carlo jobs.', usage='''loadl <command> <jobscript> [<args>]
<jobscript> is an executable that prints the job parameter JSON-file to stdout. It is convenient to use the taskmaker python module for this purpose.
......@@ -73,7 +75,7 @@ def run():
if args_run.single:
cmd = '{} single "{}"'.format(job.jobconfig['mc_binary'], job_input_filename)
print('$ '+cmd)
subprocess.run(cmd, shell=True)
result = subprocess.run(cmd, shell=True, check=True)
else:
clusterutils.run(job.jobname, job.jobconfig, [job.jobconfig['mc_binary'], job_input_filename])
......
import tempfile
import os
import sys
import subprocess
batchscript_claix18 = '''#!/usr/bin/env zsh
......@@ -74,7 +75,7 @@ def run(jobname, jobconfig, cmd):
if sysinfo == 'local':
mpicmd = '{} -n {} {}'.format(jobconfig.get('mpirun', 'mpirun'), jobconfig['num_cores'], ' '.join(cmd))
print('$ '+mpicmd)
os.system(mpicmd)
subprocess.run(mpicmd, shell=True, check=True)
else:
with tempfile.NamedTemporaryFile(mode='w',delete=False) as f:
batchscript = generate_batchscript(sysinfo, cmd, jobname, jobconfig)
......@@ -83,5 +84,6 @@ def run(jobname, jobconfig, cmd):
bscriptname = f.name
mpicmd = batch_commands[sysinfo].format(batchscript=bscriptname)
print('$ '+mpicmd)
os.system(mpicmd)
result = subprocess.run(mpicmd, shell=True)
os.unlink(f.name)
result.check_returncode()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment