Skip to content

Commit

Permalink
Merge pull request #25 from beckermr/beckermr-patch-1
Browse files Browse the repository at this point in the history
BUG use exit codes for remote machines
  • Loading branch information
beckermr authored Sep 11, 2022
2 parents e30e36f + 5c6995a commit 1dd234c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mattspy/condor_yield.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
mkdir -p $(dirname $3)
touch $3
mattspy-exec-run-pickled-task $1 $2 $3 &> $3
mattspy-exec-run-pickled-task $1 $2 $3 1 &> $3
"""


Expand Down
2 changes: 1 addition & 1 deletion mattspy/lsf_yield.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
mkdir -p $(dirname {output})
mkdir -p $(dirname {logfile})
mattspy-exec-run-pickled-task {input} {output} {logfile}
mattspy-exec-run-pickled-task {input} {output} {logfile} 1
rm -rf /scratch/$LSB_JOBID
"""
Expand Down
12 changes: 12 additions & 0 deletions mattspy/mattspy_exec_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ def run_pickled_task():
input_file = sys.argv[1]
output_file = sys.argv[2]
logfile = sys.argv[3]
if len(sys.argv) > 4:
use_exit_code = True if sys.argv[4] == "1" else False
else:
use_exit_code = False
errored = False

try:
with open(input_file, "rb") as fp:
Expand All @@ -16,9 +21,16 @@ def run_pickled_task():
try:
res = rd[0](*rd[1], **rd[2])
except Exception as e:
errored = True
res = e

joblib.dump(res, output_file)
finally:
if not os.path.exists(output_file):
joblib.dump(RuntimeError("job failed - see %s" % logfile), output_file)
errored = True

if errored and use_exit_code:
sys.exit(-1)
else:
sys.exit(0)

0 comments on commit 1dd234c

Please sign in to comment.