Skip to main content

Cache and browse Prefect flow-run history locally using SQLite.

Project description

Prefect History

Cache and browse Prefect flow-run history locally using SQLite.

Installation

uv is recommended.

git clone https://github.com/dmonlineuk/prefect_history
cd prefect_history
uv venv
. .venv/Scripts/activate    # Windows
# or . .venv/bin/activate   # Linux / Mac
uv sync

Configuration

Create a .env file in the project root:

PREFECT_API_URL=https://api.prefect.cloud/api/accounts/<ACCOUNT-ID>/workspaces/<WORKSPACE-ID>
PREFECT_API_KEY=pnu_...

# Optional
PH_DB_PATH=prefect_history.db
PH_BACKFILL_MONTHS=2
PH_PAGE_SIZE=200

CLI Usage

After installation, the prefect-history command is available:

prefect-history --help

Sync Commands

# Initial backfill (default: last 2 months)
prefect-history backfill
prefect-history backfill -m 6          # 6-month backfill

# Incremental sync (new runs + re-check in-flight)
prefect-history sync

# Cache statistics and recent sync log
prefect-history status

Browsing Flow Runs (CLI)

# List cached flow runs in a colour-coded table
prefect-history list
prefect-history list -n 50             # show 50 rows
prefect-history list --state FAILED    # filter by state
prefect-history list --flow etl-pipeline   # filter by flow name
prefect-history list --offset 20       # pagination (skip first 20)

Web Dashboard

# Launch the web UI at http://127.0.0.1:8000 (default)
prefect-history serve

# Custom host/port (e.g. expose on all interfaces, port 9000)
prefect-history serve --host 0.0.0.0 --port 9000

The web dashboard provides:

  • Stats overview (total runs, in-flight, last sync time)
  • Filter dropdowns for state type and flow name
  • Paginated table with colour-coded state badges
  • Smooth navigation via HTMX partial updates

Global Options

prefect-history --env-file /path/to/.env list   # custom .env location
prefect-history --db /path/to/cache.db list     # custom database path
prefect-history -v sync                         # verbose/debug logging

Python API

from prefect_history import load_settings, backfill, incremental

settings = load_settings()       # reads .env
backfill(settings)               # initial 2-month pull
incremental(settings)            # daily delta + in-flight re-check

Contributions

Please use linter, formatter, and run pytest before committing.

uv sync --extra dev
isort .
black .
ruff check .
pytest

Project details


Download files

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

Source Distribution

prefect_history-0.1.0.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

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

prefect_history-0.1.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file prefect_history-0.1.0.tar.gz.

File metadata

  • Download URL: prefect_history-0.1.0.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for prefect_history-0.1.0.tar.gz
Algorithm Hash digest
SHA256 28f8e4371361c02e5a7cd4912f5e752d7747ea30837f4baa629ae96f091e1323
MD5 0ee61d9808de5e8263ea202a46d7dffa
BLAKE2b-256 4e6bf7e2233d1eb318d6b76870ab5c142351c12aa8b088b2f56c05f5337d4009

See more details on using hashes here.

File details

Details for the file prefect_history-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for prefect_history-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 07973e70de3ec119af4c7d71a5b19362b9e16ab6b59749d80599f6932ef02a01
MD5 acf5bf10bdb12a86b60b5b8d0ebcb69d
BLAKE2b-256 ce107783358685fe9bbe38a599ce8969d355784086144c74bcb9616298bd97aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page