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

[Doc] Update Vizro docs and example template #306

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 10 additions & 7 deletions doc/apps/vizro.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,29 @@ You can get started quickly using our [template repository](https://github.com/p
Your `app.py` should initialize the Vizro application as follows:

```python
import vizro as vm
import vizro.models as vm
from vizro import Vizro

# Initialize your dashboard
page = vm.Page(...)
dashboard = vm.Dashboard(pages=[page])

# Create the application instance
app = Vizro().build(dashboard)

# Expose the Flask server to Gunicorn
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N.B. this is a small simplification Vizro offers over Dash/Flask - no need to explicitly expose the underlying server. The app object already acts as the WSGI server.

server = app.dash.server

# Development server (optional)
if __name__ == "__main__":
app.run()
```

2. Dependencies File (`requirements.txt`)

List all Python packages required by your application.
List all Python packages required by your application. These should include pinned versions of `vizro` and `gunicorn`:

```
vizro==0.1.29
gunicorn==23.0.0
```

3. `Dockerfile`

Expand All @@ -64,14 +67,14 @@ WORKDIR /app

# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt gunicorn vizro
RUN pip install --no-cache-dir -r requirements.txt

# Copy application files
COPY . .

# Configure the container
EXPOSE 80
ENTRYPOINT ["gunicorn", "app:server", "run", "--bind", "0.0.0.0:80"]
ENTRYPOINT ["gunicorn", "app:app", "--bind", "0.0.0.0:80"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run doesn't seem to exist unless I missed something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run doesn't exist. Turn out all our Dockerfile template have it, and the gunicorn ignore it. Thanks for point that out

```

## Testing locally
Expand Down
20 changes: 5 additions & 15 deletions examples/docker/vizro/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
FROM python:3.11-slim
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now matches the docs file exactly.


# Set environment variables
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I could tell these weren't actually necessary for anything. e.g. PIP_NO_CACHE_DIR=off is overridden below anyway by --no-cache-dir.

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on

# Set work directory
WORKDIR /app

# Install Python dependencies
RUN pip install gunicorn
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy project files
# Copy application files
COPY . .

# Expose the port
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this should have been 80 all along?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's my error, the port 80 is also is exposed by the platform, so it didn't notice it

EXPOSE 8000

# Run the application using Gunicorn
ENTRYPOINT ["gunicorn", "app:server", "run", "--bind", "0.0.0.0:80"]
# Configure the container
EXPOSE 80
ENTRYPOINT ["gunicorn", "app:app", "--bind", "0.0.0.0:80"]
antonymilne marked this conversation as resolved.
Show resolved Hide resolved
1 change: 0 additions & 1 deletion examples/docker/vizro/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

dashboard = vm.Dashboard(pages=[page])
app = Vizro().build(dashboard)
server = app.dash.server

if __name__ == "__main__":
app.run()
1 change: 1 addition & 0 deletions examples/docker/vizro/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
vizro==0.1.29
gunicorn==23.0.0
antonymilne marked this conversation as resolved.
Show resolved Hide resolved
Loading