I have a flow that insert rows into a database. So...
# prefect-community
m
I have a flow that insert rows into a database. Sometimes a row or two are not inserted due to an error. Right now the flow terminates, but I want to continue running the flow but in the end set the flow run to failed or maybe to some kind of warning. Is that possible?
j
Hi @Mikael, this is certainly possible, but without knowing more about how your flow looks, I can't give you more specific advice. A few general notes: • Prefect has triggers, which decide if a task can run based on the state of upstream tasks: https://docs.prefect.io/core/concepts/execution.html#triggers. By default, a task will run only if the upstream tasks all succeeded. Through the use of triggers, you could set a task downstream from your tasks that may fail to determine what the downstream state should be. • The state of a flow run is determined by the state of its reference tasks: https://docs.prefect.io/core/concepts/flows.html#reference-tasks. By default, reference tasks are all tasks that have no downstream dependents. If needed, you can configure the reference tasks to base the final state on a different set of tasks. By combining these two components (triggers on tasks and reference tasks on flows) you generally can get whatever state outputs you want.
m
Thanks for this. I have been reading a little about it but it certainly help to get some notes of how I can use it. I think I go for a split between success, semi-failed (some rows errored) and total error. And handle each after that.