airflow TimeDeltaSensor fails with unsupported operand type

旧街凉风 提交于 2019-12-12 10:57:45

问题


In my DAG I have a TimeDeltaSensor created using:

from datetime import datetime, timedelta
from airflow.operators.sensors import TimeDeltaSensor 
wait = TimeDeltaSensor(
    task_id='wait',
    delta=timedelta(seconds=300),
    dag=dag
)

However when it runs I get error

  • Subtask: [2018-07-13 09:00:39,663] {models.py:1427} ERROR - unsupported operand type(s) for +=: 'NoneType' and 'datetime.timedelta'

Airflow version is 1.8.1.

The code is basically lifted from Example Pipeline definition so I'm nonplussed as to what the problem could be. Any ideas?


回答1:


Looking into the source code you linked there is one line that strikes me as interesting in this case:

target_dttm = dag.following_schedule(context['execution_date'])

Which means: If you don't have setup a proper DAG schedule this component will try to add its time delta to None.

I am not sure if the code in the question is just an example or the whole thing. My suggestion is: Add a DAG schedule with is other than None.



来源:https://stackoverflow.com/questions/51321699/airflow-timedeltasensor-fails-with-unsupported-operand-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!