JC Garcia

    JC Garcia

    1 year ago
    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
    nicholas

    nicholas

    1 year ago
    Hi @JC Garcia - would you mind sharing a minimum example of your code? That's a little surprising to me.
    JC Garcia

    JC Garcia

    1 year ago
    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])
    nicholas

    nicholas

    1 year ago
    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])
    JC Garcia

    JC Garcia

    1 year ago
    awesome, thanks Nicholas!