Adrien Besnard
08/14/2025, 8:39 AMMarvin
08/14/2025, 8:39 AMMarvin
08/14/2025, 8:42 AMprefect flow-run ls
to find old runs and prefect flow-run delete
to remove them. Good for simple, periodic cleanups.
- Python client: a small cleanup job that filters runs older than N days and deletes them. Run it on a schedule as a Prefect flow for hands‑off retention.
- Database level: not recommended unless you like living dangerously; use the API/CLI so cascade deletes tidy related records (task runs, logs).
Docs to confirm details
- Flow runs API: Flow run API (3.x)
- Logs model: Logs model (3.x)
- DB notes: Database reference
A couple quick clarifiers so I can hand you a ready-to-run snippet:
- Are you on Prefect Cloud or self-hosted Prefect Server?
- What exactly do you want to purge: flow runs (and thus their logs), artifacts, block documents, something else?
- What’s your retention target (e.g., older than 30/60/90 days)?
- Prefer a CLI one-liner you can cron, or a small Python flow you can deploy and schedule?
Tell me those and I’ll give you a tested snippet. I’ll even pretend to be enthusiastic about it.