12409: Fix packing bug in cwltool, bump dependency on cwltool
authorPeter Amstutz <peter.amstutz@curii.com>
Thu, 12 Mar 2020 19:06:09 +0000 (15:06 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Thu, 12 Mar 2020 19:06:09 +0000 (15:06 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

sdk/cwl/arvados_cwl/arvworkflow.py
sdk/cwl/setup.py

index 332dcb60708fc55b05c2d37732f4fa2eace97b3c..ba60333648eabdb4d308503b3e8ac20b88ad34e1 100644 (file)
@@ -186,40 +186,16 @@ class ArvadosWorkflow(Workflow):
                                 False)
 
             if self.wf_pdh is None:
-                ### We have to reload the document to get the original version.
-                #
-                # The workflow document we have in memory right now was
-                # updated to the internal CWL version.  We need to reload the
-                # document to go back to its original version, because the
-                # version of cwltool installed in the user's container is
-                # likely to reject our internal version, and we don't want to
-                # break existing workflows.
-                #
-                # What's going on here is that the updater replaces the
-                # documents/fragments in the index with updated ones, the
-                # index is also used as a cache, so we need to go through the
-                # loading process with an empty index and updating turned off
-                # so we have the original un-updated documents.
-                #
-                loadingContext = self.loadingContext.copy()
-                loadingContext.do_update = False
-                document_loader = schema_salad.ref_resolver.SubLoader(loadingContext.loader)
-                loadingContext.loader = document_loader
-                loadingContext.loader.idx = {}
-                uri = self.tool["id"]
-                loadingContext, workflowobj, uri = fetch_document(uri, loadingContext)
-                loadingContext, uri = resolve_and_validate_document(
-                    loadingContext, workflowobj, uri
-                )
-                workflowobj, metadata = loadingContext.loader.resolve_ref(uri)
-                ###
-
-                workflowobj["requirements"] = dedup_reqs(self.requirements)
-                workflowobj["hints"] = dedup_reqs(self.hints)
-
-                packed = pack(document_loader, workflowobj, uri, metadata)
+                packed = pack(self.doc_loader, self.tool, self.tool["id"], self.metadata)
+
+                for p in packed["$graph"]:
+                    if p["id"] == "#main":
+                        p["requirements"] = dedup_reqs(self.requirements)
+                        p["hints"] = dedup_reqs(self.hints)
 
                 def visit(item):
+                    if "requirements" in item:
+                        item["requirements"] = [i for i in item["requirements"] if i["class"] != "DockerRequirement"]
                     for t in ("hints", "requirements"):
                         if t not in item:
                             continue
@@ -239,9 +215,6 @@ class ArvadosWorkflow(Workflow):
                                                     raise WorkflowException("Non-top-level ResourceRequirement in single container cannot have expressions")
                                 if not dyn:
                                     self.static_resource_req.append(req)
-                            if req["class"] == "DockerRequirement":
-                                if "http://arvados.org/cwl#dockerCollectionPDH" in req:
-                                    del req["http://arvados.org/cwl#dockerCollectionPDH"]
 
                 visit_class(packed["$graph"], ("Workflow", "CommandLineTool"), visit)
 
@@ -250,9 +223,9 @@ class ArvadosWorkflow(Workflow):
 
                 upload_dependencies(self.arvrunner,
                                     runtimeContext.name,
-                                    document_loader,
+                                    self.doc_loader,
                                     packed,
-                                    uri,
+                                    self.tool["id"],
                                     False)
 
                 # Discover files/directories referenced by the
@@ -329,6 +302,10 @@ class ArvadosWorkflow(Workflow):
             if job_res_reqs[0].get("ramMin", 1024) < 128:
                 job_res_reqs[0]["ramMin"] = 128
 
+        arguments = ["--no-container", "--move-outputs", "--preserve-entire-environment", "workflow.cwl", "cwl.input.yml"]
+        if runtimeContext.debug:
+            arguments.insert(0, '--debug')
+
         wf_runner = cmap({
             "class": "CommandLineTool",
             "baseCommand": "cwltool",
@@ -348,7 +325,7 @@ class ArvadosWorkflow(Workflow):
                     }]
             }],
             "hints": self.hints,
-            "arguments": ["--no-container", "--move-outputs", "--preserve-entire-environment", "workflow.cwl#main", "cwl.input.yml"],
+            "arguments": arguments,
             "id": "#"
         })
         return ArvadosCommandTool(self.arvrunner, wf_runner, self.loadingContext).job(joborder_resolved, output_callback, runtimeContext)
index 5475848786c9aeca90b00dc19599e410c8703e7b..5a359d22cda67be2e5bc1212e8536acb49a8f825 100644 (file)
@@ -39,7 +39,7 @@ setup(name='arvados-cwl-runner',
       # file to determine what version of cwltool and schema-salad to
       # build.
       install_requires=[
-          'cwltool==2.0.20200303141624',
+          'cwltool==2.0.20200312183052',
           'schema-salad==5.0.20200302192450',
           'arvados-python-client{}'.format(pysdk_dep),
           'setuptools',