X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9bc524ae6d516f1be41cc8a7c6a76a96bbd9578c..a605fc29fd7f79b2882625c99a72e998157fa5bc:/sdk/cwl/arvados_cwl/runner.py diff --git a/sdk/cwl/arvados_cwl/runner.py b/sdk/cwl/arvados_cwl/runner.py index cf2f1db997..e5b4e006e8 100644 --- a/sdk/cwl/arvados_cwl/runner.py +++ b/sdk/cwl/arvados_cwl/runner.py @@ -21,7 +21,22 @@ from .pathmapper import ArvPathMapper logger = logging.getLogger('arvados.cwl-runner') -cwltool.draft2tool.ACCEPTLIST_RE = re.compile(r"^[a-zA-Z0-9._+-]+$") +cwltool.draft2tool.ACCEPTLIST_RE = re.compile(r".*") + +def trim_listing(obj): + """Remove 'listing' field from Directory objects that are keep references. + + When Directory objects represent Keep references, it redundant and + potentially very expensive to pass fully enumerated Directory objects + between instances of cwl-runner (e.g. a submitting a job, or using the + RunInSingleContainer feature), so delete the 'listing' field when it is + safe to do so. + """ + + if obj.get("location", "").startswith("keep:") and "listing" in obj: + del obj["listing"] + if obj.get("location", "").startswith("_:"): + del obj["location"] def upload_dependencies(arvrunner, name, document_loader, workflowobj, uri, loadref_run): @@ -80,8 +95,8 @@ def upload_dependencies(arvrunner, name, document_loader, name=name) def setloc(p): - if not p["location"].startswith("_:") and not p["location"].startswith("keep:"): - p["location"] = mapper.mapper(p["location"]).target + if "location" in p and (not p["location"].startswith("_:")) and (not p["location"].startswith("keep:")): + p["location"] = mapper.mapper(p["location"]).resolved adjustFileObjs(workflowobj, setloc) adjustDirObjs(workflowobj, setloc) @@ -99,13 +114,15 @@ def upload_docker(arvrunner, tool): class Runner(object): - def __init__(self, runner, tool, job_order, enable_reuse): + def __init__(self, runner, tool, job_order, enable_reuse, output_name): self.arvrunner = runner self.tool = tool self.job_order = job_order self.running = False self.enable_reuse = enable_reuse self.uuid = None + self.final_output = None + self.output_name = output_name def update_pipeline_component(self, record): pass @@ -129,6 +146,8 @@ class Runner(object): self.job_order.get("id", "#"), False) + adjustDirObjs(self.job_order, trim_listing) + if "id" in self.job_order: del self.job_order["id"] @@ -152,7 +171,11 @@ class Runner(object): outputs = None try: try: - outc = arvados.collection.Collection(record["output"]) + self.final_output = record["output"] + outc = arvados.collection.CollectionReader(self.final_output, + api_client=self.arvrunner.api, + keep_client=self.arvrunner.keep_client, + num_retries=self.arvrunner.num_retries) with outc.open("cwl.output.json") as f: outputs = json.load(f) def keepify(fileobj):