Skip to content

Commit 3b267e8

Browse files
alexbarreramr-c
authored andcommitted
Deepcopy imported workflows to avoid re-parsing conflict
1 parent 2f0b45e commit 3b267e8

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

cwltool/update.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import traceback
66
from typing import (Any, Callable, Dict, Text, # pylint: disable=unused-import
77
Tuple, Union)
8+
from copy import deepcopy
89

910
import six
1011
from six.moves import urllib
@@ -349,9 +350,6 @@ def _draft3toDraft4dev1(doc, loader, baseuri):
349350
# type: (Any, Loader, Text) -> Any
350351
if isinstance(doc, dict):
351352
if "class" in doc and doc["class"] == "Workflow":
352-
if 'parsed' in doc:
353-
del doc['parsed']
354-
return doc
355353

356354
def fixup(f): # type: (Text) -> Text
357355
doc, frg = urllib.parse.urldefrag(f)
@@ -374,8 +372,9 @@ def fixup(f): # type: (Text) -> Text
374372
step["scatter"] = [fixup(s) for s in aslist(step["scatter"])]
375373
for out in doc["outputs"]:
376374
out["source"] = fixup(out["source"])
377-
doc['parsed']=True
378375
for key, value in doc.items():
376+
if key == 'run':
377+
value = deepcopy(value)
379378
doc[key] = _draft3toDraft4dev1(value, loader, baseuri)
380379
elif isinstance(doc, list):
381380
for i, a in enumerate(doc):
@@ -394,15 +393,13 @@ def _draft4Dev1toDev2(doc, loader, baseuri):
394393
# type: (Any, Loader, Text) -> Any
395394
if isinstance(doc, dict):
396395
if "class" in doc and doc["class"] == "Workflow":
397-
if 'parsed' in doc:
398-
del doc['parsed']
399-
return doc
400396
for out in doc["outputs"]:
401397
out["outputSource"] = out["source"]
402398
del out["source"]
403399
for key, value in doc.items():
400+
if key == 'run':
401+
value = deepcopy(value)
404402
doc[key] = _draft4Dev1toDev2(value, loader, baseuri)
405-
doc['parsed']=True
406403
elif isinstance(doc, list):
407404
for i, a in enumerate(doc):
408405
doc[i] = _draft4Dev1toDev2(a, loader, baseuri)

0 commit comments

Comments
 (0)