Implements commands as extensions using stevedore; adds run and init command.

This commit is contained in:
Romain Dorgueil
2017-01-10 23:09:40 +01:00
parent f736e7e7e3
commit 9daefd7207
9 changed files with 115 additions and 17 deletions

View File

@ -1,8 +1,13 @@
def run(*chain, plugins=None, strategy=None):
from bonobo import Graph, ThreadPoolExecutorStrategy
graph = Graph()
graph.add_chain(*chain)
if len(chain) == 1 and isinstance(chain[0], Graph):
graph = chain[0]
elif len(chain) >= 1:
graph = Graph()
graph.add_chain(*chain)
else:
raise RuntimeError('Empty chain.')
executor = (strategy or ThreadPoolExecutorStrategy)()
return executor.execute(graph, plugins=plugins or [])