Repository: bokeh/bokeh

Issue:
Call load_notebook via notebook hook

In `outpute_notebook`, we should call

 `_run_notebook_hook(_state.notebook_type, 'load', resources, verbose, hide_banner, load_timeout)`
instead of calling load_notebook directly,


Discussion:

Resolving patch:
diff --git a/bokeh/io.py b/bokeh/io.py
--- a/bokeh/io.py
+++ b/bokeh/io.py
@@ -270,7 +270,7 @@ def output_notebook(resources=None, verbose=False, hide_banner=False, load_timeo
     '''
     # verify notebook_type first in _state.output_notebook
     _state.output_notebook(notebook_type)
-    load_notebook(resources, verbose, hide_banner, load_timeout, notebook_type)
+    _run_notebook_hook(notebook_type, 'load', resources, verbose, hide_banner, load_timeout)
 
 def set_curdoc(doc):
     '''Configure the current document (returned by curdoc()).
@@ -882,7 +882,9 @@ def export_svgs(obj, filename=None, height=None, width=None, webdriver=None):
     return filenames
 
 
-install_notebook_hook('jupyter', partial(load_notebook, notebook_type='jupyter'), _show_jupyter_doc_with_state, _show_jupyter_app_with_state)
+def _install_notebook_hook():
+    install_notebook_hook('jupyter', partial(load_notebook, notebook_type='jupyter'), _show_jupyter_doc_with_state, _show_jupyter_app_with_state, overwrite=True)
+    # TODO (bev) These should eventually be removed, but install a basic built-in hook for docs or now
+    install_notebook_hook('zeppelin', partial(load_notebook, notebook_type='zeppelin'), _show_zeppelin_doc_with_state, None, overwrite=True)
 
-# TODO (bev) These should eventually be removed, but install a basic built-in hook for docs or now
-install_notebook_hook('zeppelin', partial(load_notebook, notebook_type='zeppelin'), _show_zeppelin_doc_with_state, None)
+_install_notebook_hook()


Test patch:
diff --git a/bokeh/tests/test_io.py b/bokeh/tests/test_io.py
--- a/bokeh/tests/test_io.py
+++ b/bokeh/tests/test_io.py
@@ -73,17 +73,23 @@ class TestOutputJupyter(DefaultStateTester):
 
     @patch('bokeh.io.load_notebook')
     def test_noarg(self, mock_load_notebook):
+        # call _install_notebook_hook to register the patched `bokeh.io.load_notebook`
+        from bokeh.io import _install_notebook_hook
+        _install_notebook_hook()
         default_load_jupyter_args = (None, False, False, 5000)
         io.output_notebook()
         self._check_func_called(io._state.output_notebook, ('jupyter',), {})
-        self._check_func_called(mock_load_notebook, default_load_jupyter_args + ('jupyter',), {})
+        self._check_func_called(mock_load_notebook, default_load_jupyter_args, {'notebook_type': 'jupyter'})
 
     @patch('bokeh.io.load_notebook')
     def test_args(self, mock_load_notebook):
-        load_jupyter_args = (Resources(), True, True, 1000, 'jupyter')
+        # call _install_notebook_hook to register the patched `bokeh.io.load_notebook`
+        from bokeh.io import _install_notebook_hook
+        _install_notebook_hook()
+        load_jupyter_args = (Resources(), True, True, 1000)
         io.output_notebook(*load_jupyter_args)
         self._check_func_called(io._state.output_notebook, ('jupyter',), {})
-        self._check_func_called(mock_load_notebook, load_jupyter_args, {})
+        self._check_func_called(mock_load_notebook, load_jupyter_args, {'notebook_type': 'jupyter'})
 
 class TestSave(DefaultStateTester):
     pass