I am using a bunch of ipywidgets in my notebook. Voila gets stuck at “Running …” phase to spin forever, while working properly on Jupyter Lab. I don’t have an issue with my voila setup, because if I put some print statements and remove display, voila loads the page and loads my print lines. Here is the minimal example (the most minimal version I could create ):
import pandas as pd
import plotly.express as px
import ipywidgets as widgets
from IPython.display import display
def update_filter_widgets(change):
if filter_checkbox.value and type_dropdown.value == "t2":
visibility = "visible"
slider.value = 1.5 if method_dropdown.value == 'm1' else 3.0
else:
visibility = "hidden"
method_dropdown.layout.visibility = visibility
slider.layout.visibility = visibility
def update_filter_checkbox(change):
if type_dropdown.value == "t1":
filter_checkbox.layout.visibility = "hidden"
else:
filter_checkbox.layout.visibility = "visible"
update_filter_widgets(None)
def update_plot(file, plot_type, filter, method, padding):
if file == "f1":
data = pd.DataFrame([l.split('\t') for l in f1], columns=['c1', 'c2', 'c3'])
else:
data = pd.DataFrame([l.split('\t') for l in f2], columns=['c1', 'c2', 'c3'])
data['c3'] = pd.to_numeric(data['c3'])
if filter:
tmp = data['c3'] + padding
data['c3'] = tmp / 2 if method == "m1" else tmp / 4
if plot_type == "t1":
fig = px.line(data, x="c1", y="c2")
else:
fig = px.line(data, x="c1", y="c3")
fig.show()
f1 = ["10:36:00\t00:00:00\t0.08", "10:41:00\t08:00:00\t0.04"]
f2 = ["11:06:00\t04:00:00\t2.07", "11:11:00\t16:00:00\t1.85"]
file_dropdown = widgets.Dropdown(options=["f1", "f2"], description="File: ")
type_dropdown = widgets.Dropdown(options=["t1", "t2"], description="Type: ")
method_dropdown = widgets.Dropdown(options=["m1", "m2"], value="m1", description="Method")
filter_checkbox = widgets.Checkbox(value=False, description="Filter")
slider = widgets.FloatSlider(value=1.5, min=0, max=5, step=0.1, description="Threshold")
type_dropdown.observe(update_filter_checkbox, names='value')
filter_checkbox.observe(update_filter_widgets, names='value')
method_dropdown.observe(update_filter_widgets, names='value')
update_filter_checkbox(None)
interactive_plot = widgets.interactive(update_plot, file=file_dropdown, plot_type=type_dropdown,
filter=filter_checkbox, method=method_dropdown, padding=slider)
display(interactive_plot)
After reading about some issues of voila with ipywidgets 8, I downgraded it to 7.6.5 and 7.7.2, but this didn’t help.