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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prefect_history-0.3.0.tar.gz.
File metadata
- Download URL: prefect_history-0.3.0.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fb7b04328685dc2583c53e34ff3be51149d67b8b689306701cae40e8ca2fcc3
|
|
| MD5 |
1cd91c0b7a4eab39912dcbf26b258c83
|
|
| BLAKE2b-256 |
cf96caf19accfcd3e1f48a15cb3e52abe580c7d5aea8edb60ad5de45c87f7601
|
File details
Details for the file prefect_history-0.3.0-py3-none-any.whl.
File metadata
- Download URL: prefect_history-0.3.0-py3-none-any.whl
- Upload date:
- Size: 34.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
492158964896c44e9b28ae50944f108d00bad7a18683f7605dd434e9eb4826d2
|
|
| MD5 |
919e4fd81ee1a8fdbbf39775160bb1ee
|
|
| BLAKE2b-256 |
86c7d2dea20e9c35a9289560ff8ff6953af9ecc15b644d6d21b28444cb66fe74
|