出现这个错误是因为Airflow版本问题,更新到最新版本可以解决该问题。同时,确保在代码中使用正确的方法调用。例如,在DAG定义中使用“PythonOperator”时,在代码中调用正确的方法。
示例代码如下:
from airflow import DAG from airflow.operators.python_operator import PythonOperator from datetime import datetime
def my_func(): print("Hello World")
with DAG('my_dag', start_date=datetime(2022, 2, 1), schedule_interval='@daily') as dag:
task_1 = PythonOperator(
task_id='task_1',
python_callable=my_func,
dag=dag
)
task_2 = PythonOperator(
task_id='task_2',
python_callable=my_func,
dag=dag
)
task_1 >> task_2
确保使用的是正确的Airflow版本和方法调用可以解决“Airflow AttributeError: 'coroutine' object has no attribute 'update_relative'” 这个问题。