Last active
September 14, 2021 15:25
-
-
Save aleksanderwalczuk/256b28f86bd152e8b50f8b3a63bea880 to your computer and use it in GitHub Desktop.
etl-tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bonobo | |
| import json | |
| import time | |
| def w(*arg): | |
| yield arg | |
| def x(*args): | |
| time.sleep(1) | |
| yield args[0] | |
| def load(*args): | |
| print(*args) | |
| def get_graph(**options): | |
| graph = bonobo.Graph() | |
| graph.add_chain( | |
| bonobo.CsvReader('./report.csv'), | |
| bonobo.Limit(1), | |
| x, | |
| bonobo.PrettyPrinter(), | |
| ) | |
| return graph | |
| def get_services(**options): | |
| """ | |
| This function builds the services dictionary, which is a simple dict of names-to-implementation used by bonobo | |
| for runtime injection. | |
| It will be used on top of the defaults provided by bonobo (fs, http, ...). You can override those defaults, or just | |
| let the framework define them. You can also define your own services and naming is up to you. | |
| :return: dict | |
| """ | |
| return {} | |
| # The __main__ block actually execute the graph. | |
| if __name__ == '__main__': | |
| parser = bonobo.get_argument_parser() | |
| with bonobo.parse_args(parser) as options: | |
| bonobo.run( | |
| get_graph(**options), | |
| services=get_services(**options) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment