气流计划任务“ t2failure”取决于任务t1

时间:2018-08-28 09:46:28

标签: airflow-scheduler

t1 = BashOperator(
    task_id='task_1',
    bash_command="Rscript Failure.R",
    dag=dag)

t2 = BashOperator(
    task_id='task_2',
    bash_command="Rscript Success.R",
    dag=dag)

t1fail = BashOperator(
    trigger_rule=TriggerRule.ONE_FAILED,
    task_id='task_1fail',
    bash_command="echo task1 failed",
    dag=dag)

t2fail = BashOperator(
    trigger_rule=TriggerRule.ONE_FAILED,
    task_id='task_2fail',
    bash_command="echo task2 failed",
    dag=dag)

tSuccess = BashOperator(
    task_id='t_Success',
    bash_command="echo task1 failed",
    dag=dag)

t2.set_upstream(t1)
tSuccess.set_upstream(t1, t2)
t2fail.set_upstream(t2)
t1fail.set_upstream(t1)

当任务t1执行失败时,理想情况是调用t1fail。 但是我得到的是任务t2fail也被调用,因为触发器设置为一个失败。有没有一种方法可以使任务t2仅在任务t2运行并且失败时才能启动。

0 个答案:

没有答案