Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bokeh on Visual Studio Code throws AttributeError: 'BokehModel' object has no attribute '_repr_mimebundle' #5454

Closed
ddrinka opened this issue Sep 22, 2022 · 6 comments

Comments

@ddrinka
Copy link
Contributor

ddrinka commented Sep 22, 2022

ALL software version info

Library Version
VS Code 1.71.2
python 3.9.13 64-bit
panel 0.14.0a25
jupyterlab 3.4.6
bokeh 2.4.3
jupyter-bokeh 3.0.5
pandas 1.4.4
ipywidgets 8.0.2

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
pn.extension(comms='vscode')

import pandas as pd
import holoviews as hv
from holoviews.operation import decimate
import numpy as np

hv.extension('bokeh')

x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)

table = hv.Table((x, y1, y2), 'x', ['y1', 'y2'])
chart = hv.Area(table)

decimate(chart)

Stack traceback and/or browser JavaScript console output

AttributeError                            Traceback (most recent call last)
File ~/.local/lib/python3.9/site-packages/IPython/core/formatters.py:973, in MimeBundleFormatter.__call__(self, obj, include, exclude)
    970     method = get_real_method(obj, self.print_method)
    972     if method is not None:
--> 973         return method(include=include, exclude=exclude)
    974     return None
    975 else:

File ~/.local/lib/python3.9/site-packages/holoviews/core/dimension.py:1293, in Dimensioned._repr_mimebundle_(self, include, exclude)
   1286 def _repr_mimebundle_(self, include=None, exclude=None):
   1287     """
   1288     Resolves the class hierarchy for the class rendering the
   1289     object using any display hooks registered on Store.display
   1290     hooks.  The output of all registered display_hooks is then
   1291     combined and returned.
   1292     """
-> 1293     return Store.render(self)

File ~/.local/lib/python3.9/site-packages/holoviews/core/options.py:1418, in Store.render(cls, obj)
   1416 data, metadata = {}, {}
   1417 for hook in hooks:
-> 1418     ret = hook(obj)
   1419     if ret is None:
   1420         continue

File ~/.local/lib/python3.9/site-packages/holoviews/ipython/display_hooks.py:277, in pprint_display(obj)
    275 if not ip.display_formatter.formatters['text/plain'].pprint:
    276     return None
--> 277 return display(obj, raw_output=True)

File ~/.local/lib/python3.9/site-packages/holoviews/ipython/display_hooks.py:253, in display(obj, raw_output, **kwargs)
    251 elif isinstance(obj, (HoloMap, DynamicMap)):
    252     with option_state(obj):
--> 253         output = map_display(obj)
    254 elif isinstance(obj, Plot):
    255     output = render(obj)

File ~/.local/lib/python3.9/site-packages/holoviews/ipython/display_hooks.py:141, in display_hook.<locals>.wrapped(element)
    139 try:
    140     max_frames = OutputSettings.options['max_frames']
--> 141     mimebundle = fn(element, max_frames=max_frames)
    142     if mimebundle is None:
    143         return {}, {}

File ~/.local/lib/python3.9/site-packages/holoviews/ipython/display_hooks.py:201, in map_display(vmap, max_frames)
    198     max_frame_warning(max_frames)
    199     return None
--> 201 return render(vmap)

File ~/.local/lib/python3.9/site-packages/holoviews/ipython/display_hooks.py:68, in render(obj, **kwargs)
     65 if renderer.fig == 'pdf':
     66     renderer = renderer.instance(fig='png')
---> 68 return renderer.components(obj, **kwargs)

File ~/.local/lib/python3.9/site-packages/holoviews/plotting/renderer.py:399, in Renderer.components(self, obj, fmt, comm, **kwargs)
    397 if embed or config.comms == 'default':
    398     return self._render_panel(plot, embed, comm)
--> 399 return self._render_ipywidget(plot)

File ~/.local/lib/python3.9/site-packages/holoviews/plotting/renderer.py:422, in Renderer._render_ipywidget(self, plot)
    420 widget = ipywidget(plot, combine_events=True)
    421 if hasattr(widget, '_repr_mimebundle_'):
--> 422     return widget._repr_mimebundle()
    423 plaintext = repr(widget)
    424 if len(plaintext) > 110:

AttributeError: 'BokehModel' object has no attribute '_repr_mimebundle'
@ddrinka
Copy link
Contributor Author

ddrinka commented Sep 22, 2022

@ddrinka
Copy link
Contributor Author

ddrinka commented Sep 22, 2022

This is reproducible on JupyterLab as well if the ipywidgets communication protocol is used:

import panel as pn
pn.extension(comms='ipywidgets')

import pandas as pd
import holoviews as hv
from holoviews.operation import decimate
import numpy as np

hv.extension('bokeh')

x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)

table = hv.Table((x, y1, y2), 'x', ['y1', 'y2'])
chart = hv.Area(table)

decimate(chart)

@ddrinka
Copy link
Contributor Author

ddrinka commented Sep 22, 2022

Correcting the typo leads to a further exception:

ValueError                                Traceback (most recent call last)
File ~/.local/lib/python3.9/site-packages/IPython/core/formatters.py:973, in MimeBundleFormatter.__call__(self, obj, include, exclude)
    970     method = get_real_method(obj, self.print_method)
    972     if method is not None:
--> 973         return method(include=include, exclude=exclude)
    974     return None
    975 else:

File ~/.local/lib/python3.9/site-packages/holoviews/core/dimension.py:1293, in Dimensioned._repr_mimebundle_(self, include, exclude)
   1286 def _repr_mimebundle_(self, include=None, exclude=None):
   1287     """
   1288     Resolves the class hierarchy for the class rendering the
   1289     object using any display hooks registered on Store.display
   1290     hooks.  The output of all registered display_hooks is then
   1291     combined and returned.
   1292     """
-> 1293     return Store.render(self)

File ~/.local/lib/python3.9/site-packages/holoviews/core/options.py:1422, in Store.render(cls, obj)
   1420         continue
   1421     d, md = ret
-> 1422     data.update(d)
   1423     metadata.update(md)
   1424 return data, metadata

ValueError: dictionary update sequence element #0 has length 1; 2 is required

@hoxbro
Copy link
Member

hoxbro commented Sep 23, 2022

This should be fixed with #5398

@hoxbro hoxbro closed this as completed Sep 23, 2022
@ddrinka
Copy link
Contributor Author

ddrinka commented Sep 23, 2022

Hi @hoxbro, I wonder if we wouldn't keep this open until the changes are merged? Is there a timeline for that PR?

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants