Airflow BranchPythonOperator不执行一个分支

时间:2019-01-30 14:10:11

标签: airflow

关于此问题的其他帖子对我没有帮助。因此,我担心自己会忽略一些明显的问题,但是请注意。我的设置中的几个Airflow DAG使用BranchPythonOperator,其中之一从不执行特定的分支。以下是相关代码:

def check_transport():
   date = datetime.today().day;
   if date == 15 or date == 16:
       return 'skip_transport'
   else:
       return 'transport_data'

transport_data = BashOperator(
    task_id = 'transport_data',
    bash_command = '**Bash command to transport data is here and correct**',
    dag = dag)

skip_transport = DummyOperator(
    task_id = 'skip_transport',
    dag = dag)

transport_check = BranchPythonOperator(
    task_id = 'transport_check',
    python_callable = check_transport,
    dag = dag)
transport_check.set_downstream(transport_data)
transport_check.set_downstream(skip_transport)

DAG的树形视图在01/15上正确显示了skip_transport分支,将其标记为成功,并将transport_data标记为已跳过。前几天将skip_transport显示为已跳过,transport_data显示为白色(无状态),并且该分支未执行。

transport_check的日志表明它打算执行正确的操作:

[2019-01-30 07:44:17,786] {base_task_runner.py:95} INFO - Subtask: [2019-01-30 07:44:17,786] {models.py:1342} INFO - Executing <Task(BranchPythonOperator): transport_check> on 2019-01-29 03:30:00
[2019-01-30 07:44:17,835] {base_task_runner.py:95} INFO - Subtask: [2019-01-30 07:44:17,835] {python_operator.py:81} INFO - Done. Returned value was: transport_data
[2019-01-30 07:44:17,835] {base_task_runner.py:95} INFO - Subtask: [2019-01-30 07:44:17,835] {python_operator.py:106} INFO - Following branch transport_data
[2019-01-30 07:44:17,836] {base_task_runner.py:95} INFO - Subtask: [2019-01-30 07:44:17,835] {python_operator.py:107} INFO - Marking other directly downstream tasks as skipped
[2019-01-30 07:44:17,861] {base_task_runner.py:95} INFO - Subtask: [2019-01-30 07:44:17,861] {python_operator.py:119} INFO - Done.

我尝试将trigger_rule = "all_done"添加到PythonBranchOperator而不改变行为。

0 个答案:

没有答案