zjffdu / bkzep

Python package for using bokeh in Apache Zeppelin Notebook
10 stars 1 forks source link

Conflict with bokehjs v2.0.1 #12

Open mhebrard opened 4 years ago

mhebrard commented 4 years ago

Versions

Observed behavior

In zeppelin, when import bokeh and bkzep an error is fired. it was working fine with bokeh v2.0.0

Example code that reproduces the issue

%pyspark
from bokeh.io import show, output_notebook
import bkzep
output_notebook(notebook_type='zeppelin')

Stack traceback and/or browser JavaScript console output

Fail to execute line 10: output_notebook(notebook_type='zeppelin')
Traceback (most recent call last):
  File "/tmp/zeppelin_pyspark-5737857176342887979.py", line 380, in <module>
    exec(code, _zcUserQueryNameSpace)
  File "<stdin>", line 10, in <module>
  File "/usr/local/lib/python3.6/site-packages/bokeh/io/output.py", line 111, in output_notebook
    run_notebook_hook(notebook_type, 'load', resources, verbose, hide_banner, load_timeout)
  File "/usr/local/lib/python3.6/site-packages/bokeh/io/notebook.py", line 298, in run_notebook_hook
    return _HOOKS[notebook_type][action](*args, **kw)
  File "/usr/local/lib/python3.6/site-packages/bkzep/io.py", line 161, in load_notebook
    lab_html, lab_js = _load_notebook_html(resources, verbose, hide_banner, load_timeout)
  File "/usr/local/lib/python3.6/site-packages/bkzep/io.py", line 132, in _load_notebook_html
    timeout  = load_timeout
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.6/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/bokeh/core/_templates/autoload_nb_js.js", line 1, in top-level template code
    {% extends "autoload_js.js" %}
  File "/usr/local/lib/python3.6/site-packages/bokeh/core/_templates/autoload_js.js", line 88, in top-level template code
    const hashes = {{ bundle.hashes|json }};
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 471, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'bundle' is undefined
epugh commented 4 years ago

I am seeing the same issue with Zeppelin 0.90-preview1.

zjffdu commented 4 years ago

Thanks @mhebrard for reporting this issue, let me take a look at it .

zjffdu commented 4 years ago

One workaround is not using bkzep (At least bokeh 2.x doesn't need bkzep.

image

epugh commented 4 years ago

@zjffdu thanks for the workaround, I just tested it on the 0.9.0 preview1 release, and your workaround worked! Now I need to learn about BokehJS!

PeterKnightGE commented 4 years ago

I am also facing this issue, and the work around looks like it relies on an ipython interpreter, but I'm using a pyspark interpreter? I've also tried implementing this fix locally: https://github.com/bokeh/bokeh/issues/9854#issuecomment-644550190 but just get error name 'bundle_for_objs_and_resources' is not defined.

zjffdu commented 4 years ago

@PeterKnightGE Is it possible for you to use ipyspark which underneath use ipython interpreter. Look at the document here http://zeppelin.apache.org/docs/0.9.0-preview1/interpreter/spark.html#ipyspark-recommended