Paste #445602

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from taskflow import task

from taskflow.patterns import linear_flow

import logging

logging.basicConfig(level=5)

from taskflow import engines

from taskflow.listeners import logging as logging_listener


class ProvidesThings(task.Task):

    default_provides = frozenset(['a'])

    def execute(self):
        print 'Running %s' % self.name
        return {
            'a': 2,
        }


class ExecutesThings(task.Task):
    def execute(self, *args, **kwargs):
        print 'Running %s' % self.name
        print args
        print kwargs

    
stuff = linear_flow.Flow("stuff")
stuff.add(ProvidesThings(), ExecutesThings(requires=['a']))

e = engines.load(stuff)
e.compile()

print e.compilation.execution_graph.pformat()
with logging_listener.DynamicLoggingListener(e):
    e.run()
print e.storage.backend.memory.pformat()