X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d43dce642a9681a33a5259f5bde05c8d3f3b690e..08123387faf00b0af64ea01f7196d8c5ca3fae1e:/sdk/cwl/arvados_cwl/done.py diff --git a/sdk/cwl/arvados_cwl/done.py b/sdk/cwl/arvados_cwl/done.py index 48466f00c2..9b26ad7064 100644 --- a/sdk/cwl/arvados_cwl/done.py +++ b/sdk/cwl/arvados_cwl/done.py @@ -1,3 +1,9 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +from future.utils import viewvalues + import re from cwltool.errors import WorkflowException from collections import deque @@ -51,16 +57,15 @@ def done_outputs(self, record, tmpdir, outdir, keepdir): 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) (.*)") -def logtail(logcollection, logger, header, maxlen=25): +def logtail(logcollection, logfunc, header, maxlen=25): if len(logcollection) == 0: - logger.info(header) - logger.info(" ** log is empty **") + logfunc("%s\n%s", header, " ** log is empty **") return 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) @@ -74,7 +79,7 @@ def logtail(logcollection, logger, header, maxlen=25): logt.append(l) if containersapi: - keys = mergelogs.keys() + keys = list(mergelogs) loglines = [] while True: earliest = None @@ -88,8 +93,7 @@ def logtail(logcollection, logger, 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) - logger.info(header) - logger.info("\n %s", logtxt) + logfunc("%s\n\n %s", header, logtxt)