Skip to content

Commit 358e927

Browse files
authored
Fix up command line generation, get rid of do_eval and use valueFrom correctly. (#150)
1 parent d4287d7 commit 358e927

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

cwltool/builder.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ def bind_input(self, schema, datum, lead_pos=[], tail_pos=[]):
4646
else:
4747
binding["position"] = aslist(lead_pos) + [0] + aslist(tail_pos)
4848

49-
if "valueFrom" in binding and "do_eval" not in binding:
50-
binding["do_eval"] = binding["valueFrom"]
51-
binding["valueFrom"] = datum
49+
binding["datum"] = datum
5250

5351
# Handle union types
5452
if isinstance(schema["type"], list):
@@ -66,7 +64,7 @@ def bind_input(self, schema, datum, lead_pos=[], tail_pos=[]):
6664
raise validate.ValidationException(u"'%s' is not a valid union %s" % (datum, schema["type"]))
6765
elif isinstance(schema["type"], dict):
6866
st = copy.deepcopy(schema["type"])
69-
if binding and "inputBinding" not in st and "itemSeparator" not in binding and st["type"] in ("array", "map"):
67+
if binding and "inputBinding" not in st and st["type"] == "array" and "itemSeparator" not in binding:
7068
st["inputBinding"] = {}
7169
bindings.extend(self.bind_input(st, datum, lead_pos=lead_pos, tail_pos=tail_pos))
7270
else:
@@ -80,22 +78,12 @@ def bind_input(self, schema, datum, lead_pos=[], tail_pos=[]):
8078
else:
8179
datum[f["name"]] = f.get("default")
8280

83-
if schema["type"] == "map":
84-
for n, item in datum.items():
85-
b2 = None
86-
if binding:
87-
b2 = copy.deepcopy(binding)
88-
b2["valueFrom"] = [n, item]
89-
bindings.extend(self.bind_input({"type": schema["values"], "inputBinding": b2},
90-
item, lead_pos=n, tail_pos=tail_pos))
91-
binding = None
92-
9381
if schema["type"] == "array":
9482
for n, item in enumerate(datum):
9583
b2 = None
9684
if binding:
9785
b2 = copy.deepcopy(binding)
98-
b2["valueFrom"] = item
86+
b2["datum"] = item
9987
bindings.extend(self.bind_input({"type": schema["items"], "inputBinding": b2},
10088
item, lead_pos=n, tail_pos=tail_pos))
10189
binding = None
@@ -152,9 +140,9 @@ def tostr(self, value): # type: (Any) -> str
152140
return str(value)
153141

154142
def generate_arg(self, binding): # type: (Dict[str,Any]) -> List[str]
155-
value = binding["valueFrom"]
156-
if "do_eval" in binding:
157-
value = self.do_eval(binding["do_eval"], context=value)
143+
value = binding.get("datum")
144+
if "valueFrom" in binding:
145+
value = self.do_eval(binding["valueFrom"], context=value)
158146

159147
prefix = binding.get("prefix")
160148
sep = binding.get("separate", True)
@@ -163,7 +151,7 @@ def generate_arg(self, binding): # type: (Dict[str,Any]) -> List[str]
163151
if isinstance(value, list):
164152
if binding.get("itemSeparator"):
165153
l = [binding["itemSeparator"].join([self.tostr(v) for v in value])]
166-
elif binding.get("do_eval"):
154+
elif binding.get("valueFrom"):
167155
value = [v["path"] if isinstance(v, dict) and v.get("class") == "File" else v for v in value]
168156
return ([prefix] if prefix else []) + value
169157
elif prefix:

cwltool/process.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def _init_job(self, joborder, **kwargs):
442442
for n, b in enumerate(aslist(self.tool["baseCommand"])):
443443
builder.bindings.append({
444444
"position": [-1000000, n],
445-
"valueFrom": b
445+
"datum": b
446446
})
447447

448448
if self.tool.get("arguments"):
@@ -453,19 +453,16 @@ def _init_job(self, joborder, **kwargs):
453453
a["position"] = [a["position"], i]
454454
else:
455455
a["position"] = [0, i]
456-
a["do_eval"] = a["valueFrom"]
457-
a["valueFrom"] = None
458456
builder.bindings.append(a)
459457
elif ("$(" in a) or ("${" in a):
460458
builder.bindings.append({
461459
"position": [0, i],
462-
"do_eval": a,
463-
"valueFrom": None
460+
"valueFrom": a
464461
})
465462
else:
466463
builder.bindings.append({
467464
"position": [0, i],
468-
"valueFrom": a
465+
"datum": a
469466
})
470467

471468
builder.bindings.sort(key=lambda a: a["position"])

0 commit comments

Comments
 (0)