voila-dashboards / voila-vuetify

Dashboard template for Voilà based on VuetifyJS
Other
153 stars 41 forks source link

voila-vuetify does not work, and breaks voila #67

Open Paul-Aime opened 5 months ago

Paul-Aime commented 5 months ago

Bug report

voila-vuetify does not work, and breaks voila.

How should I go to make it work ?

Case 1

If I create a new environment with voila-vuetify and voila, it gives the old voila-0.3.3 version and then even using voila without template does not work.

$ conda create -n voila-vuetify voila ipykernel ipywidgets ipyvuetify voila-vuetify
$ conda list | grep -E "voila|ipyvuetify|ipykernel"
# packages in environment at /home/paul/miniconda3/envs/voila-vuetify:
ipykernel                 6.29.0             pyhd33586a_0    conda-forge
ipyvuetify                1.8.10             pyhd8ed1ab_0    conda-forge
voila                     0.3.3              pyhd8ed1ab_0    conda-forge
voila-vuetify             0.6.0              pyhd8ed1ab_0    conda-forge

Trying to run voila-vuetify/ManyWidgets.ipynb:

$ voila ManyWidgets.ipynb

Traceback (most recent call last):
  File "/home/paul/miniconda3/envs/voila-vuetify/bin/voila", line 6, in <module>
    from voila.app import main
  File "/home/paul/miniconda3/envs/voila-vuetify/lib/python3.12/site-packages/voila/__init__.py", line 11, in <module>
    from .server_extension import _load_jupyter_server_extension # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/miniconda3/envs/voila-vuetify/lib/python3.12/site-packages/voila/server_extension.py", line 21, in <module>
    from .handler import VoilaHandler
  File "/home/paul/miniconda3/envs/voila-vuetify/lib/python3.12/site-packages/voila/handler.py", line 24, in <module>
    from .notebook_renderer import NotebookRenderer
  File "/home/paul/miniconda3/envs/voila-vuetify/lib/python3.12/site-packages/voila/notebook_renderer.py", line 24, in <module>
    from .exporter import VoilaExporter
  File "/home/paul/miniconda3/envs/voila-vuetify/lib/python3.12/site-packages/voila/exporter.py", line 15, in <module>
    from jinja2 import contextfilter
ImportError: cannot import name 'contextfilter' from 'jinja2' (/home/paul/miniconda3/envs/voila-vuetify/lib/python3.12/site-packages/jinja2/__init__.py)

Case 2

$ conda create -n voila-vuetify-pip voila ipykernel ipywidgets ipyvuetify
$ pip install voila-vuetify
$ conda list | grep -E "voila|ipyvuetify|ipykernel"
# packages in environment at /home/paul/miniconda3/envs/voila-vuetify-pip:
ipykernel                 6.29.0             pyhd33586a_0    conda-forge
ipyvuetify                1.8.10             pyhd8ed1ab_0    conda-forge
voila                     0.4.3                    pypi_0    pypi
voila-vuetify             0.6.0                    pypi_0    pypi

Running without template, the widgets are displayed, but I have the following errors:

$ voila ManyWidgets.ipynb

403 GET /voila/files/voila/jupyter-vue.js (127.0.0.1): File not whitelisted
403 GET /voila/files/voila/jupyter-vue.js (127.0.0.1) 1.22ms
403 GET /voila/files/voila/jupyter-vuetify.js (127.0.0.1): File not whitelisted
403 GET /voila/files/voila/jupyter-vuetify.js (127.0.0.1) 0.44ms

Running with the vuetify-default template, the widgets are not displayed, and I have the following errors:

$ voila --template vuetify-default ManyWidgets.ipynb

403 GET /voila/files/846.voila.js (127.0.0.1): File not whitelisted
403 GET /voila/files/846.voila.js (127.0.0.1) 1.15ms
403 GET /voila/files/6914.voila.js (127.0.0.1): File not whitelisted
403 GET /voila/files/6914.voila.js (127.0.0.1) 0.57ms
403 GET /voila/files/8291.voila.js (127.0.0.1): File not whitelisted
403 GET /voila/files/8291.voila.js (127.0.0.1) 0.40ms

404 GET /api/kernels/86956e0a-1a7f-4338-9264-c39c8f65fc02?1705880536585 (127.0.0.1): Kernel does not exist: 86956e0a-1a7f-4338-9264-c39c8f65fc02
[Voila] WARNING | wrote error: 'Kernel does not exist: 86956e0a-1a7f-4338-9264-c39c8f65fc02'
Traceback (most recent call last):
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/tornado/web.py", line 1786, in _execute
    result = await result
             ^^^^^^^^^^^^
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/auth/decorator.py", line 73, in inner
    return await out
           ^^^^^^^^^
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/services/kernels/handlers.py", line 74, in get
    model = await ensure_async(km.kernel_model(kernel_id))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 500, in kernel_model
    self._check_kernel_id(kernel_id)
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 531, in _check_kernel_id
    raise web.HTTPError(404, "Kernel does not exist: %s" % kernel_id)
tornado.web.HTTPError: HTTP 404: Not Found (Kernel does not exist: 86956e0a-1a7f-4338-9264-c39c8f65fc02)
404 GET /api/kernels/86956e0a-1a7f-4338-9264-c39c8f65fc02?1705880536585 (127.0.0.1) 2.46ms
404 GET /api/kernels/86956e0a-1a7f-4338-9264-c39c8f65fc02/channels?session_id=7e201f66-7c32-432c-9b9f-0dd174577783 (127.0.0.1): Kernel does not exist: 86956e0a-1a7f-4338-9264-c39c8f65fc02
Could not open static file '/favicon.ico'
Could not open static file '/style/bootstrap.min.css'
Could not open static file '/style/bootstrap-theme.min.css'
Could not open static file '/style/index.css'
Could not open static file '/logo/logo.png'

Case 3

I also tried manually copy-pasting the files from the voila-vuetify repository to the ~/miniconda3/envs/voila/share/jupyter/{voila,nbconvert}/templates folders, but it did not work either.

$ conda create -n voila voila ipykernel ipywidgets ipyvuetify 
$ conda list | grep -E "voila|ipyvuetify|ipykernel"
# packages in environment at /home/paul/miniconda3/envs/voila:
ipykernel                 6.29.0             pyhd33586a_0    conda-forge
ipyvuetify                1.8.10             pyhd8ed1ab_0    conda-forge
voila                     0.5.5              pyhd8ed1ab_0    conda-forge

I get the same error as "Case 2" when running voila --template vuetify-default ManyWidgets.ipynb.


Any help would be appreciated, thanks!

maartenbreddels commented 5 months ago
```shell
ImportError: cannot import name 'contextfilter' from 'jinja2' (/home/paul/miniconda3/envs/voila-vuetify/lib/python3.12/site-packages/jinja2/__init__.py)

This seems like some jinja version mismatch (not a specific voila-vuetify issue).

403 GET /voila/files/voila/jupyter-vue.js (127.0.0.1): File not whitelisted

This could be ok, if it falls back to the CDN fetch afterwards, if you want to get rid of it you can run with the nbextension enable flag.

I did notice that https://github.com/conda-forge/voila-vuetify-feedstock/pull/12 did not update the pinning to allow voila 0.4, mimicking https://github.com/voila-dashboards/voila-vuetify/commit/c65f5d9e9044a3b52ba6dc4f2f2698b29b039cbe

It's really annoying to keep these pins in sync manually. @mariobuikhuizen we need to do a fix release for this on conda-forge one day. In the meantime, you can try post-installing with pip.

Hope this helps.

Maarten

Paul-Aime commented 5 months ago

Thanks for the answer.

I tried post-installing with pip, that's the "Case 2".

In that case, voila --enable_nbextensions=true ManyWidgets.ipynb works almost fine, even if some errors are displayed:

Could not open static file '/favicon.ico'
Could not open static file '/style/bootstrap.min.css'
Could not open static file '/style/bootstrap-theme.min.css'
Could not open static file '/style/index.css'
Could not open static file '/logo/logo.png'
404 GET /voila/nbextensions/jupyter-black-master/kernel_exec_on_cell (127.0.0.1) 14.87ms

BUT trying to use the template with voila --enable_nbextensions=true --template vuetify-default ManyWidgets.ipynb still gives following errors, and the web page is stuck on "Executing cell 4 of 4" view.

403 GET /voila/files/358.voila.js (127.0.0.1) 0.90ms
...
404 GET /api/kernels/745ad2f5-9d1d-4eda-8047-26da9a5c28d2?1705918743214 (127.0.0.1): Kernel does not exist: 745ad2f5-9d1d-4eda-8047-26da9a5c28d2
[Voila] WARNING | wrote error: 'Kernel does not exist: 745ad2f5-9d1d-4eda-8047-26da9a5c28d2'
...
Traceback (most recent call last):
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/tornado/web.py", line 1786, in _execute
    result = await result
             ^^^^^^^^^^^^
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/auth/decorator.py", line 73, in inner
    return await out
           ^^^^^^^^^
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/services/kernels/handlers.py", line 74, in get
    model = await ensure_async(km.kernel_model(kernel_id))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 500, in kernel_model
    self._check_kernel_id(kernel_id)
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 531, in _check_kernel_id
    raise web.HTTPError(404, "Kernel does not exist: %s" % kernel_id)
tornado.web.HTTPError: HTTP 404: Not Found (Kernel does not exist: 745ad2f5-9d1d-4eda-8047-26da9a5c28d2)
404 GET /api/kernels/745ad2f5-9d1d-4eda-8047-26da9a5c28d2?1705918743214 (127.0.0.1) 3.38ms
404 GET /api/kernels/745ad2f5-9d1d-4eda-8047-26da9a5c28d2/channels?session_id=767270eb-69b0-4633-a23e-aefed57fcfea (127.0.0.1): Kernel does not exist: 745ad2f5-9d1d-4eda-8047-26da9a5c28d2
404 GET /api/kernels/745ad2f5-9d1d-4eda-8047-26da9a5c28d2/channels?session_id=767270eb-69b0-4633-a23e-aefed57fcfea (127.0.0.1) 2.69ms
404 GET /api/kernels/745ad2f5-9d1d-4eda-8047-26da9a5c28d2?1705918744234 (127.0.0.1): Kernel does not exist: 745ad2f5-9d1d-4eda-8047-26da9a5c28d2
[Voila] WARNING | wrote error: 'Kernel does not exist: 745ad2f5-9d1d-4eda-8047-26da9a5c28d2'
Traceback (most recent call last):
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/tornado/web.py", line 1786, in _execute
    result = await result
             ^^^^^^^^^^^^
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/auth/decorator.py", line 73, in inner
    return await out
           ^^^^^^^^^
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/services/kernels/handlers.py", line 74, in get
    model = await ensure_async(km.kernel_model(kernel_id))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 500, in kernel_model
    self._check_kernel_id(kernel_id)
  File "/home/paul/miniconda3/envs/voila-vuetify-pip/lib/python3.12/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 531, in _check_kernel_id
    raise web.HTTPError(404, "Kernel does not exist: %s" % kernel_id)
tornado.web.HTTPError: HTTP 404: Not Found (Kernel does not exist: 745ad2f5-9d1d-4eda-8047-26da9a5c28d2)

Is it reproducible?

maartenbreddels commented 5 months ago

Is it reproducible?

what are you referring to?

I think what you have is a very old voila with modern jupyter stack, you might be able to fix this by downgrading some of the jupyter dependencies. However, I recommend using a modern voila (using pip for now).

Paul-Aime commented 5 months ago

I mean, can't you reproduce the issue?

Because for me, even with a full pip installation it does not work.

Python installation:

$ pyenv global miniconda3-3.11-23.11.0-2  # miniconda3 for sqlite3
$ pyenv global miniconda3-3.11-23.11.0-2
$ python --version
Python 3.11.5

Environment installation without voila-vuetify:

$ python -m venv venv-voila
$ source venv-voila/bin/activate
$ python -m pip install voila ipykernel ipywidgets ipyvuetify
$ python -m pip list | grep -E "voila|ipyvue"
ipyvue                    1.10.1
ipyvuetify                1.8.10
voila                     0.5.5

voila ManyWidgets.ipynb works ok, no warning or error.

Environment installation with voila-vuetify:

$ python -m venv venv-voila-vuetify
$ source venv-voila/bin/activate
$ python -m pip install voila ipykernel ipywidgets ipyvuetify voila-vuetify
$ python -m pip list | grep -E "voila|ipyvue"
ipyvue                    1.10.1
ipyvuetify                1.8.10
voila                     0.4.3
voila-vuetify             0.6.0

voila ManyWidgets.ipynb works ok but 403 GET /voila/files/voila/jupyter-vue.js (127.0.0.1): File not whitelisted warning is displayed.

However, using the template vuetify-default again stalls on "Executing cell 4 of 4" view, with following logs (the part about "Could not open static file '/favicon.ico'" only appears when enabling nbextensions):

$ voila --enable_nbextensions=true --template vuetify-default ManyWidgets.ipynb
[Voila] Using /tmp to store connection files
[Voila] Storing connection files in /tmp/voila_pmuwyuus.
[Voila] Serving static files from /home/paul/Desktop/dashboard_tests/test_voila/venv-voila-vuetify/lib/python3.11/site-packages/voila/static.
[Voila] Voilà is running at:
http://localhost:8866/
[Voila] WARNING | Clearing invalid/expired login cookie username-localhost-8866
[Voila] WARNING | Notebook ManyWidgets.ipynb is not trusted
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[Voila] Kernel started: 98babba4-f4eb-4dd2-af18-c561d62fb6eb
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Could not open static file '/favicon.ico'
Could not open static file '/style/bootstrap.min.css'
Could not open static file '/style/bootstrap-theme.min.css'
Could not open static file '/style/index.css'
Could not open static file '/logo/logo.png'
404 GET /voila/nbextensions/jupyter-black-master/kernel_exec_on_cell (127.0.0.1) 15.13ms
403 GET /voila/files/846.voila.js (127.0.0.1): File not whitelisted
403 GET /voila/files/846.voila.js (127.0.0.1) 0.80ms
403 GET /voila/files/8291.voila.js (127.0.0.1): File not whitelisted
...
maartenbreddels commented 5 months ago

We don't support voila 0.5, so:

python -m pip install "voila < 0.5"

I don't have the time to reproduce it now.

Paul-Aime commented 5 months ago

Yes, voila-vuetify installation pins voila to 0.4.3, see "Environment installation with voila-vuetify" above, where it still doesn't work.

I understand that you don't have the time to reproduce, thanks for answering.

maartenbreddels commented 5 months ago

Did you do all this from a new environment? And just to be sure, keep the dev console in your browser open and make sure caching is turned off in the network tab.

Paul-Aime commented 5 months ago

Yes, new environment everytime, see installation steps above.

Disabling network cache did solve the issue! (Note: need to replace {'mount_id': 'content'} with {'mount_id': 'content-main'} in ManyWidgets.ipynb).

So it works with voila==0.4.3 and voila-vuetify==0.6.0, and if it failed for some reason, disabling cache is needed.

Strangely, errors are still thrown even when it works, so copying them there for reference:

Browser console errors log:

The resource from “http://localhost:8866/voila/nbextensions/jupyter-black-master/kernel_exec_on_cell” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
[localhost:8866](http://localhost:8866/)
Loading failed for the <script> with source “http://localhost:8866/voila/nbextensions/jupyter-black-master/kernel_exec_on_cell”. [localhost:8866:1:1](http://localhost:8866/)
Uncaught Error: Script error for "/voila/nbextensions/jupyter-black-master/kernel_exec_on_cell", needed by: /voila/nbextensions/jupyter-black-master/jupyter-black.js
http://requirejs.org/docs/errors.html#scripterror
    makeError http://localhost:8866/voila/static/require.min.js:1
    onScriptError http://localhost:8866/voila/static/require.min.js:1
[require.min.js:1:1067](http://localhost:8866/voila/static/require.min.js)
    makeError http://localhost:8866/voila/static/require.min.js:1
    onScriptError http://localhost:8866/voila/static/require.min.js:1
GET http://localhost:8866/voila/files/favicon.ico
GET http://localhost:8866/voila/files/voila/jupyter-vue/nodeps.js
GET http://localhost:8866/voila/files/voila/jupyter-vuetify/nodeps.js

Terminal logs:

404 GET /api/kernels/f3aeab3f-8100-4c9a-9960-908bc8b66ad3?1705936903898 (127.0.0.1): Kernel does not exist: f3aeab3f-8100-4c9a-9960-908bc8b66ad3
[Voila] WARNING | wrote error: 'Kernel does not exist: f3aeab3f-8100-4c9a-9960-908bc8b66ad3'
Traceback (most recent call last):
  File "/home/paul/Desktop/dashboard_tests/test_voila/venv-voila-vuetify/lib/python3.11/site-packages/tornado/web.py", line 1790, in _execute
    result = await result
             ^^^^^^^^^^^^
  File "/home/paul/Desktop/dashboard_tests/test_voila/venv-voila-vuetify/lib/python3.11/site-packages/jupyter_server/auth/decorator.py", line 73, in inner
    return await out
           ^^^^^^^^^
  File "/home/paul/Desktop/dashboard_tests/test_voila/venv-voila-vuetify/lib/python3.11/site-packages/jupyter_server/services/kernels/handlers.py", line 74, in get
    model = await ensure_async(km.kernel_model(kernel_id))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/Desktop/dashboard_tests/test_voila/venv-voila-vuetify/lib/python3.11/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 500, in kernel_model
    self._check_kernel_id(kernel_id)
  File "/home/paul/Desktop/dashboard_tests/test_voila/venv-voila-vuetify/lib/python3.11/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 531, in _check_kernel_id
    raise web.HTTPError(404, "Kernel does not exist: %s" % kernel_id)
tornado.web.HTTPError: HTTP 404: Not Found (Kernel does not exist: f3aeab3f-8100-4c9a-9960-908bc8b66ad3)
404 GET /api/kernels/f3aeab3f-8100-4c9a-9960-908bc8b66ad3?1705936903898 (127.0.0.1)

Thanks for your help!