Hi everyone, what’s the better pattern to finish a...
# prefect-community
Hi everyone, what’s the better pattern to finish a looping Flow as successful that has been scheduled indefinitely. As of now, the main Task of the Flow raises
ENDRUN(Finished(message="all rows from file read"))
when it has finished reading all the lines in a big file (I’m not using the LOOP signal, the Flow is an exercise to properly use
objects). Should I create a state handler and trigger a final reference task or is there something like
but at the Flow level? Any other alternatives?
script here, just in case.
Hi @Julio Venegas, That’s for sharing your script! Very helpful 😄
I might suggest raising a
signal instead of
because I believe you’re trying to communicate a successful outcome for the Task
Ok, thanks! But if there are more runs scheduled, it would continue running each of them right?
The way I’m reading this,
will run as a single Task Run for a given Flow run
So using either Signal is going to end the execution of that particular Task Run
(you won’t hit the subsequent while loop)
If you want to run another Task only if you’ve hit that conditional block, you could instead return some object that indicates that
and use control flow Tasks to enforce it
Niiice!! Will try out your suggestions, thanks a lot!
If I understand you correctly, you want to run a Task only if that conditional block where the ENDRUN Signal resides is reached, correct?
If that conditional block is reached, I want to finish the Flow and not run any other downstream Tasks.
Got it!
So basically at the time ENDRUN is raised, I also want to finish the Flow.
Same idea applies, just in the inverse
If you return an object that says “don’t keep going”, you can use a control flow Task to end the run
🙌 1
Does that make sense?
Makes sense!! Will dig into the conditional logic page you sent.
Glad I could help! 😄
Thanks a bunch Dylan!
@Dylan would you mind checking my script? I did the conditional case Task, and I wanted to add a reference Task with
but I’m getting a
ValueError: reference tasks must be part of the flow.
actually, since that task has no downstream dependencies, it would be a terminal task right? so no need to make it a reference task anyways
Forget about the
question, it’s still a bit odd that it was raised but setting the reference task was unnecessary anyways. Thanks for all the help!
Hey Julio, sorry to miss out here
Seems like you got this sorted?
Let me know if I can help 😄
All sorted out 😄 thanks!