How can I submit a Flow B for immediate execution ...
# ask-community
s
How can I submit a Flow B for immediate execution when Flow A is finished? And this should be non blocking, that is, just calling
flow_b_method()
as the last statement in Flow A is blocking. Can I use a state handler like
on_completion=[flow_b_method]
as part of Flow A's definition? But using state change hooks cannot consume parameters for Flow B. Using
**kwargs
in the hook method somehow?
k
do flow A and flow B have separate dependencies or require separate hardware? if not, you can write them as subflows where a parent flow calls flow A, then flow B
s
No, they just have to run in order. First Flow A and then Flow B. Currently we just call Flow B's method as mentioned above. But it would be nice to start Flow B without Flow A waiting for B
Its more or less a chain. Yes, I could just append all Task from B to A but then we cannot call Flow B separatly.
k
are these separate deployments?
s
When A is blocking, waiting for B, we cannot set sensible timeouts for A
at the moment: all flows in one deployment
But I'm free to change it
I'm more or less new to Prefect 2, we are in the process of migrating from Prefect 1 to 2. So it is possible that I missed some basic concepts here
I'm searching for a "fire and forget" solution to start a flow with certain parameters
k
Based on your description it sounds like you want A and B to be separate deployments, so you can run them in order but also run them independently of each other.
s
Okay, then I ask the Prefect API, retrieve the B-Deployment and call
run_deployment()
with a rather small timeout (0 seconds or so) and check the return of that method to get the state? when the state is SCHEDULED or RUNNING everything is fine?
Is this a clean way to achive my goal?
k
Yep,
run_deployment
with a timeout of 0 is non-blocking
s
What is the return type of
run_deployment
? https://docs.prefect.io/latest/api-ref/prefect/deployments/deployments/#prefect.deployments.deployments.run_deployment doesnt tell and the code neither 😕
ah, flow run?
cool
k
yep!
s
Thank you very much, @Kevin Grismore
🙂
🙌 1