X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/364dafeaac5e6d02583d4329738050842d2550b4..e2b3ed63a292537ec7bf37a904ad2925d6afa0bf:/sdk/cwl/arvados_cwl/done.py diff --git a/sdk/cwl/arvados_cwl/done.py b/sdk/cwl/arvados_cwl/done.py index 6d46e79cb8..e12fe185a0 100644 --- a/sdk/cwl/arvados_cwl/done.py +++ b/sdk/cwl/arvados_cwl/done.py @@ -2,6 +2,8 @@ # # SPDX-License-Identifier: Apache-2.0 +from future.utils import viewvalues + import re from cwltool.errors import WorkflowException from collections import deque @@ -50,7 +52,7 @@ def done(self, record, tmpdir, outdir, keepdir): def done_outputs(self, record, tmpdir, outdir, keepdir): self.builder.outdir = outdir self.builder.pathmapper.keepdir = keepdir - return self.collect_outputs("keep:" + record["output"]) + return self.collect_outputs("keep:" + record["output"], record["exit_code"]) crunchstat_re = re.compile(r"^\d{4}-\d\d-\d\d_\d\d:\d\d:\d\d [a-z0-9]{5}-8i9sb-[a-z0-9]{15} \d+ \d+ stderr crunchstat:") timestamp_re = re.compile(r"^(\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d+Z) (.*)") @@ -63,12 +65,12 @@ def logtail(logcollection, logfunc, header, maxlen=25): containersapi = ("crunch-run.txt" in logcollection) mergelogs = {} - for log in logcollection.keys(): + for log in list(logcollection): if not containersapi or log in ("crunch-run.txt", "stdout.txt", "stderr.txt"): logname = log[:-4] logt = deque([], maxlen) mergelogs[logname] = logt - with logcollection.open(log) as f: + with logcollection.open(log, encoding="utf-8") as f: for l in f: if containersapi: g = timestamp_re.match(l) @@ -77,7 +79,7 @@ def logtail(logcollection, logfunc, header, maxlen=25): logt.append(l) if containersapi: - keys = mergelogs.keys() + keys = list(mergelogs) loglines = [] while True: earliest = None @@ -91,7 +93,7 @@ def logtail(logcollection, logfunc, header, maxlen=25): loglines.append("%s %s %s" % (ts, earliest, msg)) loglines = loglines[-maxlen:] else: - loglines = mergelogs.values()[0] + loglines = mergelogs[list(mergelogs)[0]] logtxt = "\n ".join(l.strip() for l in loglines) logfunc("%s\n\n %s", header, logtxt)