https://prefect.io logo
Title
j

JC Garcia

02/19/2021, 3:28 PM
Hello, I am seeing flows fail if a task with an
any_failed
trigger is not fired because no task failed. Is there any way to fix this? docs
n

nicholas

02/19/2021, 3:57 PM
Hi @JC Garcia - would you mind sharing a minimum example of your code? That's a little surprising to me.
j

JC Garcia

02/19/2021, 4:01 PM
code looks like this:
@task
def task_one:
  #no failure here

@task
def task_two:
  #no failure here

@task(trigger=any_failed)
def set_failure() -> None:
    raise signals.FAIL()


with Flow("flow-name") as flow:
    task_one()
    task_two()

    failure = set_failure(upstream_tasks=[task_one, task_one])
n

nicholas

02/19/2021, 4:02 PM
Ahh ok I see. What a pretty run chart! One sec
In this case you'll want to use
set_reference_tasks
to a list of the tasks that you want to determine the final state of your flow. So you could so something like this:
@task
def task_one:
  #no failure here

@task
def task_two:
  #no failure here

@task(trigger=any_failed)
def set_failure() -> None:
    raise signals.FAIL()



with Flow("flow-name") as flow:
    task_1 = task_one()
    task_2 = task_two()

    failure = set_failure(upstream_tasks=[task_one, task_one])

flow.set_reference_tasks([task_1, task_2])
j

JC Garcia

02/19/2021, 4:10 PM
awesome, thanks Nicholas!
😄 1