英文:
Getting airflow exception: DAG is missing start_date parameter
问题
以下是您要翻译的内容:
当我查看文档时,没有提到在创建一个dag时需要传递start_date参数。当我不传递该参数时,我会得到以下错误:
Broken DAG: [/opt/airflow/dags/dag_api_to_minio.py] Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 1039, in dag
dag.add_task(self)
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/dag.py", line 2328, in add_task
raise AirflowException("DAG is missing the start_date parameter")
airflow.exceptions.AirflowException: DAG is missing the start_date parameter
这是我使用TaskFlow API定义的dag:
@dag(start_date=None,
schedule_interval=None,
max_active_runs=1,
catchup=False,
default_args={
"retries": 1,
"retry_delay": timedelta(minutes=3)
},)
版本信息:airflow:2.5.1, python:3.7
有人能解释一下发生了什么吗?
期望输出:代码应该可以无错误运行,因为start_date不是一个必需的参数
实际输出:airflow异常:缺少start_date参数
英文:
When I checked the documentation, it was not mentioned anywhere that the start_date is a required parameter to be passed while creating a dag. I am getting the following error when I don't pass the parameter:
Broken DAG: [/opt/airflow/dags/dag_api_to_minio.py] Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 1039, in dag
dag.add_task(self)
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/dag.py", line 2328, in add_task
raise AirflowException("DAG is missing the start_date parameter")
airflow.exceptions.AirflowException: DAG is missing the start_date parameter
Here is my dag definition using the TaskFlow API:
@dag(start_date=None,
schedule_interval=None,
max_active_runs=1,
catchup=False,
default_args={
"retries": 1,
"retry_delay": timedelta(minutes=3)
},)
Versions: airflow:2.5.1, python:3.7
Can someone please explain what is going in here?
Expected output: The code should run without any errors as start_date is not a required parameter
Actual output: airflow exception: missing start_date parameter
答案1
得分: 1
因为它不是必需的。您可以在任务中定义start_date
。
当Airflow解析DAG时,它会尝试将任务注册到其关联的DAG对象中。在这个过程中,它会验证是否提供了start_date
。任务的start_date
会覆盖DAG的start_date
,但您必须在其中至少定义一个。您可以在源代码中查看这一点。
英文:
> it was not mentioned anywhere that the start_date is a required parameter to be passed while creating a dag
Because it's not. You may define the start_date
on the tasks.
When Airflow parse the DAG it tried to register tasks into their associated DAG objects. Part of that process it to verify that start_date
was provided. The task start_date
override the DAG start_date
but you must define at least in one of the objects. You can view this in the source code.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论