Skip to content

Commit

Permalink
Update deployment docs
Browse files Browse the repository at this point in the history
  • Loading branch information
antonymilne committed Nov 6, 2023
1 parent bef5c12 commit 908fd04
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion vizro-core/docs/pages/development/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ We use [Hatch](https://hatch.pypa.io/) as a project management tool. To get star

!!!note

The above steps are all automated in GitHub Codespaces thanks to the [devcontainer configuration](.devcontainer/devcontainer.json), and the example dashboard should already be running on port `8050`.
The above steps are all automated in GitHub Codespaces thanks to the [devcontainer configuration](https://github.com/mckinsey/vizro/blob/main/.devcontainer/devcontainer.json), and the example dashboard should already be running on port `8050`.

If you haven't used Hatch before, it's well worth skimming through [their documentation](https://hatch.pypa.io/), in particular the page on [environments](https://hatch.pypa.io/latest/environment/). Run `hatch env show` to show all of Hatch's environments and available scripts, and take a look at [`hatch.toml`](https://github.com/mckinsey/vizro/tree/main/vizro-core/hatch.toml) to see our Hatch configuration. It is useful handy to [Hatch's tab completion](https://hatch.pypa.io/latest/cli/about/#tab-completion) to explore the Hatch CLI.

Expand Down
29 changes: 12 additions & 17 deletions vizro-core/docs/pages/user_guides/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ The dashboard application can be launched in jupyter environment in `inline`, `e
- you can specify `jupyter_mode="external"` and a link will be displayed to direct you to the localhost where the dashboard is running.
- you can use tab mode by `jupyter_mode="tab"` to automatically open the app in a new browser

## Launch it via Gunicorn
## Deployment of Vizro app
!!!warning "In production"
In production, it is recommended **not** to use the default flask server. One of the options here is gunicorn. It is easy to scale the application to serve more users or run more computations, run more "copies" of the app in separate processes.

A Vizro app wraps a Dash app, which itself wraps a Flask app. Hence to deploy a Vizro app, similar guidance applies as for the underlying frameworks:

- [Flask deployment documentation](https://flask.palletsprojects.com/en/2.0.x/deploying/)
- [Dash deployment documentation](https://dash.plotly.com/deployment)

In particular, `app = Vizro()` exposes the underyling Flask app through `app.dash.server`. This provides the application instance to a WSGI server such as [Gunicorn](https://gunicorn.org/).

!!! example "Use gunicorn"
=== "app.py"
```py
Expand All @@ -82,22 +90,9 @@ The dashboard application can be launched in jupyter environment in `inline`, `e
app = Vizro().build(dashboard)
server = app.dash.server
```
You need to expose the server via `app.dash.server` in order to use gunicorn as your wsgi here.
Run it via
To run using Gunicorn with four worker processes, execute
```bash
gunicorn app:server --workers 3
gunicorn app:server --workers 4
```
in the cmd. For more gunicorn configuration, please refer to [gunicorn docs](https://docs.gunicorn.org/en/stable/configure.html)


## Deployment of Vizro app
In general, Vizro is returning a Dash app. So if you want to deploy a Vizro app, similar steps apply as if you were to deploy a Dash app.
For more details, see the docs on [Dash for deployment](https://dash.plotly.com/deployment#heroku-for-sharing-public-dash-apps).

For reference (where app is a Dash app):
in the command line. For more Gunicorn configuration options, please refer to [Gunicorn documentation](https://docs.gunicorn.org/).

| Vizro | Dash |
|:-------------------------------|:--------------------------------|
| Vizro() | app |
| Vizro().build(dashboard) | app (after creating app.layout) |
| Vizro().build(dashboard).run() | app.run() |

0 comments on commit 908fd04

Please sign in to comment.