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)

# Show a specific flow run by ID
prefect-history show xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

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.3.1.tar.gz (30.0 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.3.1-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for prefect_history-0.3.1.tar.gz
Algorithm Hash digest
SHA256 fe481ed0f44057d374548bf6c7aa62f375bd72676359ef36411eb5807b0b1458
MD5 1a7f376688d216028fc258d0bbc07c3d
BLAKE2b-256 d60370920dc18a8f46f33f67a0a453dda1ea14564b379ed9bb1d285d7a37d935

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prefect_history-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2de2e41d965b6b29bf02ba0944a68528df173e4eb7f03f935361c735afbe6766
MD5 10be40d01ee92e74f8133bad85f38660
BLAKE2b-256 4485e1ff5672f22e24b878eeaea65547519b5be40c43acad683dbeaa7b4b7bb8

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