summaryrefslogtreecommitdiff
path: root/taskflow/examples/simple_linear.py
diff options
context:
space:
mode:
authorIvan A. Melnikov <imelnikov@griddynamics.com>2013-09-13 12:22:27 +0400
committerIvan A. Melnikov <imelnikov@griddynamics.com>2013-10-03 10:08:55 +0400
commitcde0dee14e0e93018f5d9a5a32a98623ec29bbc4 (patch)
treec71cabcd182ac62aadc2e2b8139bb3ce815ed44d /taskflow/examples/simple_linear.py
parent568c79494c9652f337f32182fcb1214165e0d3f8 (diff)
downloadtaskflow-cde0dee14e0e93018f5d9a5a32a98623ec29bbc4.tar.gz
Simpler API to load flows into engines
Previously to run a flow client code had to put together the flow, an engine, logbook, flowdetail, and storage backend. This commit adds two helper functions, run() and load(), so that simplest usecase now looks like taskflow.engines.run(flow) Client code may also provide configuration for storage and engine if needed, but if not needed it just works with defaults. Engines are loaded via stevedore, as drivers in 'taskflow.engines' backend. Now three entry points are defined in that namespace: - 'default', for SingleThreadedActionEngine, used by default; - 'serial', as another synonym for SingleThreadedActionEngine; - 'parallel', for MultiThreadedActionEngine. Closes-bug: #1224726 Change-Id: I7f4cb5c8ff7f5f12831ddd0952c202d2fd8cd6ef
Diffstat (limited to 'taskflow/examples/simple_linear.py')
-rw-r--r--taskflow/examples/simple_linear.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/taskflow/examples/simple_linear.py b/taskflow/examples/simple_linear.py
index bde8c64..fb2a7c1 100644
--- a/taskflow/examples/simple_linear.py
+++ b/taskflow/examples/simple_linear.py
@@ -4,11 +4,12 @@ import sys
logging.basicConfig(level=logging.ERROR)
-my_dir_path = os.path.dirname(os.path.abspath(__file__))
-sys.path.insert(0, os.path.join(os.path.join(my_dir_path, os.pardir),
- os.pardir))
+top_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
+ os.pardir,
+ os.pardir))
+sys.path.insert(0, top_dir)
-from taskflow.engines.action_engine import engine as eng
+import taskflow.engines
from taskflow.patterns import linear_flow as lf
from taskflow import task
@@ -30,16 +31,11 @@ class CallJoe(task.Task):
def execute(self, joe_number, *args, **kwargs):
print("Calling joe %s." % joe_number)
+
flow = lf.Flow('simple-linear').add(
CallJim(),
CallJoe()
)
-engine = eng.SingleThreadedActionEngine(flow)
-
-engine.storage.inject({
- "joe_number": 444,
- "jim_number": 555,
-})
-
-engine.run()
+taskflow.engines.run(flow, store=dict(joe_number=444,
+ jim_number=555))