GithubHelp home page GithubHelp logo

voila-dashboards / voila Goto Github PK

View Code? Open in Web Editor NEW
5.2K 76.0 492.0 21 MB

Voilà turns Jupyter notebooks into standalone web applications

Home Page: https://voila.readthedocs.io

License: Other

JavaScript 1.68% Python 46.23% Jupyter Notebook 27.42% Smarty 0.40% HTML 2.16% TypeScript 18.11% CSS 0.24% Jinja 3.64% Shell 0.10%
jupyter jupyter-notebook jupyterlab-extension dashboarding

voila's Introduction

voila

Documentation Binder Discourse Join the Gitter Chat

Rendering of live Jupyter notebooks with interactive widgets.

Introduction

Voilà turns Jupyter notebooks into standalone web applications.

Unlike the usual HTML-converted notebooks, each user connecting to the Voilà tornado application gets a dedicated Jupyter kernel which can execute the callbacks to changes in Jupyter interactive widgets.

  • By default, Voilà disallows execute requests from the front-end, preventing execution of arbitrary code.
  • By default, Voilà runs with the strip_sources option, which strips out the input cells from the rendered notebook.

Installation

Voilà can be installed with the mamba (or conda) package manager from conda-forge

mamba install -c conda-forge voila

or from PyPI

pip install voila

JupyterLab preview extension

Voilà provides a JupyterLab extension that displays a Voilà preview of your Notebook in a side-pane.

Starting with JupyterLab 3.0, the extension is automatically installed after installing voila with pip install voila.

If you would like to install the extension from source, run the following command.

jupyter labextension install @voila-dashboards/jupyterlab-preview

Usage

As a standalone tornado application

To render the bqplot example notebook as a standalone app, run voila bqplot.ipynb. To serve a directory of jupyter notebooks, run voila with no argument.

For example, to render the example notebook bqplot.ipynb from this repository with Voilà, you can first update your current environment with the requirements of this notebook (in this case in a conda environment and render the notebook with

mamba env update -f .binder/environment.yml
cd notebooks/
voila bqplot.ipynb

For more command line options (e.g., to specify an alternate port number), run voila --help.

As a server extension to notebook or jupyter_server

Voilà can also be used as a Jupyter server extension, both with the notebook server or with jupyter_server.

To install the Jupyter server extension, run

jupyter serverextension enable voila
jupyter server extension enable voila

When running the Jupyter server, the Voilà app is accessible from the base url suffixed with voila.

Documentation

To get started with using Voilà, check out the full documentation:

https://voila.readthedocs.io/

Examples

The following two examples show how a standalone Jupyter notebook can be turned into a separate app, from the command-line integration.

Rendering a notebook including interactive widgets and rich mime-type rendering

Voilà basics

Rendering a notebook making use of a custom widget library (bqplot)

Voilà bqplot

Showing the source code for a Voilà notebook

The sources of the Jupyter notebook can be displayed in a Voilà app if option strip_sources is set to False.

Voilà sources

Voilà dashboards with other language kernels**

Voilà is built upon Jupyter standard formats and protocols, and is agnostic to the programming language of the notebook. In this example, we present an example of a Voilà application powered by the C++ Jupyter kernel xeus-cling, and the xleaflet project.

Voilà cling

The Voilà Gallery

The Voilà Gallery is a collection of live dashboards and applications built with Voilà and Jupyter widgets.

Most of the examples rely on widget libraries such as ipywidgets, ipyleaflet, ipyvolume, bqplot and ipympl, and showcase how to build complex web applications entirely based on notebooks.

New examples can be added to the gallery by following the steps listed in the voila-gallery/gallery repository.

Development

See CONTRIBUTING.md to know how to contribute and set up a development environment.

Related projects

Voilà depends on nbconvert and jupyter_server.

License

We use a shared copyright model that enables all contributors to maintain the copyright on their contributions.

This software is licensed under the BSD-3-Clause license. See the LICENSE file for details.

voila's People

Contributors

12rambau avatar aartgoossens avatar azjps avatar cailiang9 avatar choldgraf avatar danlester avatar davidbrochart avatar dcnadler avatar dependabot[bot] avatar georgianaelena avatar giswqs avatar github-actions[bot] avatar hbcarlos avatar ivanov avatar jabbera avatar jeffyjefflabs avatar jtpio avatar katsar0v avatar maartenbreddels avatar mariobuikhuizen avatar martinrenou avatar mkcor avatar msuperina avatar ohrely avatar pre-commit-ci[bot] avatar rensdimmendaal avatar sylvaincorlay avatar timkpaine avatar trungleduc avatar vidartf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voila's Issues

Configure Content Security Policy (CSP)

I was trying to access voila from a non-localhost IP and I was getting some CSP violations, so following @Carreau's advice here I added the following configuration:

--- /home/juanlu/.local/share/virtualenvs/poseidon-oYfLlCwx/src/voila/voila/app.py.old	2018-11-28 01:31:54.073333937 +0100
+++ /home/juanlu/.local/share/virtualenvs/poseidon-oYfLlCwx/src/voila/voila/app.py	2018-11-28 01:32:45.897266756 +0100
@@ -141,8 +141,7 @@
             jinja2_env=env,
             static_path='/',
             server_root_dir='/',
-            contents_manager=contents_manager
+            contents_manager=contents_manager,
+            headers={'Content-Security-Policy': "frame-ancestors 'self' http://host.eu"},
         )
 
         base_url = webapp.settings.get('base_url', '/')

Is there a better way to do it?

Report errors when notebook execution fails

Currently, this merely results in a 503 error screen.

More details could be made available to the user (optionally since, this could give information about the code being executed).

Minimal Example of Serving on Digital Ocean

I'm trying to get a minimal working example running on a minimal Digital Ocean Ubuntu droplet using the basics.ipynb notebook and all it displays is the sum 0 * 0 = 0 (no widgets).

Console reports:

Starting WebSocket: ws://167.99.204.193/api/kernels/4535d22f-5b8a-408e-b10f-69ee3982e957
default.js:73 

WebSocket connection to 'ws://167.99.204.193/api/kernels/4535d22f-5b8a-408e-b10f-69ee3982e957/channels?session_id=c12eacb0-3f5e-4550-8a0c-5588481673da' failed: Error during WebSocket handshake: Unexpected response code: 200
_createSocket @ default.js:73
v @ default.js:192
e.connectTo @ default.js:1297
e.connectTo @ default.js:1127
e.connectTo @ kernel.js:94
renderWidgets @ WidgetApplication.js:22
default.js:1428 Kernel: reconnecting (4535d22f-5b8a-408e-b10f-69ee3982e957)
default.js:149 

Connection lost, reconnecting in 1 seconds.
_onWSClose.e @ default.js:149
error (async)
_createSocket @ default.js:79
v @ default.js:192
e.connectTo @ default.js:1297
e.connectTo @ default.js:1127
e.connectTo @ kernel.js:94
renderWidgets @ WidgetApplication.js:22
async function (async)
renderWidgets @ WidgetApplication.js:21
(anonymous) @ main.js:22
load (async)
(anonymous) @ main.js:19
execCb @ require.min.js:1
check @ require.min.js:1
(anonymous) @ require.min.js:1
(anonymous) @ require.min.js:1
(anonymous) @ require.min.js:1
each @ require.min.js:1
emit @ require.min.js:1
check @ require.min.js:1
enable @ require.min.js:1
init @ require.min.js:1
h @ require.min.js:1
completeLoad @ require.min.js:1
onScriptLoad @ require.min.js:1
load (async)
req.load @ require.min.js:1
load @ require.min.js:1
load @ require.min.js:1
fetch @ require.min.js:1
check @ require.min.js:1
enable @ require.min.js:1
enable @ require.min.js:1
(anonymous) @ require.min.js:1
(anonymous) @ require.min.js:1
each @ require.min.js:1
enable @ require.min.js:1
init @ require.min.js:1
(anonymous) @ require.min.js:1
setTimeout (async)
req.nextTick @ require.min.js:1
o @ require.min.js:1
requirejs @ require.min.js:1
(anonymous) @ main.js:9
default.js:64

Starting WebSocket: ws://167.99.204.193/api/kernels/4535d22f-5b8a-408e-b10f-69ee3982e957

Any hints on where I can find a minimum viable example fir using voila on a remote host?

Option to exclude Markdown cells

I would like the option to exclude markdown cells in Voila. In some of my notebooks have several markdowns cells to help me navigate the notebook but these would be a distraction for the end user.

Does Voila use nbconvert to render the markdown cells? If so, there is an option in nbcovert to exclude markdown. Can this be easily enabled in Voila?

nbconvert command to exclude markdown:
!jupyter nbconvert --to python 'example.ipynb' --stdout --TemplateExporter.exclude_markdown=True

Cannot start conda kernel error

This notebook works in appmode, but I think voila is not able to start the custom conda env kernel:

(pythreejs_env) MacBook-Pro:examples scott$ voila network\ plot\ -\ les\ mis\ -\ update.ipynb 
[Voila] Storing connection files in /var/folders/m0/zs_gtkld71bb06pqswcsndv00000gn/T/voila_65hjawfv.
[Voila] Serving static files from /Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/voila/static.
[Voila] Voila listening on port 8866.
ERROR:tornado.application:Uncaught exception GET / (::1)
HTTPServerRequest(protocol='http', host='localhost:8866', method='GET', uri='/', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/tornado/web.py", line 1592, in _execute
    result = yield result
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/tornado/gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/voila/handler.py", line 47, in get
    kernel_id = yield tornado.gen.maybe_future(self.kernel_manager.start_kernel(kernel_name=kernel_name))
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/tornado/gen.py", line 326, in wrapper
    yielded = next(result)
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 160, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/jupyter_client/manager.py", line 246, in start_kernel
    kernel_cmd = self.format_kernel_cmd(extra_arguments=extra_arguments)
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/jupyter_client/manager.py", line 170, in format_kernel_cmd
    cmd = self.kernel_spec.argv + extra_arguments
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/jupyter_client/manager.py", line 82, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "/Users/scott/miniconda3/envs/pythreejs_env/lib/python3.6/site-packages/jupyter_client/kernelspec.py", line 236, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named conda-env-pythreejs_env-py
ERROR:tornado.general:Could not open static file '/base/images/favicon.ico'
ERROR:tornado.general:Could not open static file '/style/style.min.css'
ERROR:tornado.access:500 GET / (::1) 359.25ms

Are ipywidgets enabled?

I have a notebook in which I use ipywidgets to update a plot. Is this supported with voila? It appears that the widget that I use doesn't show up when served by voila.

Btw, this looks very close to the exact thing that I was looking for, to serve up a notebook for my colleagues who aren't programming-savvy! Thank you for making this!

TODO: Use ipywidgets' require loader

The logic for loading of AMD module of loader.js is duplicated from core ipywidgets.

We should make upstream's public API and use it to prevent duplication.

when a kernel is no longer available there's no `connection failed` dialogue

when a ipython kernel no longer is available, the following dialogue pops up

Connection failed

A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration

Should a similar behaviour be available to voila?
Similarly, what in the event of reconnecting to the Kernel?

Windows 10: 500 Internal Server Error

Does this work on Windows 10? I installed voila from conda-forge and tried running

voila voilable_astrowidgets.ipynb

where the notebook is at https://github.com/spacetelescope/dat_pyinthesky/blob/master/jupyter_platform/voilable_astrowidgets.ipynb and I get "500 Internal Server Error" when I open up http://localhost:8866/ on my browser (Chrome) with the following traceback

VOILA: 16368
[Voila] Using C:\...\AppData\Local\Temp to store connection files
[Voila] Storing connection files in C:\...\AppData\Local\Temp\voila_rz22_17q.
[Voila] Serving static files from C:\...\Miniconda3\envs\py37\lib\site-packages\voila\static.
[Voila] Voila listening on port 8866.
[18780:12268:0404/134334.485:ERROR:cache_util_win.cc(19)] Unable to move the cache: 0
[18780:12268:0404/134334.486:ERROR:cache_util.cc(140)] Unable to move cache folder C:\...\AppData\Local\Google\Chrome\User Data\ShaderCache\GPUCache to C:\...\AppData\Local\Google\Chrome\User Data\ShaderCache\old_GPUCache_000
[18780:12268:0404/134334.486:ERROR:disk_cache.cc(184)] Unable to create cache
[18780:12268:0404/134334.486:ERROR:shader_disk_cache.cc(622)] Shader Cache Creation failed: -2
[Voila] WARNING | Notebook voilable_astrowidgets.ipynb is not trusted
Opening in existing browser session.
ERROR:tornado.application:Uncaught exception GET / (::1)
HTTPServerRequest(protocol='http', host='localhost:8866', method='GET', uri='/', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\tornado\web.py", line 1592, in _execute
    result = yield result
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\tornado\gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\voila\handler.py", line 64, in get
    kernel_id = yield tornado.gen.maybe_future(self.kernel_manager.start_kernel(kernel_name=kernel_name))
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\tornado\gen.py", line 326, in wrapper
    yielded = next(result)
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\jupyter_server\services\kernels\kernelmanager.py", line 170, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\jupyter_client\manager.py", line 246, in start_kernel
    kernel_cmd = self.format_kernel_cmd(extra_arguments=extra_arguments)
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\jupyter_client\manager.py", line 170, in format_kernel_cmd
    cmd = self.kernel_spec.argv + extra_arguments
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\jupyter_client\manager.py", line 82, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "C:\...\Miniconda3\envs\py37\lib\site-packages\jupyter_client\kernelspec.py", line 236, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named astro36
ERROR:tornado.general:Could not open static file 'C:\\base\\images\\favicon.ico'
ERROR:tornado.general:Could not open static file 'C:\\style\\style.min.css'
ERROR:tornado.access:500 GET / (::1) 134.71ms

Template/plugin system

As discussed with @SylvainCorlay the template system could be pretty light weight and flexible if we adopt the following approach:

  • $PREFIX/etc/jupyter/voila/conf.(yaml|json) holds a general default configuration, which for now would only have the following options:
    default_nbconvert_template: default
    
  • $PREFIX/share/jupyter/voila/nbconvert_templates/{nbconvert_template_name}/ directory which would be added to the template search path, to enable overloading of voila.tpl or base.tpl (or any of the nbconvert templates used)
  • $PREFIX/share/jupyter/voila/static/{nbconvert_template_name}/ for any static content. Ideally this would enable similar to the templates directory overloading of files, such that for instance a new template could be based on an existing template, but just have a different css or logo image.

Different from what I discussed with @SylvainCorlay , I propose for the last two directories, the following layout:

  • $PREFIX/share/jupyter/voila/{nbconvert_template_name}/nbconvert_templates
  • $PREFIX/share/jupyter/voila/{nbconvert_template_name}/static
  • (optionally $PREFIX/share/jupyter/voila/{nbconvert_template_name}/template so that we can also overload 404.html etc)

This reflects better the directory structure of the voila Python package, and makes it easier to fiddle with templates (make a symlink, manually remove or rename the directory).

This system makes it easy to conda/pip/apt-get install a template, since it just needs to put it in a directory, no post scripts are needed.

Open ideas:

  • Ideally, a template could also 'inherit' from a different template. So the search path for templates and static paths just gets appended with the list of extra template paths.
  • The default template could go outside of the Python package, sharing the exact same system as the other templates.

Question / Idea

@SylvainCorlay Theo from the Met Office Informatics lab here. Great to talk earlier.

I had a idea that I've not fully processed but thought would be fun to bounce off you.

Do you remember my concern over notebooks with some initial heavy lifting / loading and that this would be repeated for each page view/request?

Do you think that it would be theoretically (at least) possible to execute the notebook, capture the output but but at this point fork the process and return/use the fork as the kernel for the output/JS widgets. The original is "kept" and each new request just forks the original "first pass" kernel/environment. The advantage if this is possible is that any heavy lifting is only done once. Additionally due to (and my understanding is poor here so this might be nonsense) the nature of process forking only copying memory on modification, there could be a potential memory footprint saved if the code had large objects but that the underlying data isn't changed (just different views taken).

No idea if this is even possible but would like your thoughts.

Cheers,

Theo.

Rendering local images in markdown

At the moment, images in relative directories w.r.t. notebooks are not rendered.

Serving these directories would break the security model of voila, which is not supposed to expose the actual notebook content.

This raises the question of how deal with images. Could nbconvert explicitly render inline images?

Support for @interact

ipywidget's @interact does not appear to work with voila

  • widgets are all properly created
  • the output widget works perfectly in a standalone fashion
  • but the output for the interactive object does not seem to be generated by the nbexecute nbconvert preprocessor.

ERROR:tornado.general:Could not open static file '/base/images/favicon.ico'

I installed voila but when I run a notebook and want to access to it I get this error:

`ERROR:tornado.application:Uncaught exception GET / (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:8300', method='GET', uri='/', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 423, in _wait_for_reply
    msg = self.kc.shell_channel.get_msg(timeout=timeout)
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/jupyter_client/blocking/channels.py", line 57, in get_msg
    raise Empty
queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/tornado/web.py", line 1592, in _execute
    result = yield result
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/tornado/gen.py", line 1147, in run
    yielded = self.gen.send(value)
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/voila/handler.py", line 53, in get
    result = executenb(notebook, km=km)
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 541, in executenb
    return ep.preprocess(nb, resources, km=km)[0]
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 361, in preprocess
    nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources)
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/nbconvert/preprocessors/base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 376, in preprocess_cell
    reply, outputs = self.run_cell(cell, cell_index)
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 447, in run_cell
    exec_reply = self._wait_for_reply(msg_id, cell)
  File "/home/ubuntu/.newenv/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 436, in _wait_for_reply
    raise exception("Cell execution timed out")
TimeoutError: Cell execution timed out
ERROR:tornado.general:Could not open static file '/base/images/favicon.ico'
ERROR:tornado.general:Could not open static file '/style/style.min.css'
ERROR:tornado.access:500 GET / (127.0.0.1) 47190.06ms
`

Binder broken

Just show a file structure can't get anything interactive.

Sorry for short issue, in a meeting, on my phone.

Not showing jupyter-matplotlib figure

The following code shows an initial jupyter-matplotlib figure, and then closes it and shows another one when the Refresh button is pressed. It works fine in the notebook, but with voila only the first figure is shown, not the subsequent ones.

%matplotlib widget

import matplotlib.pyplot as plt
import numpy as np
import ipywidgets as widgets
from IPython.display import display

button = widgets.Button(description='Refresh')
display(button)
def get_fig():
    fig, ax = plt.subplots(1)
    ax.plot(np.arange(10), np.random.random(10))
    return fig
fig = get_fig()

def on_button_clicked(b):
    global fig
    fig.canvas.close()
    fig = get_fig()
button.on_click(on_button_clicked)

Allowing notebook parameterisation

Would it be possible / desirable to enable notebook parameterisation with URL parameters? I'm currently thinking about using notebooks as external services integrating with amazon MTurk, and it would be great to be able to allow reading of URL parameters.

It could be done with something like https://github.com/takluyver/nbparameterise #maybe?

It should probably be turned off by default to prevent unexpected or malicious behaviour.

requirejs timeouts when loading libwidgets

Experimenting with voila I noticed that I usually get a require.js timeout the first time I open the page:

Error: Script error for "libwidgets"
http://requirejs.org/docs/errors.html#scripterror

However, it's gone when I refresh. If I disable the cache in my developer tools, I keep getting the error. Is this what #4 is trying to solve?

Voila mode button/option

Like appmode, https://github.com/oschuett/appmode it would be good to have a button or option in the menu bar for the classical notebook to open a notebook in voila (also make voila more 'visible'). For Jupyter lab, we could add a command to the command palette, and possibly add it to the menu.

404s in server stdout

I installed voila from conda-forge and cloned this repo for the example notebooks.

I get a different set of 404s in the voila stdout for each example, although all three examples seem to render and interact just fine..

For basics.ipynb:

(voila) pylantic:voila cbc$ voila notebooks/basics.ipynb
[Voila] Storing connection files in /var/folders/pt/k6jh8nc93_n81ys_n10dz0500000gn/T/voila_b92hsxyk.
[Voila] Serving static files from /Users/cbc/anaconda3/envs/voila/lib/python3.7/site-packages/voila/static.
[Voila] Voila listening on port 8866.
WARNING:tornado.general:404 GET /api/kernels/bfab0005-7e7e-41b6-990c-55ab659b651e/channels?session_id=785b7333-2720-41a7-a049-7f85d5aebf8f (::1): Kernel does not exist: bfab0005-7e7e-41b6-990c-55ab659b651e
ERROR:tornado.general:Could not open static file '/base/images/favicon.ico'
ERROR:tornado.general:Could not open static file '/style/style.min.css'
WARNING:tornado.access:404 GET /api/kernels/bfab0005-7e7e-41b6-990c-55ab659b651e/channels?session_id=785b7333-2720-41a7-a049-7f85d5aebf8f (::1) 43.93ms
[Voila] Kernel started: ea7b103f-59d2-49ed-898e-ed4f65805379
[Voila] Executing notebook with kernel: python3
WARNING:tornado.access:404 GET /favicon.ico (::1) 0.80ms
[Voila] Adapting to protocol v5.1 for kernel ea7b103f-59d2-49ed-898e-ed4f65805379

For bqplot.ipynb:

(voila) pylantic:voila cbc$ voila notebooks/bqplot.ipynb
[Voila] Storing connection files in /var/folders/pt/k6jh8nc93_n81ys_n10dz0500000gn/T/voila_0x8r_3jb.
[Voila] Serving static files from /Users/cbc/anaconda3/envs/voila/lib/python3.7/site-packages/voila/static.
[Voila] Voila listening on port 8866.
WARNING:tornado.general:404 GET /api/kernels/ea7b103f-59d2-49ed-898e-ed4f65805379/channels?session_id=bc58d6fc-842c-41c7-ba6e-881b435b2de1 (::1): Kernel does not exist: ea7b103f-59d2-49ed-898e-ed4f65805379
ERROR:tornado.general:Could not open static file '/base/images/favicon.ico'
ERROR:tornado.general:Could not open static file '/style/style.min.css'
WARNING:tornado.access:404 GET /api/kernels/ea7b103f-59d2-49ed-898e-ed4f65805379/channels?session_id=bc58d6fc-842c-41c7-ba6e-881b435b2de1 (::1) 44.59ms
[Voila] WARNING | Replacing stale connection: ea7b103f-59d2-49ed-898e-ed4f65805379:bc58d6fc-842c-41c7-ba6e-881b435b2de1
[Voila] Kernel started: 97b5dbae-e900-487a-985d-43e85f4e8567
[Voila] Executing notebook with kernel: python3
WARNING:tornado.access:404 GET /favicon.ico (::1) 0.62ms
[Voila] Adapting to protocol v5.1 for kernel 97b5dbae-e900-487a-985d-43e85f4e8567
WARNING:tornado.access:404 GET /voila/static/bqplot.js (::1) 0.55ms
WARNING:tornado.access:404 GET /af7ae505a9eed503f8b8e6982036873e.woff2 (::1) 0.54ms
WARNING:tornado.access:404 GET /fee66e712a8a08eef5805a46892932ad.woff (::1) 0.43ms
WARNING:tornado.access:404 GET /b06871f281fee6b241d60582ae9369b9.ttf (::1) 0.52ms
WARNING:tornado.access:404 GET /components/font-awesome/fonts/fontawesome-webfont.woff2?v=4.7.0 (::1) 0.53ms
WARNING:tornado.access:404 GET /components/font-awesome/fonts/fontawesome-webfont.woff?v=4.7.0 (::1) 0.34ms
WARNING:tornado.access:404 GET /components/font-awesome/fonts/fontawesome-webfont.ttf?v=4.7.0 (::1) 0.33ms

For ipyvolume.ipynb:

(voila) pylantic:voila cbc$ voila notebooks/ipyvolume.ipynb
[Voila] Storing connection files in /var/folders/pt/k6jh8nc93_n81ys_n10dz0500000gn/T/voila__p2oyq8g.
[Voila] Serving static files from /Users/cbc/anaconda3/envs/voila/lib/python3.7/site-packages/voila/static.
[Voila] Voila listening on port 8866.
[Voila] Kernel started: cf933146-19cf-483f-b0de-662cbed0e4c0
[Voila] Executing notebook with kernel: python3
WARNING:tornado.general:404 GET /api/kernels/97b5dbae-e900-487a-985d-43e85f4e8567/channels?session_id=09b948c8-6159-440d-a71f-78a81278b831 (::1): Kernel does not exist: 97b5dbae-e900-487a-985d-43e85f4e8567
ERROR:tornado.general:Could not open static file '/base/images/favicon.ico'
ERROR:tornado.general:Could not open static file '/style/style.min.css'
WARNING:tornado.access:404 GET /api/kernels/97b5dbae-e900-487a-985d-43e85f4e8567/channels?session_id=09b948c8-6159-440d-a71f-78a81278b831 (::1) 36.30ms
WARNING:tornado.access:404 GET /favicon.ico (::1) 0.58ms
[Voila] Adapting to protocol v5.1 for kernel cf933146-19cf-483f-b0de-662cbed0e4c0
WARNING:tornado.access:404 GET /voila/static/jupyter-threejs.js (::1) 0.66ms
WARNING:tornado.access:404 GET /voila/static/ipyvolume.js (::1) 0.42ms
WARNING:tornado.access:404 GET /af7ae505a9eed503f8b8e6982036873e.woff2 (::1) 0.49ms
WARNING:tornado.access:404 GET /fee66e712a8a08eef5805a46892932ad.woff (::1) 0.45ms
WARNING:tornado.access:404 GET /b06871f281fee6b241d60582ae9369b9.ttf (::1) 0.46ms
WARNING:tornado.access:404 GET /components/font-awesome/fonts/fontawesome-webfont.woff2?v=4.7.0 (::1) 0.49ms
WARNING:tornado.access:404 GET /components/font-awesome/fonts/fontawesome-webfont.woff?v=4.7.0 (::1) 0.35ms
WARNING:tornado.access:404 GET /components/font-awesome/fonts/fontawesome-webfont.ttf?v=4.7.0 (::1) 0.34ms

ipyvolume example gives an error

[Voila] Executing notebook with kernel: python3
WARNING:tornado.access:404 GET /custom.css (::1) 0.85ms
WARNING:tornado.access:404 GET /custom.css (::1) 0.32ms
[Voila] Adapting to protocol v5.1 for kernel 26a4a1ff-c3c3-406c-b1f3-b24dba6afd04
[IPKernelApp] WARNING | Unknown message type: 'custom_message'
WARNING:tornado.access:404 GET /static/dist/jupyter-threejs.js (::1) 0.58ms
WARNING:tornado.access:404 GET /static/dist/ipyvolume.js (::1) 1.13ms

generated response includes 12k lines of css

I noticed that when hosting a notebook with voila, that in the initial response, 12k lines of bootstrap css is included. While most js code is cached, this initial response is not and takes little under 3.00 seconds to complete. About 95% of the response data is the css code. It seems low hanging fruit to just link the dependency ( as is done for font-awesome ) or is served as a separate file, such that the browser can perform caching.

this applies to the template:

voila/share/jupyter/voila/template/default/nbconvert_templates/voila.tpl

here the css code is inlined in the template

whereas

voila/share/jupyter/voila/template/gridstack/nbconvert_templates/voila.tpl

inlines the bootstrap css

This reduces the response considerable...

QGrid widget breaks Voila

Hi,

QGrid does not seem to work in Voila. I can't see any error messages in the console. QGrid seems to prevent all widgets from being rendered. Has anyone found this issue with qgrid/Voila?

Example......

import numpy as np
import pandas as pd
import qgrid


np.random.seed(0)
n = 200
x = np.linspace(0.0, 10.0, n)
y = np.cumsum(np.random.randn(n))
df = pd.DataFrame({'x': x, 'y':y})

tableOut = qgrid.QgridWidget(df=df, show_toolbar=True)
tableOut

In Notebook:
image

In Voila
image

widgets interact not presenting a slider

# Name                    Version                   Build  Channel
voila                     0.0.9                      py_0    conda-forge

I did see this:
#19

And I am able to get widgets working using the pattern shown in that report.

However when I use widgets in other patterns like the below they don't work:

import ipywidgets as widgets
from ipywidgets import interact

def what(item):
    return item*5
interact(what, item=widgets.IntSlider(value=2, min=1, max=10))

Here is what it looks like with voila:
image

Here is the chrome console output:
image


Here is what the jupyter widget looks like in the regular notebook:
image

RTD documentation

At the time of this writing, README seems to be more informative than the RTD doc.

Notebook extensions not working in voila frontend?

Hi all,

I've been enjoying voila so far for rendering widgets as websites.

One issue I'm having is I seemingly can't use a notebook extension I use in a widget.

Specifically, my widget superintendent uses ipyevents for capturing keyboard keystrokes. ipyevents provites a jupyter extension that can capture keystrokes.

While it works in a notebook, it doesn't work when presenting that notebook using voila.

Example:

pip install git+https://github.com/janfreyberg/superintendent.git
jupyter nbextension enable --py --sys-prefix ipyevents
from superintendent import SemiSupervisor
import numpy as np

SemiSupervisor(
   features=np.random.randint(10, shape=(10, 3)),
   options=range(10),
   keyboard_shortcuts=True
)

This should allow the user to press e.g. the "1" key to label a row as 1, but this doesn't work in voila.

Is this intentional? Is there a workaround?

Bug: Race condition on widget render

Not sure this is fixable, but heres what i'm seeing:

if plotlywidget.js is present locally, the chart renders no problem.

if not, then the graph is attempted to be rendered while the js is being fetched from unpkg, and the chart is never displayed.

Presumably this affects other libraries as well (though not qgrid it seems).

Serve a RISE slideshow

Enable Voila to serve a RISE slideshow

This would be a great way of hosting and sharing Jupyter notebook content in a slidey way. I suggest Voila should directly make use of the RISE slide-type dropdown menus and other parts of the RISE Jupyterlab extension UI.

@damianavila , what do you think about this proposal? ref: #36 (comment)

Loading screen while widgets load

There is a brief period when we just show the empty white box while the widgets load/python executes. We should think of a good loading screen and find a way to hook it in. Initial thought is wait for kernel-ready, but its conceivable users could program an infinite loop in their last cell.

Preloading kernels / enabling a pool of kernels

I am experimenting with a moderately complex notebook (~10 widgets, among them an ipyleaflet map) and I have seen that, from first GET request to the end of the load, it takes about 1 minute, and sometimes it gives timeouts when loading the JavaScript modules. I wonder if there would be some way to "preload" a pool of kernels to help accelerate page show times. Not sure if this is similar to #5.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.