Skip to content

Commit 327dd43

Browse files
authored
Add ids to tools embedded in 'run' fields. (#354)
1 parent eba1d64 commit 327dd43

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

cwltool/load_tool.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ def _convert_stdstreams_to_files(workflowobj):
108108
for entry in workflowobj:
109109
_convert_stdstreams_to_files(entry)
110110

111+
def _add_blank_ids(workflowobj):
112+
# type: (Union[Dict[Text, Any], List[Dict[Text, Any]]]) -> None
113+
114+
if isinstance(workflowobj, dict):
115+
if ("run" in workflowobj and
116+
isinstance(workflowobj["run"], dict) and
117+
"id" not in workflowobj["run"] and
118+
"$import" not in workflowobj["run"]):
119+
workflowobj["run"]["id"] = Text(uuid.uuid4())
120+
for entry in itervalues(workflowobj):
121+
_add_blank_ids(entry)
122+
if isinstance(workflowobj, list):
123+
for entry in workflowobj:
124+
_add_blank_ids(entry)
111125

112126
def validate_document(document_loader, # type: Loader
113127
workflowobj, # type: CommentedMap
@@ -166,6 +180,8 @@ def validate_document(document_loader, # type: Loader
166180
idx=document_loader.idx, cache=sch_document_loader.cache,
167181
fetcher_constructor=fetcher_constructor)
168182

183+
_add_blank_ids(workflowobj)
184+
169185
workflowobj["id"] = fileuri
170186
processobj, metadata = document_loader.resolve_all(workflowobj, fileuri)
171187
if not isinstance(processobj, (CommentedMap, CommentedSeq)):

0 commit comments

Comments
 (0)