Skip to content

Commit 2f0b45e

Browse files
alexbarreramr-c
authored andcommitted
Avoid parse already parsed Workflows
When cwltool tries to update a workflow that includes more than once the same subworkflow an exception is raised. This is a product of the updating procedure where workflows are passed by reference in the document. Once a workflow has been updated, it should not be processed again.
1 parent 2971fce commit 2f0b45e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cwltool/update.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ def _draft3toDraft4dev1(doc, loader, baseuri):
349349
# type: (Any, Loader, Text) -> Any
350350
if isinstance(doc, dict):
351351
if "class" in doc and doc["class"] == "Workflow":
352+
if 'parsed' in doc:
353+
del doc['parsed']
354+
return doc
355+
352356
def fixup(f): # type: (Text) -> Text
353357
doc, frg = urllib.parse.urldefrag(f)
354358
frg = '/'.join(frg.rsplit('.', 1))
@@ -370,6 +374,7 @@ def fixup(f): # type: (Text) -> Text
370374
step["scatter"] = [fixup(s) for s in aslist(step["scatter"])]
371375
for out in doc["outputs"]:
372376
out["source"] = fixup(out["source"])
377+
doc['parsed']=True
373378
for key, value in doc.items():
374379
doc[key] = _draft3toDraft4dev1(value, loader, baseuri)
375380
elif isinstance(doc, list):
@@ -389,11 +394,15 @@ def _draft4Dev1toDev2(doc, loader, baseuri):
389394
# type: (Any, Loader, Text) -> Any
390395
if isinstance(doc, dict):
391396
if "class" in doc and doc["class"] == "Workflow":
397+
if 'parsed' in doc:
398+
del doc['parsed']
399+
return doc
392400
for out in doc["outputs"]:
393401
out["outputSource"] = out["source"]
394402
del out["source"]
395403
for key, value in doc.items():
396404
doc[key] = _draft4Dev1toDev2(value, loader, baseuri)
405+
doc['parsed']=True
397406
elif isinstance(doc, list):
398407
for i, a in enumerate(doc):
399408
doc[i] = _draft4Dev1toDev2(a, loader, baseuri)

0 commit comments

Comments
 (0)