Skip to content

Commit 62afb47

Browse files
authored
Merge pull request #354 from hartym/339_templates_new_syntax
#339 - Update templates to use new syntax.
2 parents 8325d7e + 9158af1 commit 62afb47

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

bonobo/_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ def run(graph, *, plugins=None, services=None, strategy=None):
8383

8484
from bonobo.util.errors import sweeten_errors
8585

86+
if not isinstance(graph, Graph) and hasattr(graph, 'graph'):
87+
graph = graph.graph
88+
8689
with sweeten_errors():
8790
return strategy.execute(graph, plugins=plugins, services=services)
8891

bonobo/commands/templates/bare.py-tpl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import bonobo
22

33

4-
def get_graph(**options):
5-
graph = bonobo.Graph()
6-
graph.get_cursor() >> ...
7-
return graph
8-
9-
10-
def get_services(**options):
11-
return {}
4+
def create_graph():
5+
return (
6+
bonobo.Graph()
7+
>> ...
8+
)
129

1310

1411
if __name__ == '__main__':
1512
with bonobo.parse_args() as options:
16-
bonobo.run(get_graph(**options), services=get_services(**options))
13+
bonobo.run(create_graph())

bonobo/commands/templates/default.py-tpl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ def get_graph(**options):
2727

2828
"""
2929
graph = bonobo.Graph()
30-
graph.get_cursor() >> extract >> transform >> load
31-
30+
(
31+
graph
32+
>> extract
33+
>> transform
34+
>> load
35+
)
3236
return graph
3337

3438

0 commit comments

Comments
 (0)