summaryrefslogtreecommitdiff
path: root/taskflow/patterns/linear_flow.py
diff options
context:
space:
mode:
authorIvan A. Melnikov <imelnikov@griddynamics.com>2014-03-17 14:15:53 +0400
committerIvan A. Melnikov <imelnikov@griddynamics.com>2014-03-21 11:11:15 +0400
commit1011df951eda7481a3e16b14baf9fdc6089ffe9c (patch)
treed75c3c3b1dac3841c158649f9ae284575fcb23e8 /taskflow/patterns/linear_flow.py
parent4252eb02779a8399740fd04a37ec67ebd274d866 (diff)
downloadtaskflow-1011df951eda7481a3e16b14baf9fdc6089ffe9c.tar.gz
Iteration over links in flow interface
In addition to iteration over its children (atoms or subflows) each pattern now provides iter_links() method that iterates over dependency links. This allows engines to treat all patterns in the same way instead knowing what structure each pattern expresses. Change-Id: I52cb5b0b501eefc8eb56a9ef5303aeb318013e11
Diffstat (limited to 'taskflow/patterns/linear_flow.py')
-rw-r--r--taskflow/patterns/linear_flow.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/taskflow/patterns/linear_flow.py b/taskflow/patterns/linear_flow.py
index 5ffd211..89fab08 100644
--- a/taskflow/patterns/linear_flow.py
+++ b/taskflow/patterns/linear_flow.py
@@ -18,6 +18,10 @@ from taskflow import exceptions
from taskflow import flow
+# TODO(imelnikov): add metadata describing link here
+_LINK_METADATA = dict()
+
+
class Flow(flow.Flow):
"""Linear Flow pattern.
@@ -71,6 +75,11 @@ class Flow(flow.Flow):
for child in self._children:
yield child
+ def iter_links(self):
+ for src, dst in zip(self._children[:-1],
+ self._children[1:]):
+ yield (src, dst, _LINK_METADATA.copy())
+
def __getitem__(self, index):
return self._children[index]