<@ULVA73B9P> I have flaky tasks and I use allow_fa...
# ask-marvin
a
@Marvin I have flaky tasks and I use allow_failure to make sure downstream jobs continue; is there a way to mark the whole flow as
COMPLETE_WITH_ERRORS
or something similar to distinguish unexpected failures from the ones we tolerate?
m
It seems there isn't a direct feature in Prefect that allows marking a flow as
COMPLETE_WITH_ERRORS
or something similar directly out-of-the-box. However, Prefect has introduced automated error summaries in the latest release of Prefect Cloud (according to Prefect Blog), which can help to triage and manage failed runs quickly. This might not mark the whole flow in a specific way but gives a path to detect and analyze any errors that occur, including those that are tolerated by the
allow_failure
parameter of tasks. For flaky tasks, you could consider using a combination of retries and the
allow_failure
parameter to handle failures. If you want to mark the flow in a certain way after completion, you might have to implement some custom logic within your flow to check task statuses and then set a flow-level status or message manually based on those. This would likely be a combination of querying the state of the tasks within the flow and then using a conditionally run task to set the overall flow message/status. If there are any more recent updates or community practices around this, we might find something relevant on GitHub issues or discussions, so let's consider searching there as well. Would you like me to search GitHub for any discussions or issues related to handling flaky tasks or marking flows with a certain status on Prefect?
n
you can return a named
Completed
state when you handle the error
Copy code
from prefect.states import Completed

@flow
def something():
  try:
    flaky_code():
  except SomeException:
    return Compeleted(message="its ok", name="CompletedWithErrors")
🙌 1
g
@Nate Is there a way at the end of a flow to pull the tasks states of that flow similar to what generates this
Finished in state Failed('1/11 states failed.')
n
not a public way, but if you're curious how its working ill point you here