Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

py_app_runner

Async Python service framework: Tornado HTTP/WS bridge, PyBridge service loader, Redis WebSocket connection manager.

Install

pip install py_app_runner

Every push to develop publishes a pre-release, X.Y.<commit count>.dev0. pip hides those unless you ask for them:

pip install --pre py_app_runner        # newest, including dev builds
pip install py_app_runner==0.4.50.dev0 # a specific dev build

Development

docker-compose up develop

Migrations

Built-in service that applies tracked SQL files to one or more configured databases. Add migrations to SERVICES to enable it.

python3 src/app.py migrations status   [--check] [--target NAME]
python3 src/app.py migrations apply    [--dry-run] [--to PREFIX] [--target NAME]
python3 src/app.py migrations baseline [--to PREFIX] [--yes] [--target NAME]
python3 src/app.py migrations new      <name> [--target NAME]
python3 src/app.py migrations repair   <filename> [--target NAME]

By default there is a single target, main, against config["db"]["main"]: files live in config["migrations"]["dir"] (default data/migrations) and are tracked in config["migrations"]["table"] (default migrations). No project needs to change anything to keep this working - an absent migrations key, an empty one, and this flat shape all resolve to that same single target.

To migrate more than one database, opt in with config["migrations"]["targets"]:

"migrations": {
    "targets": {
        "main": {"db": "main", "dir": "data/migrations", "table": "migrations"},
        "gis": {"db": "gis", "dir": "data/migrations_gis", "table": "gis_migrations"},
    }
}

Each target's db names a key under config["db"] and defaults to the target's own name. dir and table default as above. status and apply with no --target run every target in declared order (apply stops at the first one that fails; status --check reports each target rather than stopping at the first with pending work, and exits 1 if any is pending or blocked). new, repair and baseline require --target once more than one target is configured, and an unknown --target exits 1 - both name the configured targets. Output gets a [name] prefix only when more than one target is processed, so single-target output is unchanged.

Targets may share a database, but not a database and a tracking table - each would then report the other's migrations as missing, so that config is refused up front, naming both targets. table defaults to migrations for every target, so two targets on one database need an explicit table on at least one of them.

  • Migrations no longer need to be idempotent - each file runs in its own transaction with its tracking row written inside it, so what already ran is always known.
  • -- migrations:no-transaction on line 1 runs a file outside a transaction (for CREATE INDEX CONCURRENTLY and friends). Such a file must contain exactly one statement: Postgres wraps a multi-statement send in an implicit transaction, which would defeat the directive, so apply refuses it up front. A no-transaction file that fails cannot roll back and is not recorded - apply says so and tells you to inspect the database before re-running.
  • Editing an applied file is detected as drift, and a tracked file that has since been deleted shows as missing; both block apply until resolved. repair fixes drift only; a missing file is fixed by restoring it, or by deleting its tracking row by hand (apply prints the exact DELETE when it blocks).
  • Files must not contain psql meta-commands (\restrict / \unrestrict, as emitted by pg_dump) - psycopg cannot execute them, and apply refuses such a file up front.
  • baseline adopts an existing database into the system: it writes tracking rows without executing anything.
  • Every subcommand exits non-zero on failure, including a misconfigured targets block. status --check exits 1 if anything is pending, drifted or missing, so a deploy script can halt before restarting services against a half-migrated database.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_app_runner-0.5.54.dev0.tar.gz (149.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_app_runner-0.5.54.dev0-py3-none-any.whl (127.3 kB view details)

Uploaded Python 3

File details

Details for the file py_app_runner-0.5.54.dev0.tar.gz.

File metadata

  • Download URL: py_app_runner-0.5.54.dev0.tar.gz
  • Upload date:
  • Size: 149.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for py_app_runner-0.5.54.dev0.tar.gz
Algorithm Hash digest
SHA256 3a8bf86dd98d085246aa319cc31ad03cf1c51b914e1e8012a4f1f78f56b36f74
MD5 132f08dea2105a3230ab1ccebc35c7cf
BLAKE2b-256 d6c7650dc9533c587d10dae81cce141dc53156173be092c5e8a88958b77914bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_app_runner-0.5.54.dev0.tar.gz:

Publisher: publish-dev.yml on 4Apps/py_app_runner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_app_runner-0.5.54.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for py_app_runner-0.5.54.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a6cf9293ab4e8d428059761c37eced6dd2d7011f9ef71d61b59c72bcb4f6f1c
MD5 b7eae395bc400f6d9cff0cf4d5fbb456
BLAKE2b-256 07c1541e63c2ff814c836961d28592d5031d0f46d9ce991934abe20fb780addd

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_app_runner-0.5.54.dev0-py3-none-any.whl:

Publisher: publish-dev.yml on 4Apps/py_app_runner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.5.54.dev0 This release

2 files

0.5.53

2 files

0.5.50

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page