Closed mgunyho closed 4 days ago
Hi, I tested this with 0.5.2 now, and the HoloMap is displayed, but still not fully functioning: the slider does not appear.
Compare to the example in the documentation:
Or in Jupyter:
Having these sliders is the main reason for using Holoviews / HoloMap for me, and this is keeping me from using marimo as my main notebook.
For reference, here is the code for the MWE
import numpy as np
import holoviews as hv
hv.extension("bokeh")
_t = np.linspace(0, 10, 101)
hv.HoloMap(
{f: hv.Curve((_t, np.sin(f * _t))) for f in [0.5, 0.75, 1.0]},
kdims="frequency",
)
Also here's the output of marimo env
, let me know if you need some more information.
{
"marimo": "0.5.2",
"OS": "Linux",
"OS Version": "5.15.0-105-generic",
"Processor": "x86_64",
"Python Version": "3.8.10",
"Binaries": {
"Browser": "124.0.6367.207",
"Node": "--"
},
"Requirements": {
"click": "8.1.7",
"importlib-resources": "6.4.0",
"jedi": "0.19.1",
"markdown": "3.6",
"pymdown-extensions": "10.8.1",
"pygments": "2.18.0",
"tomlkit": "0.12.5",
"uvicorn": "0.29.0",
"starlette": "0.37.2",
"websocket": "missing",
"typing-extensions": "4.11.0",
"black": "24.4.2"
}
}
Right now, we render HoloMap by converting it to its backend (bokeh/plotly/matplotlib) and then rendering using those specific formatters (e.g. bokeh) to convert to HTML. I think the fix would be to render the HoloMap using panel which seems to be the one adding the slider. I am not familiar enough with that library to support rendering going from HoloMap -> HTML
using panel, but if anyone is, we would welcome a contribution.
I can't claim to have a lot of expertise here, but I would be willing to put in some time to work on this if someone is able to provide some guidance to get me started.
I rely heavily on the holoviews ecosystem for data exploration (using e.g. datashader) and would love to be able to give marimo a real go as a jupyter replacement.
Hey @smutch, @philippjfr is actually going to look at helping us support Panel this week. He or I can report back if we could use some help here.
Hi @mscolnick & @philippjfr. Thanks for the great work on this. Really excited to see more of the Holoviz ecosystem make its way into Marimo.
I saw that the #2719 was merged and tried to give things a go but I found that holoviews plots are still not updating with panel sliders etc. Minimal working example below. Hopefully this is useful and apologies if it's known and on the roadmap - I recognize this is still early days!
import marimo
__generated_with = "0.9.14"
app = marimo.App(width="medium")
@app.cell
def __():
import holoviews as hv
import panel as pn
import marimo as mo
pn.extension()
return hv, mo, pn
@app.cell
def __(hv):
hv.DynamicMap(
lambda v: hv.Curve([1, 2 * v, 3]).opts(title="Doesn't work"),
kdims=hv.Dimension("v", range=(0, 5), default=1),
)
return
@app.cell
def __(pn):
slider = pn.widgets.IntSlider(start=0, end=10, name="Does work")
slider.rx() * "🎉"
return (slider,)
@app.cell
def __(hv, pn):
plot_slider = pn.widgets.IntSlider(start=0, end=10, name="Doesn't work either")
pn.rx(lambda v: hv.Curve([1, 2 * v, 3]))(plot_slider)
return (plot_slider,)
@app.cell
def __():
return
if __name__ == "__main__":
app.run()
Further investigation seems to suggest that the error is possibly due to embedded state and binary buffers as the error message (see below) is similar to https://github.com/holoviz/holoviews/issues/5601#issuecomment-1415306414.
Uncaught Error: Expected binary fragment but received text fragment
_assume_binary https://cdn.bokeh.org/bokeh/release/bokeh-3.6.0.min.js:236
_BUFFER_PAYLOAD https://cdn.bokeh.org/bokeh/release/bokeh-3.6.0.min.js:236
consume https://cdn.bokeh.org/bokeh/release/bokeh-3.6.0.min.js:236
w http://localhost:2718/assets/index-BLbE17NO.js:72
n http://localhost:2718/assets/index-BLbE17NO.js:31
broadcastMessage http://localhost:2718/assets/index-BLbE17NO.js:70
broadcastMessage http://localhost:2718/assets/index-BLbE17NO.js:70
D http://localhost:2718/assets/useMarimoWebSocket-x2rME3kL.js:21
R http://localhost:2718/assets/useMarimoWebSocket-x2rME3kL.js:21
e http://localhost:2718/assets/useMarimoWebSocket-x2rME3kL.js:14
_addListeners http://localhost:2718/assets/useMarimoWebSocket-x2rME3kL.js:14
_connect http://localhost:2718/assets/useMarimoWebSocket-x2rME3kL.js:14
promise callback*_connect http://localhost:2718/assets/useMarimoWebSocket-x2rME3kL.js:14
reconnect http://localhost:2718/assets/useMarimoWebSocket-x2rME3kL.js:14
P http://localhost:2718/assets/useMarimoWebSocket-x2rME3kL.js:21
sc http://localhost:2718/assets/index-BLbE17NO.js:31
Pu http://localhost:2718/assets/index-BLbE17NO.js:31
fu http://localhost:2718/assets/index-BLbE17NO.js:31
Bi http://localhost:2718/assets/index-BLbE17NO.js:31
Cu http://localhost:2718/assets/index-BLbE17NO.js:31
Cu http://localhost:2718/assets/index-BLbE17NO.js:31
lu http://localhost:2718/assets/index-BLbE17NO.js:31
w http://localhost:2718/assets/index-BLbE17NO.js:22
E http://localhost:2718/assets/index-BLbE17NO.js:22
EventHandlerNonNull* http://localhost:2718/assets/index-BLbE17NO.js:22
<anonymous> http://localhost:2718/assets/index-BLbE17NO.js:22
5 bokeh-3.6.0.min.js:236:1101
I've tried to debug this myself, but there is too much going on for me to understand where exactly the potential issue lies without further guidance I'm afraid.
huge thanks to @philippjfr for fixing this!
Describe the bug
If I try to display a Holoviews
HoloMap
orDynamicMap
, I get blank/textual output instead of an interactive plot (example code taken from Holoviews docs):See here how it should look like: https://holoviews.org/reference/containers/bokeh/HoloMap.html
I would like to use Holoviews with
HoloMap
/DynamicMap
to visualize multidimensional data using sliders, which I currently do very often in Jupyter. I understand that this is a bit redundant since marimo has it's own slider widget, but I couldn't find a better way to do this kind of slicing through multidimensional data (I tried Altair, but there the sliders cannot handle values that are not evenly spaced).This can probably be fixed by adding one of the superclasses of
HoloMap
toHoloviewsFormatter._show_chart
here. Here's the inheritance hierarchy ofHoloMap
:I'm not familiar enough with the internals of holoviews to say which of these should be added to
_show_chart
.DynamicMap
is a subclass ofHoloMap
.As a bonus, if I convert the HoloMap to a layout with
hv.Layout(hv.HoloMap(...))
, the cell grows indefinitely (similar to #978):https://github.com/marimo-team/marimo/assets/20118130/3d316294-ea77-4f73-8a88-839bc65f6e02
I'm using a virtualenv with
pip install marimo matplotlib tornado holoviews
. Here's the full output ofpip list
: Click to showI am using Python 3.8 with Ubuntu 20.04 on Firefox 123.0.1
Environment
Code to reproduce