コード例 #1
0
ファイル: run.py プロジェクト: redhat-aqe/wfepy
def run_wf(debug, example_name):
    logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)

    example_module = __import__(example_name)

    wf = wfepy.Workflow()
    wf.load_tasks(example_module)

    wfepy.utils.render_graph(wf, os.path.join(os.path.dirname(__file__), example_name + '.gv'))

    runner = wf.create_runner()
    runner.run()
コード例 #2
0
ファイル: test_simple.py プロジェクト: redhat-aqe/wfepy
 def setUp(self):
     self.workflow = wfepy.Workflow()
     self.workflow.load_tasks(__name__)
     self.workflow.check_graph()
コード例 #3
0
            'state': [(name, istate.name) for name, istate in self.state],
        })

    def task_execute(self, task):
        # Custom task execute code. We can add custom pre/post hooks, logging,
        # pass extra variables to tasks (by defalt only context is passed to
        # tasks) ... we can even prevent some task from executing and fake their
        # results.

        self.executed_tasks.add(task.name)

        retval = task(self.context)  # or `super().execute(task)`

        if not retval and task.has_labels({'user'}):
            logging.info('Waiting for user input in task %s.', task.name)

        return retval


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)

    workflow = wf.Workflow()
    workflow.load_tasks(__name__)

    # Use custom runner instead of default one.
    runner = Runner(workflow)
    runner.run()

    assert runner.executed_tasks == {'start', 'middle', 'end'}
コード例 #4
0
ファイル: simple_run.py プロジェクト: redhat-aqe/wfepy
import logging
import wfepy
import wfepy.utils

logging.basicConfig(level=logging.INFO)

# Import module with tasks.
import simple

# Create new workflow.
wf = wfepy.Workflow()
# Load tasks from module and add them to workflow.
wf.load_tasks(simple)
# Check if graph is OK, all tasks are defined, decorated correctly, ...
wf.check_graph()

# Render graph.
wfepy.utils.render_graph(wf, 'basic.gv')

# Create runner for workflow.
runner = wf.create_runner()

# Execute workflow.
runner.run()

# Check if workflow finished, no tasks are waiting.
while not runner.finished:
    logging.info('Workflow is not finished, trying run it again...')
    runner.run()