How long will a flow stay in Paused status while i...
# prefect-community
l
How long will a flow stay in Paused status while it waits for approval? And is the best way to decline just to cancell the flow run?
k
I have heard people use a week. What time duration are you thinking? And yeah I guess so. Maybe you can elaborate on the use case more?
l
The use case is emitting a pause when a certain number of actions is reached for a given flow. To give a toy example: Say we have a set of 100 metrics and the flow aims to find out how many of these metrics should be refreshed and if the number is of a certain percentage (say over 30%) - we pause for manual input And lets say this flow runs every 4 hours …and lets say I missed a few of these pauses over the weekend and only want to approve the latest one Should I just cancel all the flow runs except for the latest one?
k
This is hard…I think so that you would cancel the previous ones because there is a manual step anyway. What would be nice is if you can say “If the Flow is paused for four hours, just cancel”, which you might be able to do with two ways: 1. Upon resuming, check flow duration (current time - start time). If duration is more than 4 hours, return success 2. Try an automation where is the flow is running more than 4 hours, cancel it. The things is I don’t know is Paused counts as running
Number 1 can be done through a state handler on the Flow. You need to end the flow by raising a SKIP state maybe and then letting that propagate
l
So what I’ve gathered is if a task state is
Paused
the flow state is
Running
Can I cancel all flow runs for a flow run id thru graphql?
I’m able to find all flows with a paused task with
Copy code
query {
  task_run(
    where: { state: {_eq: "Paused" } }
  ) {
    flow_run_id,
    flow_run {
      agent {
        labels
      }
    }
  }
}
I could be missing the point of the pause for input feature, but should there be an option to approve or decline rather that just approve?
k
You could but then wouldn’t you cancel the most recent one too?
That is true, I’ll bring that up as we talk about it in 2.0
👍 1
Noone used the decline to the feature story was never advanced
l
Gotcha - I cancelled the flows manually, there weren’t very many - thanks Kevin
upvote 1
a
Catching up here. @Leon Kozlowski you may also consider approaching this using subflows/orchestrator pattern. This way, you could potentially send a notification on a failed child flow run to the person responsible for manual check and approval, and given that a child flow run is an independent flow run, this person could also directly start only the relevant child flow run by creating a new run, independent of the old run. Just mentioning this as one option worth exploring