@ -5,6 +5,7 @@ from stevedore import ExtensionManager
|
||||
|
||||
|
||||
def entrypoint(args=None):
|
||||
logging.basicConfig()
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
subparsers = parser.add_subparsers(dest='command')
|
||||
@ -19,9 +20,7 @@ def entrypoint(args=None):
|
||||
except Exception:
|
||||
logging.exception('Error while loading command {}.'.format(ext.name))
|
||||
|
||||
mgr = ExtensionManager(
|
||||
namespace='bonobo.commands',
|
||||
)
|
||||
mgr = ExtensionManager(namespace='bonobo.commands')
|
||||
mgr.map(register_extension)
|
||||
|
||||
args = parser.parse_args(args).__dict__
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import importlib
|
||||
import os
|
||||
import runpy
|
||||
|
||||
@ -44,7 +45,13 @@ def execute(filename, module, install=False, quiet=False, verbose=False):
|
||||
if os.path.isdir(filename):
|
||||
if install:
|
||||
requirements = os.path.join(filename, 'requirements.txt')
|
||||
pip.main(['install', '-qr', requirements])
|
||||
pip.main(['install', '-r', requirements])
|
||||
# Some shenanigans to be sure everything is importable after this, especially .egg-link files which
|
||||
# are referenced in *.pth files and apparently loaded by site.py at some magic bootstrap moment of the
|
||||
# python interpreter.
|
||||
pip.utils.pkg_resources = importlib.reload(pip.utils.pkg_resources)
|
||||
import site
|
||||
importlib.reload(site)
|
||||
filename = os.path.join(filename, DEFAULT_GRAPH_FILENAME)
|
||||
elif install:
|
||||
raise RuntimeError('Cannot --install on a file (only available for dirs containing requirements.txt).')
|
||||
|
||||
23
bonobo/examples/tutorials/tut01e01.py
Normal file
23
bonobo/examples/tutorials/tut01e01.py
Normal file
@ -0,0 +1,23 @@
|
||||
import bonobo
|
||||
|
||||
|
||||
def extract():
|
||||
yield 'foo'
|
||||
yield 'bar'
|
||||
yield 'baz'
|
||||
|
||||
|
||||
def transform(x):
|
||||
return x.upper()
|
||||
|
||||
|
||||
def load(x):
|
||||
print(x)
|
||||
|
||||
|
||||
graph = bonobo.Graph(extract, transform, load)
|
||||
|
||||
graph.__doc__ = 'hello'
|
||||
|
||||
if __name__ == '__main__':
|
||||
bonobo.run(graph)
|
||||
10
bonobo/examples/tutorials/tut01e02.py
Normal file
10
bonobo/examples/tutorials/tut01e02.py
Normal file
@ -0,0 +1,10 @@
|
||||
import bonobo
|
||||
|
||||
graph = bonobo.Graph(
|
||||
['foo', 'bar', 'baz', ],
|
||||
str.upper,
|
||||
print,
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
bonobo.run(graph)
|
||||
Reference in New Issue
Block a user