Zach
06/18/2024, 3:20 PMMarvin
06/18/2024, 3:20 PMrun_deployment
. Here are some options:
1. Pausing a Flow Run:
Prefect allows you to pause an in-progress flow run for manual approval using the pause_flow_run
function. More details can be found in the Prefect documentation.
2. Cancelling a Flow Run:
You can directly cancel a flow run via Prefect. However, ensure the infrastructure block for the flow run supports cancellation. Any discrepancies might prevent successful cancellation.
Here's a GitHub Issue discussing flow run SLAs including functionality for alerting, cancelling, or pausing deployments when flow runs exceed specified states like Pending
or Running
too long.
Additional automation actions, like canceling or suspending flow runs, can be managed via the UI. This is detailed in the Prefect Automations documentation.
To implement these operations, setting the appropriate environment variables is required:
env
PREFECT_EXPERIMENTAL_EVENTS=True
PREFECT_API_SERVICES_TRIGGERS_ENABLED=True
Feel free to read more from this GitHub pull request for implementing automations.
If you need any more specific code examples or further assistance, just let me know.Zach
06/18/2024, 3:24 PMpaused_state: State = State(type=StateType.PAUSED)
await client.set_flow_run_state(flow_run_id=run.id, state=paused_state)