X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f6e2ed9520af6a1184160a2008ed13d3b0f2f76f..ec0278bcf9affbbe9f88c413116f6aaa2713e0f6:/crunch_scripts/run-command diff --git a/crunch_scripts/run-command b/crunch_scripts/run-command index 528baab4c1..6335523a74 100755 --- a/crunch_scripts/run-command +++ b/crunch_scripts/run-command @@ -50,24 +50,41 @@ try: stdoutname = subst.do_substitution(p, p["stdout"]) stdoutfile = open(stdoutname, "wb") - print("Running command: {}{}".format(' '.join(cmd), (" > " + stdoutname) if stdoutname != None else "")) + print("run-command: {}{}".format(' '.join(cmd), (" > " + stdoutname) if stdoutname != None else "")) rcode = subprocess.call(cmd, stdout=stdoutfile) + print("run-command: completed with exit code %i" % rcode) + except Exception as e: - print("Caught exception {}".format(e)) + print("run-command: caught exception: {}".format(e)) finally: for l in links: os.unlink(l) + print("run-command: the follow output files will be saved to keep:") + + subprocess.call(["find", ".", "-type", "f", "-printf", "run-command: %12.12s %h/%f\\n"]) + + print("run-command: start writing output to keep") + out = arvados.CollectionWriter() out.write_directory_tree(".", max_manifest_depth=0) - arvados.current_task().set_output(out.finish()) + outuuid = out.finish() + arvados.api('v1').job_tasks().update(uuid=arvados.current_task()['uuid'], + body={ + 'output':outuuid, + 'success': (rcode == 0), + 'progress':1.0 + }).execute() if rcode == 0: os.chdir("..") shutil.rmtree("tmpdir") shutil.rmtree("output") + print("run-command: success") +else: + print("run-command: failed") sys.exit(rcode)