Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cwltool/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ def get_feature(self, feature): # type: (Any, Any) -> Tuple[Any, bool]
if t["class"] == feature:
return (t, False)
return (None, None)

class HashableDict(dict):
def __hash__(self):
return hash(tuple(sorted(self.items())))
25 changes: 16 additions & 9 deletions cwltool/workflow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from . import job
from . import draft2tool
from .utils import aslist
from .utils import aslist, HashableDict
from .process import Process, get_feature, empty_subtree, shortname, uniquename
from .errors import WorkflowException
import copy
Expand Down Expand Up @@ -88,21 +88,28 @@ def match_types(sinktype, src, iid, inputobj, linkMerge, valueFrom):
return True
return False


def are_same_type(src, sink): # type: (Any, Any) -> bool
"""Check for identical type specifications, ignoring extra keys like inputBinding.
"""
if isinstance(src, dict) and isinstance(sink, dict):
if src["type"] == "array" and sink["type"] == "array":
if 'null' in sink["items"]:
return are_same_type([src["items"]], [it for it in sink["items"] if it != 'null'])
return are_same_type(src["items"], sink["items"])
elif src["type"] == sink["type"]:
return True
src_items = src["items"]
sink_items = sink["items"]
if not isinstance(src_items, list):
src_items = [src_items]
if not isinstance(sink_items, list):
sink_items = [sink_items]
src_items = [HashableDict(s) if isinstance(s, dict) else s for s in src_items]
sink_items = [HashableDict(s) if isinstance(s, dict) else s for s in sink_items]
return are_same_type(src_items, sink_items)
else:
return False
return src["type"] == sink["type"]
else:
return src == sink

try:
return src == sink or len(set(src).intersection(set(sink))) > 0
except TypeError:
return False

def object_from_state(state, parms, frag_only, supportsMultipleInput):
# type: (Dict[str,WorkflowStateItem], List[Dict[str, Any]], bool, bool) -> Dict[str, str]
Expand Down