所以我将 DAG 从气流版本 1.12.15 升级到 2.2.2 并将 python 从 3.8 降级到 3.7(因为 MWAA 不支持 python 3.8)。DAG 在之前的设置中运行良好,但在 MWAA 设置中显示此错误:
Broken DAG: [/usr/local/airflow/dags/google_analytics_import.py] Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 1474, in set_downstream
self._set_relatives(task_or_task_list, upstream=False, edge_modifier=edge_modifier)
File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 1412, in _set_relatives
task_object.update_relative(self, not upstream)
AttributeError: 'DAG' object has no attribute 'update_relative'
这是似乎失败的内置函数:
def set_downstream(
self,
task_or_task_list: Union[TaskMixin, Sequence[TaskMixin]],
edge_modifier: Optional[EdgeModifier] = None,
) -> None:
"""
Set a task or a task list to be directly downstream from the current
task. Required by TaskMixin.
"""
self._set_relatives(task_or_task_list, upstream=False, edge_modifier=edge_modifier)
有我们试图在 DAG 中运行的代码:
for report in reports:
dag << PythonOperator(
task_id=f"task_{report}",
python_callable=process,
op_kwargs={
"conn": "snowflake_production",
"table": report,
},
provide_context=True,
)
我认为从 Python 3.8 到 3.7 的过渡导致了这个问题,但我不确定。
有没有人遇到过类似的问题?