Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dash documentation #128

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions doc/apps/dash.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Dash

To deploy a [Dash](https://dash.plotly.com/) application to Ploomber Cloud you need:
To deploy a [Dash](https://dash.plotly.com/) application to Ploomber Cloud you need at least two files zipped up:

- A `Dockerfile`
- A Dash project
1. Your application file (`app.py`)
2. A dependencies file (`requirements.txt`)

Note that your app should exist in an `app.py` file and be initialized in this way:
## Required files

You can use this [template](https://github.com/ploomber/doc/blob/main/examples/dash) to get started.

In the `requirements.txt` file, add all the dependencies that you need for your application to run. The application logic should exist in an `app.py` file and be initialized in this way:

```python
# name your app "app"
Expand All @@ -14,30 +18,16 @@ app = Dash(__name__)
server = app.server
```

## `Dockerfile`

Use this [template](https://github.com/ploomber/doc/blob/main/examples/dash/simple-app/Dockerfile) `Dockerfile`:

```Dockerfile
FROM python:3.11

COPY app.py app.py
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

ENTRYPOINT ["gunicorn", "app:server", "run", "--bind", "0.0.0.0:80"]
```

## Testing locally

To test your app, you can use `docker` locally:
To test the Dash application, you can run the following commands locally:

```sh
# build the docker image
docker build . -t dash-app
pip install -r requirements.txt

# run it
docker run -p 5000:80 dash-app
# Start the dash application
gunicorn app:server run --bind 0.0.0.0:5000
```

Now, open [http://0.0.0.0:5000/](http://0.0.0.0:5000/) to see your app.
Expand All @@ -47,6 +37,6 @@ Now, open [http://0.0.0.0:5000/](http://0.0.0.0:5000/) to see your app.

Once you have all your files, create a zip file.

To deploy a Dash app from the deployment menu, select the Docker option and follow the instructions:
To deploy a Dash app from the deployment menu, select the Dash option and follow the instructions:

![](../static/docker.png)
![](../static/dash.png)
Binary file added doc/static/dash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions examples/dash/clinical-analytics/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion examples/dash/clinical-analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

A dashboard that visualizes clinical data.

Based on [this example.](https://github.com/plotly/dash-sample-apps/tree/main/apps/dash-clinical-analytics)
Based on [this example](https://github.com/plotly/dash-sample-apps/tree/main/apps/dash-clinical-analytics).
7 changes: 0 additions & 7 deletions examples/dash/simple-app/Dockerfile

This file was deleted.

2 changes: 2 additions & 0 deletions examples/dash/simple-app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
app = Dash(__name__)
server = app.server

app.title = "Population by country - Ploomber Cloud Dash Application"

app.layout = html.Div(
[
html.H1(children="Population by country", style={"textAlign": "center"}),
Expand Down
Binary file modified examples/dash/simple-app/app.zip
Binary file not shown.