Skip to content

Commit

Permalink
Add ids to tools embedded in 'run' fields. (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
tetron authored Mar 29, 2017
1 parent eba1d64 commit 327dd43
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cwltool/load_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ def _convert_stdstreams_to_files(workflowobj):
for entry in workflowobj:
_convert_stdstreams_to_files(entry)

def _add_blank_ids(workflowobj):
# type: (Union[Dict[Text, Any], List[Dict[Text, Any]]]) -> None

if isinstance(workflowobj, dict):
if ("run" in workflowobj and
isinstance(workflowobj["run"], dict) and
"id" not in workflowobj["run"] and
"$import" not in workflowobj["run"]):
workflowobj["run"]["id"] = Text(uuid.uuid4())
for entry in itervalues(workflowobj):
_add_blank_ids(entry)
if isinstance(workflowobj, list):
for entry in workflowobj:
_add_blank_ids(entry)

def validate_document(document_loader, # type: Loader
workflowobj, # type: CommentedMap
Expand Down Expand Up @@ -166,6 +180,8 @@ def validate_document(document_loader, # type: Loader
idx=document_loader.idx, cache=sch_document_loader.cache,
fetcher_constructor=fetcher_constructor)

_add_blank_ids(workflowobj)

workflowobj["id"] = fileuri
processobj, metadata = document_loader.resolve_all(workflowobj, fileuri)
if not isinstance(processobj, (CommentedMap, CommentedSeq)):
Expand Down

0 comments on commit 327dd43

Please sign in to comment.