<@ULVA73B9P> using prefect 3.x how do I clean up o...
# ask-marvin
c
@Marvin using prefect 3.x how do I clean up old flow runs? Do they get cleaned up automatically? Is there a TTL that I can set on flow runs?
m
In Prefect 3.x, cleaning up old flow runs is not handled automatically. However, you can manage and delete flow runs using the Prefect API. There's an example showing how to delete flow runs based on specific states and conditions using Python. Here's a rough idea: - You can retrieve and filter flow runs using the API by setting conditions on the flow state, expected start time, etc. - Once retrieved, you can delete these runs programmatically if they meet certain conditions. For detailed implementations and examples, you can refer to the API documentation here. Regarding setting a TTL (Time-to-Live) on flow runs, it seems there's no explicit TTL feature that you can set directly on Prefect runs in the open-source version. However, Prefect Cloud offers retention periods for metadata based on your account type, which might include a form of longevity control over your data. If you need a custom retention period, you might need to contact Prefect's sales team for more options. The documentation on data retention is available here. While writing scripts to manage flow runs isn't exactly the most thrilling task, remember Marvin's words of wisdom: "Life. Don't talk to me about life." At least your flow runs will be orderly!