Description
Thank you for the work behind Voila. It is the perfect tool for the demos I had the opportunity to show in the past years. I am however facing an issue in a trick I use to control the flow of a demo.
Description
I use an ipywidget button callback to programmatically drive the execution of a notebook. For example, pressing on a button executes a determined number of cells below the one that created the button. More information regarding notebook commands can be found here.
The approach works in Jupyterlab, but not when rendered with Voila.
Reproduce
Cell 1
import ipywidgets as widgets
from IPython.display import display
from ipylab import JupyterFrontEnd
button = widgets.Button(description="Click Me!")
output = widgets.Output()
app = JupyterFrontEnd()
state = False
clicked = False
display(button, output)
def on_button_clicked(b):
global state, clicked
clicked = True
state = not state
with output:
print("Button clicked.", state)
app.commands.execute('notebook:move-cursor-down')
app.commands.execute('notebook:run-cell-and-select-next')
button.on_click(on_button_clicked)
Cell 2
if clicked:
with output:
print("exec'ed", state)
Execute the first cell, press the button a few times, you should get the following output:
Button clicked. True
exec'ed True
Button clicked. False
exec'ed False
Button clicked. True
exec'ed True
Button clicked. False
exec'ed False
If rendered in Voila, I obtain the following:
Button clicked. True
Button clicked. False
Button clicked. True
Button clicked. False
The callback is executed, but the notebook command has no effect.
The clicked
global skips the execution of the cells I want to control with the button instead.
Expected behavior
I would like the same behavior in Voila as the one observed in the notebook, so that pressing the button triggers the execution of the cell below.
I can't tell whether this is a bug or a feature request, nor whether this is technically achievable when using Voila.
Context
I couldn't spot anything useful in the context.
- voila version 0.5.8
- Operating System and version: Debian trixie/sid
- Browser and version: Chrome 131.0.6778.69
Troubleshoot Output
$PATH: ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/bin /usr/local/bin /usr/bin /bin /usr/local/games /usr/gamessys.path:
${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/bin
/usr/lib/python311.zip
/usr/lib/python3.11
/usr/lib/python3.11/lib-dynload
${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/lib/python3.11/site-packagessys.executable:
${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/bin/pythonsys.version:
3.11.9 (main, Apr 10 2024, 13:16:36) [GCC 13.2.0]platform.platform():
Linux-6.11.5-amd64-x86_64-with-glibc2.40which -a jupyter:
${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/bin/jupyterpip list:
Package Version
--------------------------------- --------------
anyio 4.6.2.post1
argon2-cffi 23.1.0
argon2-cffi-bindings 21.2.0
arrow 1.3.0
asttokens 2.4.1
async-lru 2.0.4
attrs 24.2.0
babel 2.16.0
bap 1.3.1
beautifulsoup4 4.12.3
bleach 6.2.0
certifi 2024.8.30
cffi 1.17.1
charset-normalizer 3.4.0
comm 0.2.2
contourpy 1.3.1
cycler 0.12.1
debugpy 1.8.8
decorator 5.1.1
defusedxml 0.7.1
executing 2.1.0
fastjsonschema 2.20.0
fonttools 4.55.0
fqdn 1.5.1
freetype-py 2.5.1
h11 0.14.0
hsluv 5.0.4
httpcore 1.0.7
httpx 0.27.2
idna 3.10
ipykernel 6.29.5
ipylab 1.0.0
ipympl 0.9.4
ipython 8.29.0
ipython-genutils 0.2.0
ipywidgets 8.1.5
isoduration 20.11.0
jedi 0.19.2
Jinja2 3.1.4
json5 0.9.28
jsonpointer 3.0.0
jsonschema 4.23.0
jsonschema-specifications 2024.10.1
jupyter_client 8.6.3
jupyter_contrib_core 0.4.2
jupyter_contrib_nbextensions 0.7.0
jupyter_core 5.7.2
jupyter-events 0.10.0
jupyter-highlight-selected-word 0.2.0
jupyter-lsp 2.2.5
jupyter_nbextensions_configurator 0.6.4
jupyter_server 2.14.2
jupyter_server_terminals 0.5.3
jupyterlab 4.2.6
jupyterlab_pygments 0.3.0
jupyterlab_server 2.27.3
jupyterlab_widgets 3.0.13
kiwisolver 1.4.7
lief 0.15.1
lxml 5.3.0
MarkupSafe 3.0.2
matplotlib 3.9.2
matplotlib-inline 0.1.7
mistune 3.0.2
nbclient 0.10.0
nbconvert 7.16.4
nbformat 5.10.4
nest-asyncio 1.6.0
networkx 3.4.2
notebook 7.2.2
notebook_shim 0.2.4
numpy 2.1.3
overrides 7.7.0
packaging 24.2
pandocfilters 1.5.1
parso 0.8.4
pexpect 4.9.0
pillow 11.0.0
pip 24.2
platformdirs 4.3.6
prometheus_client 0.21.0
prompt_toolkit 3.0.48
psutil 6.1.0
ptyprocess 0.7.0
pure_eval 0.2.3
pycparser 2.22
Pygments 2.18.0
pyparsing 3.2.0
pypower 2.3.1
PyQt5 5.15.11
PyQt5-Qt5 5.15.15
PyQt5_sip 12.15.0
PyQtWebEngine 5.15.7
PyQtWebEngine-Qt5 5.15.15
python-dateutil 2.9.0.post0
python-json-logger 2.0.7
PyYAML 6.0.2
pyzmq 26.2.0
QDarkStyle 3.0.3
QtPy 2.4.2
referencing 0.35.1
requests 2.32.3
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rpds-py 0.21.0
Send2Trash 1.8.3
setuptools 75.5.0
six 1.16.0
sniffio 1.3.1
soupsieve 2.6
stack-data 0.6.3
tabulate 0.9.0
tenacity 9.0.0
terminado 0.18.1
tinycss2 1.4.0
tornado 6.4.1
traitlets 5.14.3
types-python-dateutil 2.9.0.20241003
typing_extensions 4.12.2
uri-template 1.3.0
urllib3 2.2.3
vispy 0.11.0
voila 0.5.8
wcwidth 0.2.13
webcolors 24.11.1
webencodings 0.5.1
websocket-client 1.8.0
websockets 14.1
wheel 0.44.0
widgetsnbextension 4.0.13
Command Line Output
[Voila] Looking for voila in /etc/jupyter [Voila] Looking for voila in /usr/local/etc/jupyter [Voila] Looking for voila in ${HOME}/.jupyter [Voila] Looking for voila in ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/etc/jupyter [Voila] Looking for voila in /shared/Work/Projects/2024.09.25.Demo_Olivier_Flous/demo_wbc [Voila] Loaded config file: /shared/Work/Projects/2024.09.25.Demo_Olivier_Flous/demo_wbc/voila.json [Voila] using template: lab [Voila] template paths: ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/templates/lab ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/nbconvert/templates/lab /usr/share/jupyter/nbconvert/templates/lab ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/templates/base ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/nbconvert/templates/base /usr/share/jupyter/nbconvert/templates/base ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/templates ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/nbconvert/templates ${HOME}/.local/share/jupyter ${HOME}/.local/share/jupyter/voila/templates ${HOME}/.local/share/jupyter/nbconvert/templates /usr/local/share/jupyter /usr/local/share/jupyter/voila/templates /usr/local/share/jupyter/nbconvert/templates /usr/share/jupyter /usr/share/jupyter/voila/templates /usr/share/jupyter/nbconvert/templates [Voila] static paths: ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/templates/lab/static ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/nbconvert/templates/lab/static ${HOME}/.local/share/jupyter/voila/templates/lab/static ${HOME}/.local/share/jupyter/nbconvert/templates/lab/static /usr/local/share/jupyter/voila/templates/lab/static /usr/local/share/jupyter/nbconvert/templates/lab/static /usr/share/jupyter/voila/templates/lab/static /usr/share/jupyter/nbconvert/templates/lab/static ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/templates/base/static ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/nbconvert/templates/base/static ${HOME}/.local/share/jupyter/voila/templates/base/static ${HOME}/.local/share/jupyter/nbconvert/templates/base/static /usr/local/share/jupyter/voila/templates/base/static /usr/local/share/jupyter/nbconvert/templates/base/static /usr/share/jupyter/voila/templates/base/static /usr/share/jupyter/nbconvert/templates/base/static ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/lib/python3.11/site-packages/jupyter_server/static [Voila] Using /tmp to store connection files [Voila] Storing connection files in /tmp/voila_g1k2qe3t. [Voila] Serving static files from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/lib/python3.11/site-packages/voila/static. [Voila] serving directory: '/shared/Work/Projects/2024.09.25.Demo_Olivier_Flous/demo_wbc' [Voila] Voilà is running at: http://localhost:8866/ [Voila] WARNING | Clearing invalid/expired login cookie username-localhost-8866 [Voila] Generating new user for token-authenticated request: 902b9ae8875a4958a33ee85425f4d1d5 [Voila] Paths used for configuration of page_config: /etc/jupyter/labconfig/page_config.json [Voila] Paths used for configuration of page_config: /usr/local/etc/jupyter/labconfig/page_config.json [Voila] Paths used for configuration of page_config: ${HOME}/.jupyter/labconfig/page_config.json [Voila] Paths used for configuration of page_config: ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/etc/jupyter/labconfig/page_config.json [Voila] Using contents: services/contents [Voila] Path jupyterlab_pygments/static/remoteEntry.5cbb9d2323598fbda535.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/jupyterlab_pygments/static/remoteEntry.5cbb9d2323598fbda535.js [Voila] Path ipylab/static/remoteEntry.1c9b77c557d03a2498f4.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/ipylab/static/remoteEntry.1c9b77c557d03a2498f4.js [Voila] Path @jupyter-notebook/lab-extension/static/remoteEntry.04dfa589925e7e7c6a3d.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/remoteEntry.04dfa589925e7e7c6a3d.js [Voila] Path @jupyter-widgets/jupyterlab-manager/static/remoteEntry.e4ff09401a2f575928c0.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager/static/remoteEntry.e4ff09401a2f575928c0.js [Voila] Path @voila-dashboards/widgets-manager8/static/remoteEntry.958dac8c7410b5fcc9ee.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/labextensions/@voila-dashboards/widgets-manager8/static/remoteEntry.958dac8c7410b5fcc9ee.js [Voila] Path jupyter-matplotlib/static/remoteEntry.a0518cb14ef99e994963.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/jupyter-matplotlib/static/remoteEntry.a0518cb14ef99e994963.js 404 GET /favicon.ico (::1) 0.52ms [Voila] Path jupyterlab_pygments/static/747.67662283a5707eeb4d4c.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/jupyterlab_pygments/static/747.67662283a5707eeb4d4c.js [Voila] Path jupyterlab_pygments/static/568.1e2faa2ba0bbe59c4780.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/jupyterlab_pygments/static/568.1e2faa2ba0bbe59c4780.js [Voila] Path @voila-dashboards/widgets-manager8/static/651.d9c6fa52270ea21fdf9e.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/labextensions/@voila-dashboards/widgets-manager8/static/651.d9c6fa52270ea21fdf9e.js [Voila] Path @voila-dashboards/widgets-manager8/static/264.95d855dc9ed80b79c78e.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/labextensions/@voila-dashboards/widgets-manager8/static/264.95d855dc9ed80b79c78e.js [Voila] Path jupyter-matplotlib/static/480.18f23d468bae372d1c77.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/jupyter-matplotlib/static/480.18f23d468bae372d1c77.js [Voila] Path ipylab/static/480.16044a8abb039e4c2a69.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/ipylab/static/480.16044a8abb039e4c2a69.js [Voila] Path ipylab/static/78.bae6a35721d5e7309228.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/ipylab/static/78.bae6a35721d5e7309228.js [Voila] Path @jupyter-notebook/lab-extension/static/928.bf5955f09ff1e05edfbb.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/928.bf5955f09ff1e05edfbb.js [Voila] Path @jupyter-notebook/lab-extension/static/42.33f638f0a4239bed9676.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/42.33f638f0a4239bed9676.js [Voila] Path @jupyter-notebook/lab-extension/static/568.3dd58d88e32a98358776.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/568.3dd58d88e32a98358776.js [Voila] Path @jupyter-notebook/lab-extension/static/93.eae3497dd223d842d198.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/93.eae3497dd223d842d198.js [Voila] Path @jupyter-widgets/jupyterlab-manager/static/651.fe40a967a60b543cf15c.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager/static/651.fe40a967a60b543cf15c.js [Voila] Path @jupyter-widgets/jupyterlab-manager/static/420.063e2ee9f71033206b1f.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager/static/420.063e2ee9f71033206b1f.js [Voila] Path @jupyter-widgets/jupyterlab-manager/static/439.33696bc45fbd403becbb.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager/static/439.33696bc45fbd403becbb.js [Voila] Path @jupyter-widgets/jupyterlab-manager/static/327.8166aeb81cf1531ca240.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager/static/327.8166aeb81cf1531ca240.js [Voila] Path @jupyter-widgets/jupyterlab-manager/static/722.3fefeac9cae358348cbc.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager/static/722.3fefeac9cae358348cbc.js [Voila] Path @jupyter-widgets/jupyterlab-manager/static/446.bf169bd3821a9ba1aa62.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager/static/446.bf169bd3821a9ba1aa62.js [Voila] Path @voila-dashboards/widgets-manager8/static/883.bbe30bf61f3074749dda.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/labextensions/@voila-dashboards/widgets-manager8/static/883.bbe30bf61f3074749dda.js [Voila] Path @voila-dashboards/widgets-manager8/static/324.aa49bd5aec16839cc9e0.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/labextensions/@voila-dashboards/widgets-manager8/static/324.aa49bd5aec16839cc9e0.js [Voila] Path @voila-dashboards/widgets-manager8/static/603.9866b69497a4a124e57f.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/labextensions/@voila-dashboards/widgets-manager8/static/603.9866b69497a4a124e57f.js [Voila] Path @voila-dashboards/widgets-manager8/static/496.45f50ff8111515264be7.js served from ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/voila/labextensions/@voila-dashboards/widgets-manager8/static/496.45f50ff8111515264be7.js 404 GET /api/kernels?1732034622770 (::1) 0.34ms
Browser Output
Connection lost, reconnecting in 0 seconds. _reconnect @ :8888/static/notebook/3676.bundle.js:1 reconnect @ :8888/static/notebook/3676.bundle.js:1 restart @ :8888/static/notebook/3676.bundle.js:1 await in restart restartKernel @ :8888/static/notebook/9605.bundle.js:2 restart @ :8888/static/notebook/9605.bundle.js:2 await in restart execute @ :8888/static/notebook/1962.bundle.js:1 execute @ :8888/static/notebook/3301.bundle.js:1 onClick @ :8888/static/notebook/7506.bundle.js:703 Yo.r @ :8888/static/notebook/7506.bundle.js:703 Oe @ :8888/static/notebook/1542.bundle.js:2 Be @ :8888/static/notebook/1542.bundle.js:2 (anonymous) @ :8888/static/notebook/1542.bundle.js:2 Ir @ :8888/static/notebook/1542.bundle.js:2 Ur @ :8888/static/notebook/1542.bundle.js:2 (anonymous) @ :8888/static/notebook/1542.bundle.js:2 cs @ :8888/static/notebook/1542.bundle.js:2 Le @ :8888/static/notebook/1542.bundle.js:2 Qr @ :8888/static/notebook/1542.bundle.js:2 qn @ :8888/static/notebook/1542.bundle.js:2 $n @ :8888/static/notebook/1542.bundle.js:2Understand this warningAI Scrolling to a new item is requested.
If using JupyterLab
- JupyterLab version: v4.2.6
Installed Labextensions
JupyterLab v4.2.6 ${HOME}/.local/share/virtualenvs/pipenv-3m7R3yRy/share/jupyter/labextensions jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments) jupyter-matplotlib v0.11.4 enabled OK ipylab v1.0.0 enabled OK (python, ipylab) @voila-dashboards/jupyterlab-preview v2.3.8 enabled OK (python, voila) @jupyter-notebook/lab-extension v7.2.2 enabled OK @jupyter-widgets/jupyterlab-manager v5.0.13 enabled OK (python, jupyterlab_widgets)
Activity