Merge pull request #146 from alekzvik/ipywidgets-fix

Do not fail in ipykernel without ipywidgets.
This commit is contained in:
Romain Dorgueil
2017-07-15 12:20:59 +02:00
committed by GitHub
2 changed files with 12 additions and 5 deletions

View File

@ -1,3 +1,5 @@
import logging
from bonobo.structs import Bag, Graph, Token from bonobo.structs import Bag, Graph, Token
from bonobo.nodes import CsvReader, CsvWriter, FileReader, FileWriter, Filter, JsonReader, JsonWriter, Limit, \ from bonobo.nodes import CsvReader, CsvWriter, FileReader, FileWriter, Filter, JsonReader, JsonWriter, Limit, \
PrettyPrinter, PickleWriter, PickleReader, RateLimited, Tee, count, identity, noop PrettyPrinter, PickleWriter, PickleReader, RateLimited, Tee, count, identity, noop
@ -52,7 +54,12 @@ def run(graph, strategy=None, plugins=None, services=None):
plugins.append(ConsoleOutputPlugin) plugins.append(ConsoleOutputPlugin)
if _is_jupyter_notebook(): if _is_jupyter_notebook():
try:
from bonobo.ext.jupyter import JupyterOutputPlugin from bonobo.ext.jupyter import JupyterOutputPlugin
except ImportError:
logging.warning(
'Failed to load jupyter widget. Easiest way is to install the optional "jupyter" ' 'dependencies with «pip install bonobo[jupyter]», but you can also install a specific ' 'version by yourself.')
else:
if JupyterOutputPlugin not in plugins: if JupyterOutputPlugin not in plugins:
plugins.append(JupyterOutputPlugin) plugins.append(JupyterOutputPlugin)

View File

@ -1,11 +1,11 @@
import logging
from bonobo.ext.jupyter.widget import BonoboWidget from bonobo.ext.jupyter.widget import BonoboWidget
from bonobo.plugins import Plugin from bonobo.plugins import Plugin
try: try:
import IPython.core.display import IPython.core.display
except ImportError as e: except ImportError as e:
import logging
logging.exception( logging.exception(
'You must install Jupyter to use the bonobo Jupyter extension. Easiest way is to install the ' 'You must install Jupyter to use the bonobo Jupyter extension. Easiest way is to install the '
'optional "jupyter" dependencies with «pip install bonobo[jupyter]», but you can also install a ' 'optional "jupyter" dependencies with «pip install bonobo[jupyter]», but you can also install a '