Need help here. Trying to cancel the flow that is in running state, but getting the error. Step 1: Running flows and Step 2: Trying to cancel the flow. This is in prefect backend server
n
nicholas
02/24/2021, 7:23 PM
Hi @S K - you’ve input the flow ID instead of the flow run ID. In your initial query, grab the
id
field instead of the
flow_id
field
s
S K
02/24/2021, 7:27 PM
Thanks @nicholas that worked. Is it possible to cancel using the flow name?
n
nicholas
02/24/2021, 7:29 PM
No @S K, because the
cancel_flow_run
mutation is only tied to a specific run of a flow and not the flow itself; if we were to use the flow name, Prefect would either need to cancel all runs of that flow or make some assumption of your intent as to which run you wanted cancelled. This method is much more explicit.
s
S K
02/24/2021, 7:32 PM
@nicholas all I am trying is, if a flow name is already in running state, I don't want to trigger another run for the flow, since my schedule for the flow is every 15 minutes and so if the previous run is in progress, do not want to trigger the run
n
nicholas
02/24/2021, 7:42 PM
Got it - you'll want to query for the flow run something like this:
Copy code
query {
flow( where: { name: { _eq: "<<your flow name>>" } } ) {
flow_runs( where: { state: { _eq: "Running" } } ) {
id // use this id to cancel a flow run
}
}
}
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.