Commit 3e2eb975 authored by Wout De Nolf's avatar Wout De Nolf
Browse files

ppfmethod: rename "return_value" by "ppfdict"

parent a2c90326
......@@ -74,7 +74,7 @@ class DecodeRouterActor(RouterActor):
def _extractPersistentValue(self, inData):
if self.is_ppfmethod:
uhash = inData["return_value"]
uhash = inData["ppfdict"]
else:
if self.itemName in inData:
uhash = inData[self.itemName]
......@@ -94,7 +94,7 @@ class DecodeRouterActor(RouterActor):
def _extractValue(self, inData):
if self.is_ppfmethod:
inData = inData["return_value"]
inData = inData["ppfdict"]
if self.itemName in inData:
value = inData[self.itemName]
if value in self.dictValues:
......
......@@ -27,9 +27,7 @@ def workflow1():
}
expected_results = {
"Python Actor Test": {
"return_value": {"name": "myname", "reply": "Hello myname!"}
}
"Python Actor Test": {"ppfdict": {"name": "myname", "reply": "Hello myname!"}}
}
return graph, expected_results
......
......@@ -47,7 +47,7 @@ def workflow10(inputs):
limit = inputs["limit"]
expected_result = {
"return_value": {"doContinue": "false", "limit": limit, "value": limit}
"ppfdict": {"doContinue": "false", "limit": limit, "value": limit}
}
return graph, expected_result
......
......@@ -139,16 +139,16 @@ def workflow11():
}
expected_results = {
"addtask1": {"return_value": {"value": 2}},
("submodel11b", "in11b"): {"return_value": {"value": 2}},
("submodel11b", "addtask2ba"): {"return_value": {"value": 3}},
("submodel11b", ("submodel11a", "in11a")): {"return_value": {"value": 3}},
("submodel11b", ("submodel11a", "addtask2aa")): {"return_value": {"value": 4}},
("submodel11b", ("submodel11a", "addtask2ab")): {"return_value": {"value": 5}},
("submodel11b", ("submodel11a", "out11a")): {"return_value": {"value": 5}},
("submodel11b", "addtask2bb"): {"return_value": {"value": 6}},
("submodel11b", "out11b"): {"return_value": {"value": 6}},
"addtask3": {"return_value": {"value": 7}},
"addtask1": {"ppfdict": {"value": 2}},
("submodel11b", "in11b"): {"ppfdict": {"value": 2}},
("submodel11b", "addtask2ba"): {"ppfdict": {"value": 3}},
("submodel11b", ("submodel11a", "in11a")): {"ppfdict": {"value": 3}},
("submodel11b", ("submodel11a", "addtask2aa")): {"ppfdict": {"value": 4}},
("submodel11b", ("submodel11a", "addtask2ab")): {"ppfdict": {"value": 5}},
("submodel11b", ("submodel11a", "out11a")): {"ppfdict": {"value": 5}},
("submodel11b", "addtask2bb"): {"ppfdict": {"value": 6}},
("submodel11b", "out11b"): {"ppfdict": {"value": 6}},
"addtask3": {"ppfdict": {"value": 7}},
}
return graph, expected_results
......
......@@ -89,20 +89,16 @@ def workflow12(startvalue, withsubmodel_startvalue):
value = startvalue
value += 1
expected_results = {"addtask1": {"return_value": {"value": value}}}
expected_results = {"addtask1": {"ppfdict": {"value": value}}}
if startvalue == withsubmodel_startvalue:
expected_results[("submodel12", "in")] = {"return_value": {"value": value}}
expected_results[("submodel12", "in")] = {"ppfdict": {"value": value}}
value += 1
expected_results[("submodel12", "addtask2a")] = {
"return_value": {"value": value}
}
expected_results[("submodel12", "addtask2a")] = {"ppfdict": {"value": value}}
value += 1
expected_results[("submodel12", "addtask2b")] = {
"return_value": {"value": value}
}
expected_results[("submodel12", "out")] = {"return_value": {"value": value}}
expected_results[("submodel12", "addtask2b")] = {"ppfdict": {"value": value}}
expected_results[("submodel12", "out")] = {"ppfdict": {"value": value}}
value += 1
expected_results["addtask2"] = {"return_value": {"value": value}}
expected_results["addtask2"] = {"ppfdict": {"value": value}}
return graph, expected_results
......
......@@ -88,14 +88,14 @@ def workflow13(startvalue, withlastnode_startvalue):
}
expected_results = {
"addtask1": {"return_value": {"value": startvalue + 1}},
("submodel13", "in"): {"return_value": {"value": startvalue + 1}},
("submodel13", "addtask2a"): {"return_value": {"value": startvalue + 2}},
("submodel13", "addtask2b"): {"return_value": {"value": startvalue + 3}},
("submodel13", "out"): {"return_value": {"value": startvalue + 3}},
"addtask1": {"ppfdict": {"value": startvalue + 1}},
("submodel13", "in"): {"ppfdict": {"value": startvalue + 1}},
("submodel13", "addtask2a"): {"ppfdict": {"value": startvalue + 2}},
("submodel13", "addtask2b"): {"ppfdict": {"value": startvalue + 3}},
("submodel13", "out"): {"ppfdict": {"value": startvalue + 3}},
}
if startvalue == withlastnode_startvalue:
expected_results["addtask2"] = {"return_value": {"value": startvalue + 4}}
expected_results["addtask2"] = {"ppfdict": {"value": startvalue + 4}}
return graph, expected_results
......
......@@ -129,14 +129,14 @@ def workflow14():
}
expected_results = {
"addtask1": {"return_value": {"value": 2}},
("submodel14b", "In"): {"return_value": {"value": 2}},
("submodel14b", ("submodel14a", "In")): {"return_value": {"value": 2}},
("submodel14b", ("submodel14a", "addtask2aa")): {"return_value": {"value": 3}},
("submodel14b", ("submodel14a", "addtask2ab")): {"return_value": {"value": 4}},
("submodel14b", ("submodel14a", "Out")): {"return_value": {"value": 4}},
("submodel14b", "Out"): {"return_value": {"value": 4}},
"addtask3": {"return_value": {"value": 5}},
"addtask1": {"ppfdict": {"value": 2}},
("submodel14b", "In"): {"ppfdict": {"value": 2}},
("submodel14b", ("submodel14a", "In")): {"ppfdict": {"value": 2}},
("submodel14b", ("submodel14a", "addtask2aa")): {"ppfdict": {"value": 3}},
("submodel14b", ("submodel14a", "addtask2ab")): {"ppfdict": {"value": 4}},
("submodel14b", ("submodel14a", "Out")): {"ppfdict": {"value": 4}},
("submodel14b", "Out"): {"ppfdict": {"value": 4}},
"addtask3": {"ppfdict": {"value": 5}},
}
return graph, expected_results
......
......@@ -98,16 +98,16 @@ def workflow15():
}
expected_results = {
"addtask1": {"return_value": {"value": 2}},
("submodel15a", "in"): {"return_value": {"value": 2}},
("submodel15a", "addtask1"): {"return_value": {"value": 3}},
("submodel15a", "addtask2"): {"return_value": {"value": 4}},
("submodel15a", "out"): {"return_value": {"value": 4}},
("submodel15b", "in"): {"return_value": {"value": 4}},
("submodel15b", "addtask1"): {"return_value": {"value": 5}},
("submodel15b", "addtask2"): {"return_value": {"value": 6}},
("submodel15b", "out"): {"return_value": {"value": 6}},
"addtask2": {"return_value": {"value": 7}},
"addtask1": {"ppfdict": {"value": 2}},
("submodel15a", "in"): {"ppfdict": {"value": 2}},
("submodel15a", "addtask1"): {"ppfdict": {"value": 3}},
("submodel15a", "addtask2"): {"ppfdict": {"value": 4}},
("submodel15a", "out"): {"ppfdict": {"value": 4}},
("submodel15b", "in"): {"ppfdict": {"value": 4}},
("submodel15b", "addtask1"): {"ppfdict": {"value": 5}},
("submodel15b", "addtask2"): {"ppfdict": {"value": 6}},
("submodel15b", "out"): {"ppfdict": {"value": 6}},
"addtask2": {"ppfdict": {"value": 7}},
}
return graph, expected_results
......
......@@ -139,18 +139,18 @@ def workflow16():
}
expected_results = {
"addtask1": {"return_value": {"value": 2}},
("submodel16b", "in"): {"return_value": {"value": 2}},
("submodel16b", "addtask1"): {"return_value": {"value": 3}},
("submodel16b", ("submodel16a", "in")): {"return_value": {"value": 3}},
("submodel16b", ("submodel16a", "addtask1")): {"return_value": {"value": 4}},
("submodel16b", ("submodel16a", "addtask2")): {"return_value": {"value": 5}},
"addtask1": {"ppfdict": {"value": 2}},
("submodel16b", "in"): {"ppfdict": {"value": 2}},
("submodel16b", "addtask1"): {"ppfdict": {"value": 3}},
("submodel16b", ("submodel16a", "in")): {"ppfdict": {"value": 3}},
("submodel16b", ("submodel16a", "addtask1")): {"ppfdict": {"value": 4}},
("submodel16b", ("submodel16a", "addtask2")): {"ppfdict": {"value": 5}},
("submodel16b", ("submodel16a", "out")): {
"return_value": {"value": 5}
"ppfdict": {"value": 5}
}, # 2 destinations
("submodel16b", "addtask2"): {"return_value": {"value": 6}},
("submodel16b", "out"): {"return_value": {"value": 6}},
"addtask2": {"return_value": {"value": 6}},
("submodel16b", "addtask2"): {"ppfdict": {"value": 6}},
("submodel16b", "out"): {"ppfdict": {"value": 6}},
"addtask2": {"ppfdict": {"value": 6}},
}
return graph, expected_results
......
......@@ -78,11 +78,9 @@ def workflow3():
}
expected_results = {
"first": {"return_value": {"name": "first", "reply": "Hello first!"}},
("middle", "mytask"): {
"return_value": {"name": "middle", "reply": "Hello middle!"}
},
"last": {"return_value": {"name": "last", "reply": "Hello last!"}},
"first": {"ppfdict": {"name": "first", "reply": "Hello first!"}},
("middle", "mytask"): {"ppfdict": {"name": "middle", "reply": "Hello middle!"}},
"last": {"ppfdict": {"name": "last", "reply": "Hello last!"}},
}
return graph, expected_results
......
......@@ -86,12 +86,12 @@ def workflow6():
}
expected_results = {
"addtask1": {"return_value": {"value": 2}},
("submodel6", "in"): {"return_value": {"value": 2}},
("submodel6", "addtask2a"): {"return_value": {"value": 3}},
("submodel6", "addtask2b"): {"return_value": {"value": 4}},
("submodel6", "out"): {"return_value": {"value": 4}},
"addtask3": {"return_value": {"value": 5}},
"addtask1": {"ppfdict": {"value": 2}},
("submodel6", "in"): {"ppfdict": {"value": 2}},
("submodel6", "addtask2a"): {"ppfdict": {"value": 3}},
("submodel6", "addtask2b"): {"ppfdict": {"value": 4}},
("submodel6", "out"): {"ppfdict": {"value": 4}},
"addtask3": {"ppfdict": {"value": 5}},
}
return graph, expected_results
......
......@@ -76,9 +76,9 @@ def workflow7():
}
expected_results = {
"addtask1": {"return_value": {"all_arguments": {"value": 2}}},
("submodel7", "addtask2"): {"return_value": {"all_arguments": {"value": 3}}},
"addtask3": {"return_value": {"all_arguments": {"value": 4}}},
"addtask1": {"ppfdict": {"all_arguments": {"value": 2}}},
("submodel7", "addtask2"): {"ppfdict": {"all_arguments": {"value": 3}}},
"addtask3": {"ppfdict": {"all_arguments": {"value": 4}}},
}
return graph, expected_results
......
......@@ -76,9 +76,9 @@ def workflow8():
}
expected_results = {
"addtask1": {"return_value": {"a": 1, "b": 2}},
("submodel8", "addtask2"): {"return_value": {"a": 1, "b": 2, "c": 3}},
"addtask3": {"return_value": {"a": 1, "b": 2, "c": 3, "d": 6}},
"addtask1": {"ppfdict": {"a": 1, "b": 2}},
("submodel8", "addtask2"): {"ppfdict": {"a": 1, "b": 2, "c": 3}},
"addtask3": {"ppfdict": {"a": 1, "b": 2, "c": 3, "d": 6}},
}
return graph, expected_results
......
......@@ -51,9 +51,9 @@ def workflow9():
# the same task instance as addtask2 (same task hash). So it
# will appear as "done" and have a result.
expected_results = {
"addtask1": {"return_value": {"value": 2}},
"addtask2": {"return_value": {"value": 3}},
"addtask3": {"return_value": {"value": 3}},
"addtask1": {"ppfdict": {"value": 2}},
"addtask2": {"ppfdict": {"value": 3}},
"addtask3": {"ppfdict": {"value": 3}},
}
return graph, expected_results
......
......@@ -55,7 +55,7 @@ All tasks are described by a `Task` class.
When not specifying the `Task` class directly, a class wrapper will be used:
* *method*: defined by a `Task` class with one required input argument ("method": full qualifier name of the method) and one output argument ("return_value")
* *ppfmethod*: same as *method* but it has one optional input ("return_value": dictionary that will be unpacked to the input arguments when present)
* *ppfmethod*: same as *method* but it has one optional input "ppfdict" and one output "ppfdict". The output dictonary is the input dictionary updated by the method. The input dictionary is unpacked before passing to the method. The output dictionary is unpacked when checking conditions in links.
* *ppfport*: *ppfmethod* which is the identity mapping
* *script*: defined by a `Task` class with one required input argument ("method": full qualifier name of the method) and one output argument ("return_value")
......
from esrftaskgraph.task import Task
from esrftaskgraph.methodtask import MethodExecutorTask
from esrftaskgraph.utils import import_method
class PpfMethodExecutorTask(
MethodExecutorTask,
optional_input_names=["return_value"],
output_names=["return_value"],
Task,
input_names=["method"],
optional_input_names=["ppfdict"],
output_names=["ppfdict"],
):
"""Ppf workflows pass one dictionary around between tasks and this dictionary
gets updates by each task.
"""
@property
def method(self):
fullname = self.inputs.method
return import_method(fullname)
def process(self):
method_kwargs = self.input_values
method_kwargs.pop("method")
return_value = method_kwargs.pop("return_value", None)
if return_value:
method_kwargs.update(return_value)
ppfdict = method_kwargs.pop("ppfdict", None)
if ppfdict:
method_kwargs.update(ppfdict)
result = self.method(**method_kwargs)
return_value = dict(method_kwargs)
return_value.update(result)
self.outputs.return_value = return_value
ppfdict = dict(method_kwargs)
ppfdict.update(result)
self.outputs.ppfdict = ppfdict
class PpfPortTask(
Task, optional_input_names=["return_value"], output_names=["return_value"]
):
class PpfPortTask(Task, optional_input_names=["ppfdict"], output_names=["ppfdict"]):
"""A ppfmethod which represents the identity mapping"""
def process(self):
passthroughdata = self.inputs.return_value
passthroughdata = self.inputs.ppfdict
if passthroughdata:
self.outputs.return_value = dict(passthroughdata)
self.outputs.ppfdict = dict(passthroughdata)
else:
self.outputs.return_value = dict()
self.outputs.ppfdict = dict()
......@@ -125,7 +125,7 @@ def test_ppfmethod_task(variable_kwargs):
)
task.run()
assert task.done
assert task.output_values == {"return_value": {"a": 8, "b": 5}}
assert task.output_values == {"ppfdict": {"a": 8, "b": 5}}
shellscript = r"""a=0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment