Voilà allows you to convert a Jupyter Notebook into an interactive dashboard. Note that this method uses ngrok and creates an unauthenticated url, so use caution with sensitive material. This will also require an internet connection with your Domino deployment. To create a Voilà dashboard in Domino use the following steps:
- Create a new environment based on the current Domino Analytics Distribution and add the following to the docker file:
RUN pip install voila RUN pip install --upgrade jupyter_client RUN pip install bqplot && pip install plotutils && sudo pip install tornado --upgrade
- You'll use ngrok to deploy the Voila app as described here. Upload the linux binary to your Domino files page and obtain an access token. Details on downloading and creating an account to obtain an access token are found here.
- Create a python script for a dash app in Domino (i.e. app-dash.py) and insert the following code
import dash from dash.dependencies import Input, Output, State import dash_core_components as dcc import dash_html_components as html import dash_table_experiments as dt import json import pandas as pd import numpy as np import plotly import base64 app = dash.Dash() app.config.update({ 'routes_pathname_prefix': '', 'requests_pathname_prefix': '' }) app.layout = html.Iframe(src='REPLACEMENOW', style={'border': 'none', 'width': '100%', 'height': '100vh'}) if __name__ == '__main__': app.run_server(host='0.0.0.0',port=8888) # Domino hosts all apps at 0.0.0.0:8888
- Finally, create an app.sh file in the main Domino file directory and add the following, making sure to change the path for your Jupyter notebook on line 2 and the ngrok access token on line 3:
sudo chmod 777 ngrok && sudo chmod 777 app-dash.py nohup voila --Voila.ip=127.0.0.1 --Voila.tornado_settings='{"headers":{"Content-Security-Policy":"frame-ancestors self *" }}' --port=8887 --no-browser /mnt/<path to notebook> & sudo ./ngrok authtoken <your ngrok token> nohup sudo ./ngrok http 8887 -log=stdout & sleep 5 OUTPUT="$(curl --silent --show-error http://127.0.0.1:4040/api/tunnels | sed -nE 's/.*public_url":"https:..([^"]*).*/\1/p')" OUTPUT=https://$OUTPUT sed "s#REPLACEMENOW#$OUTPUT#g" -i app-dash.py nohup python app-dash.py & sleep 10 sed "s#$OUTPUT#REPLACEMENOW#g" -i app-dash.py while true; do :; done
- Navigate to Publish -> App, start the app, and navigate to your newly created Voilà dashboard!
Comments
1 comment
With updates to Voila, publishing a notebook as Voila app is now just a one liner in the app.sh script.
voila <path to notebook> --port 8888 --base_url /$DOMINO_PROJECT_OWNER/$DOMINO_PROJECT_NAME/r/notebookSession/$DOMINO_RUN_ID/ --server_url /
Submitted by: john.joo
Please sign in to leave a comment.