diff --git a/bonobo/_api.py b/bonobo/_api.py index 5d35eebf..96310c7d 100644 --- a/bonobo/_api.py +++ b/bonobo/_api.py @@ -83,6 +83,9 @@ def run(graph, *, plugins=None, services=None, strategy=None): from bonobo.util.errors import sweeten_errors + if not isinstance(graph, Graph) and hasattr(graph, 'graph'): + graph = graph.graph + with sweeten_errors(): return strategy.execute(graph, plugins=plugins, services=services) diff --git a/bonobo/commands/templates/bare.py-tpl b/bonobo/commands/templates/bare.py-tpl index 9390d76c..9a4e630d 100644 --- a/bonobo/commands/templates/bare.py-tpl +++ b/bonobo/commands/templates/bare.py-tpl @@ -1,16 +1,13 @@ import bonobo -def get_graph(**options): - graph = bonobo.Graph() - graph.get_cursor() >> ... - return graph - - -def get_services(**options): - return {} +def create_graph(): + return ( + bonobo.Graph() + >> ... + ) if __name__ == '__main__': with bonobo.parse_args() as options: - bonobo.run(get_graph(**options), services=get_services(**options)) + bonobo.run(create_graph()) diff --git a/bonobo/commands/templates/default.py-tpl b/bonobo/commands/templates/default.py-tpl index fef1e1c3..42d280a6 100644 --- a/bonobo/commands/templates/default.py-tpl +++ b/bonobo/commands/templates/default.py-tpl @@ -27,8 +27,12 @@ def get_graph(**options): """ graph = bonobo.Graph() - graph.get_cursor() >> extract >> transform >> load - + ( + graph + >> extract + >> transform + >> load + ) return graph