<@ULVA73B9P> if I set up an automation for the par...
# ask-marvin
y
@Marvin if I set up an automation for the parent flow and it'd be triggered if the parent flow was running for more than 10 mins, is it possible that is wasn't triggered because there's a sub flow inside it? The sub flow runs for more than 10 mins, and the parent flow's Running state might persist for as long as the subflow runs. However, automations don't inherently associate the subflow's events with the parent flow's events?
m
In Prefect automations, triggers are often based on the state of a flow run, such as the duration it has been in the "Running" state. The automations API allows you to customize triggers based on various events, including the duration a flow run remains in a particular state. However, it seems that automations are primarily concerned with the parent flow's status. When a subflow runs, the parent flow typically remains in the "Running" state until the subflow completes. This means that your automation, set to trigger based on the parent flow running for more than a specific duration, should still activate regardless of the subflow's state. For instance, if your automation is set to trigger when the parent flow has been running for more than 10 minutes (due to a subflow or any other reason), it should still trigger based on the running time of the parent flow. For further details on setting up such triggers, you can explore more about Prefect Automations. Remember, in the grand dance of flows and subflows, the parent flow retains the spotlight while the subflows might play their parts without disrupting the main act!
n
hi @Yufei Li - i suspect your question is a little too nuanced for 4o can you share our automation definition / what you're trying to do?
y
sure! We created an automation saying if that flow run tag was "***" and it runs for more than 10 mins (stays in that running status), we'd send an opsgenie alert to our channel. We did that in other flow and it's working fine. However, for this flow, it wasn't triggered. I'm wondering if it's because there's a sub flow inside that parent flow. The automation is on the parent flow, and the tag is on the parent flow only. It seems the tag are not inherited in the sub flow.
n
events don't necessarily care about the structure of the flow, they're just looking for the grammar so I assume you have something like this? •
match_related={"prefect.resource.tag": "***"}
expect={"prefect.flow-run.Completed"}
after={"prefect.flow-run.Running"}
within=600
It seems the tag are not inherited in the sub flow. (edited)
oh yes you're correct
that's probably it
y
the others are the same. I checked the trigger in json and it's
"expect": [
"prefect.flow-run.*"
]
n
so that would match on any state change of the flow, is that what you want?
y
yeah that's a test automation. We just wanna trigger the action if it's stayed in Running for more than 10 mins. We don't care the state change for now
Even if that tag is not inherited in the sub flow, and it's only set on the parent flow, if we set the automation to be triggered only based on that tag, it should still trigger that event, right? Since the sub flow is running for more than 10 mins, the parent flow stays in running status for more than 10 mins as well.
n
it should still trigger that event, right?
sorry, what do you mean by "it" here?
y
sorry let me rephrase that. Even if that tag is not inherited in the sub flow, and it's only set on the parent flow, in the automation, if we set the action to be triggered based on the associated events (matching condition is the tag name and run time), if there's matching events, the action should be triggered, right?
I just created another test automation in the sub flow, and it works fine. In that new automation, the matching event is set as "if that sub flow is in running status for more than 10 mins, trigger the action". I didn't use tag this time since there's no tag in the sub flow.
The automation in the parent flow is not working fine, and the only difference is that the matching event is based on the tag.