X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0eb72b526bf8bbb011551ecf019f604e17a534f1..2feec8cbac7ef28a47f3c3a9d071b070ef38cb6e:/sdk/cwl/arvados_cwl/runner.py?ds=sidebyside diff --git a/sdk/cwl/arvados_cwl/runner.py b/sdk/cwl/arvados_cwl/runner.py index 683f548c48..087fed3e16 100644 --- a/sdk/cwl/arvados_cwl/runner.py +++ b/sdk/cwl/arvados_cwl/runner.py @@ -18,7 +18,7 @@ from cwltool.draft2tool import CommandLineTool import cwltool.workflow from cwltool.process import get_feature, scandeps, UnsupportedRequirement, normalizeFilesDirs, shortname from cwltool.load_tool import fetch_document -from cwltool.pathmapper import adjustFileObjs, adjustDirObjs +from cwltool.pathmapper import adjustFileObjs, adjustDirObjs, visit_class from cwltool.utils import aslist from cwltool.builder import substitute from cwltool.pack import pack @@ -46,6 +46,17 @@ def trim_anonymous_location(obj): if obj.get("location", "").startswith("_:"): del obj["location"] +def find_defaults(d, op): + if isinstance(d, list): + for i in d: + find_defaults(i, op) + elif isinstance(d, dict): + if "default" in d: + op(d) + else: + for i in d.itervalues(): + find_defaults(i, op) + def upload_dependencies(arvrunner, name, document_loader, workflowobj, uri, loadref_run, include_primary=True): """Upload the dependencies of the workflowobj document to Keep. @@ -101,6 +112,23 @@ def upload_dependencies(arvrunner, name, document_loader, for s in workflowobj["$schemas"]: sc.append({"class": "File", "location": s}) + def capture_default(obj): + remove = [False] + def add_default(f): + if "location" not in f and "path" in f: + f["location"] = f["path"] + del f["path"] + if "location" in f and not arvrunner.fs_access.exists(f["location"]): + # Remove from sc + sc[:] = [x for x in sc if x["location"] != f["location"]] + # Delete "default" from workflowobj + remove[0] = True + visit_class(obj["default"], ("File", "Directory"), add_default) + if remove[0]: + del obj["default"] + + find_defaults(workflowobj, capture_default) + mapper = ArvPathMapper(arvrunner, sc, "", "keep:%s", "keep:%s/%s",