voila-dashboards / voici

Voici turns any Jupyter Notebook into a static web application
https://voici.readthedocs.io/
Other
154 stars 8 forks source link

ipywidgets.Output has stopped working in voici (still works in jupyterlite though) #127

Open LiamBindle opened 1 week ago

LiamBindle commented 1 week ago

Description

I recently upgraded to xeus-python=0.17 because 0.16 stopped working for me and now I'm having trouble getting ipywidgets.Output() to work. When I update an output widget nothing happens. I think the bug is stems from voici because when I build the notebook with jupyterlite ipywidgets.Output() works as expected.

I created a reproducer here

import ipywidgets
from datetime import datetime

output = ipywidgets.Output()
button = ipywidgets.Button(description='Click me')

display(button)
display(output)

def on_click(*args):
    output.clear_output()

    with output:
        print(datetime.now().isoformat())
button.on_click(on_click)

With jupyterlite (expected behaviour) Screenshot_1

With voici (nothing happens) Screenshot_2

Reproduce

You can build the reproducer like so (I also included a build-environment.yml within...I'm using voici 0.7)

git clone https://github.com/LiamBindle/voici-ipywidget-output-bug-reproducer.git
cd voici-ipywidget-output-bug-reproducer
voici build --contents content --apps lab --apps retro

Serve the files

cd _output
python -m http.server 8010

See that ipywidgets.Output() works in jupyterlite: http://0.0.0.0:8010/lab/index.html

See that ipywidgets.Output() doesn't work in voici: http://0.0.0.0:8010/voici/render/content/reproducer.html?


Any thoughts? Thanks in advance!

LiamBindle commented 1 week ago

CCing @martinRenou, @DerThorsten, and @jtpio

LiamBindle commented 6 days ago

https://github.com/voila-dashboards/voici/issues/121 might be related, but I tried it's reproducer also exhibited the bug in jupyter lite (whereas #127 is isolated to voici).

I've also confirmed that the traitlet is firing by adding a GET request upon the button click (I can see the GET request firing in the network tab), so it seems this issue is related to the redraw.

DerThorsten commented 6 days ago

@LiamBindle unfortunately I dont know much about voici, but hope that @martinRenou or @jtpio can help

martinRenou commented 6 days ago

There shouldn't be anything specific to Voici. The only thing that comes to my mind is that voici was requiring the alpha version of jupyterlite-xeus https://github.com/voila-dashboards/voici/blob/main/python/voici/pyproject.toml#L36 which was having some issues recently.

I just made a final release of jupyterlite-xeus. Can you try again a new build and see if you still see the issue?

LiamBindle commented 6 days ago

Thanks @DerThorsten and @martinRenou

Hmm, strange that there should be anything unique to voici. I'm definitely seeing the bug in voici but not jupyterlite. That seems like a good lead.

I'll try the new jupyterlite-xeus right now and get back to you

LiamBindle commented 6 days ago

@martinRenou I'm afraid upgrading to jupyterlite-xeus=2.0.0 didn't fix the problem. I've double checked that my build environment is indeed using jupyterlite-xeus=2.0.0. Here's a comparison of the jupyter lite vs voici console log.

Console log with Jupyter Lite (works) ![image](https://github.com/user-attachments/assets/d1a6406c-b3e3-4820-b001-bea25701baa1) ![image](https://github.com/user-attachments/assets/02b8b5bb-280b-431b-9077-e4dba511f9b7)
Console log with Voici (doesn't work) ![image](https://github.com/user-attachments/assets/df8b6e90-aa41-4491-b1ba-ddb4278084c8) ![image](https://github.com/user-attachments/assets/d09256e0-7dbc-4db0-ab16-eacb3e6c8e0e)

The main differences I see are:

  1. The voici log has a bunch of warnings about unsatisfied versions

    Example

    Unsatisfied version 4.3.4 from _JUPYTERLAB.CORE_OUTPUT of shared singleton module @jupyterlab/apputils (required ^4.3.5)

  2. The voici log has warning about failing to fetch ipywidgets through the "jupyter.widget.control" comm channel

    Example

    Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm did not respond in time

Do you have any insight? I'm happy to keep digging but I'd benefit if someone could point me in the right direction.

trungleduc commented 6 days ago

@LiamBindle are you using the latest version of ipywidgets? could you try some previous versions? There are some changes in the newest version that might affect voici.

LiamBindle commented 6 days ago

@trungleduc Thanks for the suggestion. I have tried earlier versions of 8 and I get the same problem. In fact, I've tried pinning all packages (including dependencies) to versions that were released prior to June 2024 and that doesn't work either, but I know these versions used to work with voici because we exercise them pretty heavily.

The only package that I haven't been able to pin to a pre-June version is xeus-python because v0.16 seems to have stopped working due to an error creating the default directories when xpython is initializing (I'm not sure why this error wasn't an issue previously).

Any ideas?