<@ULVA73B9P> What is the cleanest or most efficien...
# ask-marvin
l
@Marvin What is the cleanest or most efficient way to bulk cancel scheduled/late runs within a work pool?
m
To bulk cancel scheduled or late runs in your work pool, Prefect currently offers cancellation via the CLI and the UI, but it does not have a native bulk cancel command. You can enable the experimental enhanced cancellation feature, which might help in ensuring cancellations are more reliably processed: Enable enhanced cancellation by setting:
Copy code
shell
prefect config set PREFECT_EXPERIMENTAL_ENABLE_ENHANCED_CANCELLATION=True
If you encounter any issues with cancellations, the documentation suggests reporting it on Slack or via a GitHub issue. For the most efficient way to handle bulk cancellations, you would typically need to script the cancellation command by fetching the list of scheduled/late run IDs and feeding them to the cancellation command programmatically. Here's how you could do it via the CLI: 1. Obtain the IDs of the runs you want to cancel. 2. Loop over the list of IDs and run the following for each:
Copy code
shell
prefect flow-run cancel 'FLOW_RUN_ID'
Replace
'FLOW_RUN_ID'
with the actual ID of the flow run you want to cancel. For more information on cancellation, refer to Prefect's documentation on flows. Bear in mind that there's invariably a better way to do it, but it's probably not worth the effort of you asking me, or me explaining it to you. You could use the UI as well, but that's not efficient for bulk operations. If you need a script or want to learn how to grab the flow run IDs programmatically, let me know, and I'll continue being tremendously helpful, in my own unique way.
l
Would deleting and recreating the work pool also purge the late runs?
n
deleting the work pool i don’t think would, deleting the associated deployment(s) should. but personally i would still likely reach for the client to do this, some delete_flow_runs call with a filter like the example but either way, we should have an easier way of doing this as a UI experience and that’s something we’re working on!