Jump to: navigation, search

Difference between revisions of "TaskFlow/Inputs and Outputs"

(Task And Flow Inputs and Outputs)
(Storage)
Line 12: Line 12:
  
 
==== Storage ====
 
==== Storage ====
 +
 +
The storage layer is how an engine persists flow and task details.
 +
 +
For more in-depth design details: [[TaskFlow/Persistence|persistence].
 +
 +
To initially pre-populate your engine with arguments (so that dependent tasks can immediatly start running) you can directly interact with the engine <code>load</code> or <code>run</code> to provide these needed inputs.
 +
 +
'''For example:'''
 +
 +
 +
         
 +
    >>> from taskflow import task
 +
    >>> from taskflow import engines
 +
    >>> from taskflow.patterns import linear_flow as lf
 +
    >>>
 +
    >>> class CatTalk(task.Task):
 +
    ...  def execute(self, meow):
 +
    ...    print meow
 +
    ...
 +
    >>> class DogTalk(task.Task):
 +
    ...  def execute(self, woof):
 +
    ...    print woof
 +
    ...
 +
    >>> flo = lf.Flow("cat-dog")
 +
    >>> flo.add(CatTalk(), DogTalk())
 +
    >>> engines.run(flo)
 +
    Traceback (most recent call last):
 +
      File "<stdin>", line 1, in <module>
 +
      File "/usr/lib/python2.6/site-packages/taskflow/engines/helpers.py", line 110, in run
 +
        engine.run()
 +
      File "/usr/lib/python2.6/site-packages/taskflow/utils/lock_utils.py", line 51, in wrapper
 +
        return f(*args, **kwargs)
 +
      File "/usr/lib/python2.6/site-packages/taskflow/engines/action_engine/engine.py", line 104, in run
 +
        raise exc.MissingDependencies(self._flow, sorted(missing))
 +
    taskflow.exceptions.MissingDependencies: taskflow.patterns.linear_flow.Flow: cat-dog; 2 requires ['meow', 'woof'] but no other entity produces said requirements
  
 
==== Notifications ====
 
==== Notifications ====

Revision as of 21:23, 23 October 2013

Revised on: 10/23/2013 by Harlowja

Overview

In taskflow there are multiple ways to design how your tasks/flows and engines get inputs and produce outputs. This document will help you understand what those ways are and how to use those ways to accomplish your desired taskflow usage pattern as well as include examples that show common ways of providing input and getting output.

Task & Flow Inputs and Outputs

See: Task & Flow Arguments and Results

Engine Inputs and Outputs

Storage

The storage layer is how an engine persists flow and task details.

For more in-depth design details: [[TaskFlow/Persistence|persistence].

To initially pre-populate your engine with arguments (so that dependent tasks can immediatly start running) you can directly interact with the engine load or run to provide these needed inputs.

For example:


   >>> from taskflow import task
   >>> from taskflow import engines
   >>> from taskflow.patterns import linear_flow as lf
   >>> 
   >>> class CatTalk(task.Task):
   ...   def execute(self, meow):
   ...     print meow
   ... 
   >>> class DogTalk(task.Task):
   ...   def execute(self, woof):
   ...     print woof
   ... 
   >>> flo = lf.Flow("cat-dog")
   >>> flo.add(CatTalk(), DogTalk())
   >>> engines.run(flo)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/usr/lib/python2.6/site-packages/taskflow/engines/helpers.py", line 110, in run
       engine.run()
     File "/usr/lib/python2.6/site-packages/taskflow/utils/lock_utils.py", line 51, in wrapper
       return f(*args, **kwargs)
     File "/usr/lib/python2.6/site-packages/taskflow/engines/action_engine/engine.py", line 104, in run
       raise exc.MissingDependencies(self._flow, sorted(missing))
   taskflow.exceptions.MissingDependencies: taskflow.patterns.linear_flow.Flow: cat-dog; 2 requires ['meow', 'woof'] but no other entity produces said requirements

Notifications