-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from hartym/0.2
- Loading branch information
Showing
41 changed files
with
479 additions
and
318 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from bonobo._version import __version__ | ||
|
||
__all__ = [ | ||
'__version__', | ||
] | ||
|
||
from bonobo.structs import Bag, Graph | ||
|
||
__all__ += ['Bag', 'Graph'] | ||
|
||
# Filesystem. This is a shortcut from the excellent filesystem2 library, that we make available there for convenience. | ||
from fs import open_fs as _open_fs | ||
open_fs = lambda url, *args, **kwargs: _open_fs(str(url), *args, **kwargs) | ||
__all__ += ['open_fs'] | ||
|
||
# Basic transformations. | ||
from bonobo.basics import * | ||
from bonobo.basics import __all__ as _all_basics | ||
|
||
__all__ += _all_basics | ||
|
||
# Execution strategies. | ||
from bonobo.strategies import create_strategy | ||
|
||
__all__ += ['create_strategy'] | ||
|
||
|
||
# Extract and loads from stdlib. | ||
from bonobo.io import * | ||
from bonobo.io import __all__ as _all_io | ||
|
||
__all__ += _all_io | ||
|
||
|
||
# XXX This may be belonging to the bonobo.examples package. | ||
def get_examples_path(*pathsegments): | ||
import os | ||
import pathlib | ||
return str(pathlib.Path(os.path.dirname(__file__), 'examples', *pathsegments)) | ||
|
||
|
||
__all__.append(get_examples_path.__name__) | ||
|
||
|
||
def _is_interactive_console(): | ||
import sys | ||
return sys.stdout.isatty() | ||
|
||
|
||
def _is_jupyter_notebook(): | ||
try: | ||
return get_ipython().__class__.__name__ == 'ZMQInteractiveShell' | ||
except NameError: | ||
return False | ||
|
||
|
||
# @api | ||
def run(graph, *chain, strategy=None, plugins=None, services=None): | ||
if len(chain): | ||
warnings.warn('DEPRECATED. You should pass a Graph instance instead of a chain.') | ||
from bonobo import Graph | ||
graph = Graph(graph, *chain) | ||
|
||
strategy = create_strategy(strategy) | ||
plugins = [] | ||
|
||
if _is_interactive_console(): | ||
from bonobo.ext.console import ConsoleOutputPlugin | ||
if ConsoleOutputPlugin not in plugins: | ||
plugins.append(ConsoleOutputPlugin) | ||
|
||
if _is_jupyter_notebook(): | ||
from bonobo.ext.jupyter import JupyterOutputPlugin | ||
if JupyterOutputPlugin not in plugins: | ||
plugins.append(JupyterOutputPlugin) | ||
|
||
return strategy.execute(graph, plugins=plugins, services=services) | ||
|
||
|
||
__all__.append(run.__name__) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
'noop', | ||
] | ||
|
||
|
||
def identity(x): | ||
return x | ||
|
||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
from bonobo.config.configurables import Configurable | ||
from bonobo.config.options import Option | ||
from bonobo.config.services import Container, Service | ||
from bonobo.config.processors import ContextProcessor | ||
from bonobo.config.services import Container, Service | ||
|
||
__all__ = [ | ||
'Configurable', | ||
'Container', | ||
'ContextProcessor', | ||
'Option', | ||
'Service', | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from os.path import dirname | ||
|
||
import bonobo | ||
|
||
|
||
def get_services(): | ||
return { | ||
'fs': bonobo.open_fs(dirname(__file__)) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
from os.path import dirname, realpath, join | ||
|
||
import bonobo | ||
from bonobo.commands.run import get_default_services | ||
from bonobo.ext.opendatasoft import OpenDataSoftAPI | ||
|
||
OUTPUT_FILENAME = realpath(join(dirname(__file__), 'coffeeshops.txt')) | ||
filename = 'coffeeshops.txt' | ||
|
||
graph = bonobo.Graph( | ||
OpenDataSoftAPI(dataset='liste-des-cafes-a-un-euro', netloc='opendata.paris.fr'), | ||
lambda row: '{nom_du_cafe}, {adresse}, {arrondissement} Paris, France'.format(**row), | ||
bonobo.FileWriter(path=OUTPUT_FILENAME), | ||
bonobo.FileWriter(path=filename), | ||
) | ||
|
||
if __name__ == '__main__': | ||
bonobo.run(graph) | ||
print('Import done, read {} for results.'.format(OUTPUT_FILENAME)) | ||
bonobo.run(graph, services=get_default_services(__file__)) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import bonobo | ||
from bonobo.commands.run import get_default_services | ||
|
||
# XXX does not work anymore because of filesystem service, can't read HTTP | ||
url = 'https://data.toulouse-metropole.fr/explore/dataset/theatres-et-salles-de-spectacles/download?format=json&timezone=Europe/Berlin&use_labels_for_header=true' | ||
|
||
graph = bonobo.Graph( | ||
bonobo.JsonReader(path=url), | ||
) | ||
|
||
if __name__ == '__main__': | ||
bonobo.run(graph, services=get_default_services(__file__)) |
Oops, something went wrong.