Skip to content

Commit

Permalink
Merge pull request #354 from hartym/339_templates_new_syntax
Browse files Browse the repository at this point in the history
#339 - Update templates to use new syntax.
  • Loading branch information
hartym committed Jul 20, 2019
2 parents 8325d7e + 9158af1 commit 62afb47
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 3 additions & 0 deletions bonobo/_api.py
Expand Up @@ -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)

Expand Down
15 changes: 6 additions & 9 deletions 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())
8 changes: 6 additions & 2 deletions bonobo/commands/templates/default.py-tpl
Expand Up @@ -27,8 +27,12 @@ def get_graph(**options):

"""
graph = bonobo.Graph()
graph.get_cursor() >> extract >> transform >> load

(
graph
>> extract
>> transform
>> load
)
return graph


Expand Down

0 comments on commit 62afb47

Please sign in to comment.