This documentation is for Dash Enterprise.
Dash Enterprise is the fastest way to write & deploy Dash apps and
Jupyter notebooks.
10% of the Fortune 500 uses Dash Enterprise to productionize AI and
data science apps. Find out if your company is using Dash Enterprise.This page applies to Jupyter Notebooks in App Workspaces and isn’t supported in App Studio Workspaces.
Dash 2.11 and later supports running Dash apps in Jupyter Notebooks without the need to update the code or use the additional JupyterDash
library. If you are using an earlier version of Dash, you can run Dash apps in a notebook using JupyterDash.
This page documents options available when running Dash apps in Jupyter Notebooks in Dash Enterprise Workspaces. For more general details on building Dash apps in Jupyter Notebooks, see the Dash in Jupyter Environments page.
In Jupyter Notebooks in Workspaces, you can run your app inline
(the default), at an external
URL, or you can open it in a browser tab
when you run the cell. To change the display mode on an app, set the jupyter_mode
on app.run
:
app.run(jupyter_mode="external")
For more on these options, including how to set them at the notebook level, see the Display Modes section of the Dash in Jupyter Environments page.
You can also view your app in a tab within the workspace by running your notebook and selecting the Preview button:
<img>
The app loads in a preview panel:
To deploy your Dash app:
launch.sh
and Procfile
files to your project.launch.sh
script converts your notebook to a .py
file to deploy and the Procfile
tells Dash Enterprise which processes to run on startup.Procfile
without a file extension.launch.sh
```sh
#!/bin/bash
# Name of notebook to deploy (excluding .ipynb extension)
<name>=app
# Convert notebook to py script
jupyter nbconvert –to script $NAME.ipynb
# Depending on notebook metadata, command above may output a .txt file
# If so, change extension to .py
if [ -f $NAME.txt ]; then
mv $NAME.txt $NAME.py
fi
``
where
<name>is the name of your Jupyter notebook, excluding the
.ipynb` extension.
Procfile
web: gunicorn <name>:server --workers 4
where <name>
is the name of your Jupyter notebook, excluding the .ipynb
extension.
In your notebook, define the server
variable for Gunicorn:
server = app.server
Create a requirements.txt
file for your app dependencies with pip freeze > requirements.txt
; then go in requirements.txt
and add nbconvert
and gunicorn
.
Run the launch.sh
script in the workspace terminal:
./launch.sh
If you get an error “setuidgid: fatal: unable to run ./launch.sh: access denied”, then make the script executable and run it again:
bash
chmod +x launch.sh
Note: You’ll need to run the
launch.sh
script any time you make changes in the Jupyter Notebook
and want to deploy those changes.