X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f1943e92b2c83d2884eeaa2829f1b4a07d23b9ee..25107815e9da9483bb7e6055379420113bfc3640:/sdk/cwl/arvados_cwl/executor.py diff --git a/sdk/cwl/arvados_cwl/executor.py b/sdk/cwl/arvados_cwl/executor.py index c1f2b54744..eeb44dbd7f 100644 --- a/sdk/cwl/arvados_cwl/executor.py +++ b/sdk/cwl/arvados_cwl/executor.py @@ -59,6 +59,7 @@ class RuntimeStatusLoggingHandler(logging.Handler): def __init__(self, runtime_status_update_func): super(RuntimeStatusLoggingHandler, self).__init__() self.runtime_status_update = runtime_status_update_func + self.updatingRuntimeStatus = False def emit(self, record): kind = None @@ -66,22 +67,27 @@ class RuntimeStatusLoggingHandler(logging.Handler): kind = 'error' elif record.levelno >= logging.WARNING: kind = 'warning' - if kind is not None: - log_msg = record.getMessage() - if '\n' in log_msg: - # If the logged message is multi-line, use its first line as status - # and the rest as detail. - status, detail = log_msg.split('\n', 1) - self.runtime_status_update( - kind, - "%s: %s" % (record.name, status), - detail - ) - else: - self.runtime_status_update( - kind, - "%s: %s" % (record.name, record.getMessage()) - ) + if kind is not None and self.updatingRuntimeStatus is not True: + self.updatingRuntimeStatus = True + try: + log_msg = record.getMessage() + if '\n' in log_msg: + # If the logged message is multi-line, use its first line as status + # and the rest as detail. + status, detail = log_msg.split('\n', 1) + self.runtime_status_update( + kind, + "%s: %s" % (record.name, status), + detail + ) + else: + self.runtime_status_update( + kind, + "%s: %s" % (record.name, record.getMessage()) + ) + finally: + self.updatingRuntimeStatus = False + class ArvCwlExecutor(object): """Execute a CWL tool or workflow, submit work (using either jobs or @@ -436,17 +442,16 @@ http://doc.arvados.org/install/install-api-server.html#disable_api_methods num_retries=self.num_retries) for k,v in generatemapper.items(): - if k.startswith("_:"): - if v.type == "Directory": + if v.type == "Directory" and v.resolved.startswith("_:"): continue - if v.type == "CreateFile": - with final.open(v.target, "wb") as f: - f.write(v.resolved.encode("utf-8")) + if v.type == "CreateFile" and (k.startswith("_:") or v.resolved.startswith("_:")): + with final.open(v.target, "wb") as f: + f.write(v.resolved.encode("utf-8")) continue - if not k.startswith("keep:"): + if not v.resolved.startswith("keep:"): raise Exception("Output source is not in keep or a literal") - sp = k.split("/") + sp = v.resolved.split("/") srccollection = sp[0][5:] try: reader = self.collection_cache.get(srccollection) @@ -456,7 +461,8 @@ http://doc.arvados.org/install/install-api-server.html#disable_api_methods logger.error("Creating CollectionReader for '%s' '%s': %s", k, v, e) raise except IOError as e: - logger.warning("While preparing output collection: %s", e) + logger.error("While preparing output collection: %s", e) + raise def rewrite(fileobj): fileobj["location"] = generatemapper.mapper(fileobj["location"]).target @@ -469,7 +475,7 @@ http://doc.arvados.org/install/install-api-server.html#disable_api_methods with final.open("cwl.output.json", "w") as f: res = str(json.dumps(outputObj, sort_keys=True, indent=4, separators=(',',': '), ensure_ascii=False)) - f.write(res) + f.write(res) final.save_new(name=name, owner_uuid=self.project_uuid, storage_classes=storage_classes, ensure_unique_name=True)