Voilà Documentation

repository·main·Indexed 26 days ago

https://github.com/voila-dashboards/voila

Voilà turns Jupyter notebooks into standalone web applications, providing users with dedicated Jupyter kernels for interactive widgets and rich mime-type rendering. It includes support for JupyterLab previews, custom nbconvert templates, and dedicated widget managers for ipywidgets versions 7 and 8. The tool can be run as a standalone Tornado application or integrated as a server extension for notebook or jupyter_server.

Tokens
25.3K
Snippets
78
Records
176
Agent score
91%

What's inside Voilà

  1. Set up the JupyterLab extension for development

    main

    The JupyterLab extension is a prebuilt extension. To develop it, you must have the server extension enabled, then link your development version to JupyterLab and build it.

    # install the package in development mode
    python -m pip install -e .
    
    # link your development version of the extension with JupyterLab
    jupyter labextension develop . --overwrite
    
    # build the lab extension
    jlpm run build --scope @voila-dashboards/jupyterlab-preview
    
    # or use watch mode to pick up changes automatically
    jlpm run watch
    # install the package in development mode
    python -m pip install -e .
    
    # link your development version of the extension with JupyterLab
    jupyter labextension develop . --overwrite
    
    # build the lab extension
    jlpm run build --scope @voila-dashboards/jupyterlab-preview
    
    # or use watch mode to pick up changes automatically
    jlpm run watch
  2. Partially pre-render notebooks using wait_for_request

    main

    If a notebook requires user-specific data from a URL query string, pre-rendering might fail. In preheating mode, you can use voila.utils.wait_for_request to pause execution until a user connects, allowing the notebook to capture the QUERY_STRING environment variable.

    import os
    from voila.utils import wait_for_request
    
    # Pause execution until a user connects and request info is available
    wait_for_request()
    query_string = os.getenv('QUERY_STRING')
  3. Set up a Voilà development environment

    main

    To develop Voilà, create a conda environment with the necessary dependencies, clone your fork, install JS dependencies, and install Voilà in editable mode.

    # create a new conda environment
    conda create -n voila -c conda-forge notebook jupyterlab nodejs "yarn<4" pip
    conda activate voila
    
    # download voila from your GitHub fork
    git clone https://github./<your-github-username>/voila.git
    
    # install JS dependencies and build js assets
    cd voila
    yarn install
    
    # install Voilà in editable mode
    python -m pip install -e .
    # create a new conda environment
    conda create -n voila -c conda-forge notebook jupyterlab nodejs "yarn<4" pip
    conda activate voila
    
    # download voila from your GitHub fork
    git clone https://github./<your-github-username>/voila.git
    
    # install JS dependencies and build js assets
    cd voila
    yarn install
    
    # install Voilà in editable mode
    python -m pip install -e .
  4. Enable and configure preheated kernels

    main

    Preheating reduces dashboard load times by maintaining a pool of standby kernels that have already executed the notebook.

    Warning: This feature is incompatible with prelaunch-hook functionality.

    To activate, set --preheat_kernel=True. You can specify the pool size with --pool_size. For advanced configuration (like per-notebook pool sizes or environment variables), use a voila.json file.

  5. Configure theme via URL or Notebook Metadata

    main

    Themes can be applied without CLI flags using these methods:

    1. Query Parameter: Append ?theme=<theme-name> to the URL (e.g., http://localhost:8867/voila/render/notebook.ipynb?theme=dark).
    2. Notebook Metadata: Set the theme in the notebook file under metadata/voila/theme.
  6. Use Voilà as a server extension for notebook or jupyter_server

    main

    Voilà can be integrated directly into a Jupyter server. To enable it, use the jupyter serverextension enable command for either the notebook or jupyter_server backend. Once enabled, the Voilà app is accessible via the base URL suffixed with /voila.

    jupyter serverextension enable voila
    # or
    jupyter server extension enable voila