How to use Tapyr

Introduction

Tapyr is a template repository for Shiny for Python projects. You can either start a new application from scratch or migrate an existing one to Tapyr. For the first, checkout the Your First Tapyr App guide. For the latter, follow the Migrating to Tapyr guide.

Either way, you will end up with, more or less, the following structure:

.
├── [...]
├── app.py                # the entry point of your app
├── tapyr_template        # the application package
│   ├── __init__.py
│   ├── logic
│   │   ├── __init__.py
│   │   └── utils.py      # utility functions
│   ├── settings.py       # settings/configuration for your app
│   └── view
│       ├── __init__.py
│       └── root
│           ├── __init__.py
│           ├── server.py  # the main server function
│           └── ui.py      # the main UI function
[...]

More on structure can be found in the Tapyr Structure guide.

Running your app

To run your app, simply execute the following command:

source .venv/bin/activate
shiny run app.py --reload

or if you have uv istalled and don’t want to activate the virtual environment:

uv run shiny run app.py --reload

Editing your app

Start with editing the tapyr_template/view/root/ui.py file to define your UI, and the tapyr_template/view/root/server.py file to define your server logic. For more examples check out the Tapyr Examples page.

Quality checks, tests, validation

Linting and formatting

Formatting and linting with ruff is done automatically before each commit with pre-commit. You can also run it manually with:

pre-commit run --all

Tests

For running quality checks and tests either use quality_checks.sh with

./quality_checks.sh

or run the following commands manually:

pytest
pyright