Skip to content

Commit 65203c7

Browse files
authored
Only pass formal params (#765)
* Only pass formal parameters to workflow step. Parameters which are connected to the workflow step but do not correspond to a parameter of the tool run by the step should not appear in the input object. * Add static checker warning for connections that don't correspond to tool input parameter.
1 parent e6e3140 commit 65203c7

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

cwltool/checker.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def can_assign_src_to_sink(src, sink, strict=False): # type: (Any, Any, bool) -
6767
if src == "Any" or sink == "Any":
6868
return True
6969
if isinstance(src, dict) and isinstance(sink, dict):
70+
if sink.get("not_connected") and strict:
71+
return False
7072
if src["type"] == "array" and sink["type"] == "array":
7173
return can_assign_src_to_sink(src["items"], sink["items"], strict)
7274
elif src["type"] == "record" and sink["type"] == "record":
@@ -127,8 +129,8 @@ def _rec_fields(rec): # type: (Dict[Text, Any]) -> Dict[Text, Any]
127129
return False
128130
return True
129131

130-
def static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs):
131-
# type: (List[Dict[Text, Any]], List[Dict[Text, Any]], List[Dict[Text, Any]], List[Dict[Text, Any]]) -> None
132+
def static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs, param_to_step):
133+
# type: (List[Dict[Text, Any]], List[Dict[Text, Any]], List[Dict[Text, Any]], List[Dict[Text, Any]], Dict[Text, Dict[Text, Any]]) -> None
132134
"""Check if all source and sink types of a workflow are compatible before run time.
133135
"""
134136

@@ -165,6 +167,13 @@ def static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs)
165167
"source '%s' does not include secondaryFiles." % (shortname(src["id"])))
166168
msg4 = SourceLine(src, "id").makeError("To fix, add secondaryFiles: %s to definition of '%s'." % (sink.get("secondaryFiles"), shortname(src["id"])))
167169
msg = SourceLine(sink).makeError("%s\n%s" % (msg1, bullets([msg2, msg3, msg4], " ")))
170+
elif sink.get("not_connected"):
171+
msg = SourceLine(sink, "type").makeError(
172+
"'%s' is not an input parameter of %s, expected %s"
173+
% (shortname(sink["id"]), param_to_step[sink["id"]]["run"],
174+
", ".join(shortname(s["id"])
175+
for s in param_to_step[sink["id"]]["inputs"]
176+
if not s.get("not_connected"))))
168177
else:
169178
msg = SourceLine(src, "type").makeError(
170179
"Source '%s' of type %s may be incompatible"

cwltool/workflow.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,15 @@ def __init__(self, toolpath_object, **kwargs):
446446

447447
step_inputs = [] # type: List[Any]
448448
step_outputs = [] # type: List[Any]
449+
param_to_step = {} # type: Dict[Text, Dict[Text, Any]]
449450
for step in self.steps:
450451
step_inputs.extend(step.tool["inputs"])
451452
step_outputs.extend(step.tool["outputs"])
453+
for s in step.tool["inputs"]:
454+
param_to_step[s["id"]] = step.tool
452455

453456
if kwargs.get("do_validate", True):
454-
static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs)
457+
static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs, param_to_step)
455458

456459

457460
def job(self,
@@ -539,6 +542,7 @@ def __init__(self, toolpath_object, pos, **kwargs):
539542
if not found:
540543
if stepfield == "in":
541544
param["type"] = "Any"
545+
param["not_connected"] = True
542546
else:
543547
validation_errors.append(
544548
SourceLine(self.tool["out"], n).makeError(
@@ -629,7 +633,8 @@ def job(self,
629633
for i in self.tool["inputs"]:
630634
p = i["id"]
631635
field = shortname(p)
632-
job_order[field] = job_order[i["id"]]
636+
if not i.get("not_connected"):
637+
job_order[field] = job_order[i["id"]]
633638
del job_order[i["id"]]
634639

635640
try:

0 commit comments

Comments
 (0)