- ### 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.loadingContext, self.tool["id"], loader=self.doc_loader)
+
+ for p in packed["$graph"]:
+ if p["id"] == "#main":
+ p["requirements"] = dedup_reqs(self.requirements)
+ p["hints"] = dedup_reqs(self.hints)