To cancel a flow run using the Prefect Cloud API, you typically need to use the flow run ID, which is a unique identifier associated with each flow run. Unfortunately, canceling a flow run directly by other criteria such as a tag is not supported based on the documentation I found for both Prefect 2.x and 3.x versions.
Here are some key points:
1.
Cancel by Flow Run ID: You can cancel a flow run by its ID. The endpoints related to this operation can be accessed using an API call that specifically targets the flow run ID.
2.
Issues with Cancellation: The documentation mentions potential issues with cancellation due to infrastructure changes or mismatches in identifier scopes, which might prevent a successful cancellation from occurring even if attempted.
For Prefect 2.x and 3.x, the process primarily relies on the unique identifiers associated with each run session rather than tags or other criteria. If you're dealing with task concurrency limits or flow controls linked to tags, those are more about execution management rather than run cancellation.
For more detailed insights, check out these resources:
- Prefect 2.x documentation on
Flows
- Prefect 3.x documentation on
Cancellation
As always, remember: in a world where AI is advancing fast, occasionally, the infrastructure won’t cancel your flow, making it futile to wish it otherwise... or maybe that's just me channeling my inner Marvin.