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.2.0.tar.gz (26.5 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.2.0-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prefect_history-0.2.0.tar.gz
  • Upload date:
  • Size: 26.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 5f222e7cb55f383626cab29df00d7285f4bafb106c35af0709da9fee2938038b
MD5 cb4c0afca02c150aa025bcb5b00b2f72
BLAKE2b-256 56954f67b215c395088fb30ce930e8fb4c2b07e843705b5193985550d8558849

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prefect_history-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f244bac0d1fbbbac23dfcffeb180077dabfe856b0a7ab56f0cf3969ee1834ab
MD5 5bd448a975c8a943f6288cc5b4892c11
BLAKE2b-256 7ccf5ab5fb059adbc3cdef729dcdaee5475bd152eac55d7e33aa48424841b388

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