获取空气流异常:DAG缺少start_date参数

huangapple go评论85阅读模式
英文:

Getting airflow exception: DAG is missing start_date parameter

问题

以下是您要翻译的内容:

  1. 当我查看文档时,没有提到在创建一个dag时需要传递start_date参数。当我不传递该参数时,我会得到以下错误:
  2. Broken DAG: [/opt/airflow/dags/dag_api_to_minio.py] Traceback (most recent call last):
  3. File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 1039, in dag
  4. dag.add_task(self)
  5. File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/dag.py", line 2328, in add_task
  6. raise AirflowException("DAG is missing the start_date parameter")
  7. airflow.exceptions.AirflowException: DAG is missing the start_date parameter
  8. 这是我使用TaskFlow API定义的dag
  9. @dag(start_date=None,
  10. schedule_interval=None,
  11. max_active_runs=1,
  12. catchup=False,
  13. default_args={
  14. "retries": 1,
  15. "retry_delay": timedelta(minutes=3)
  16. },)
  17. 版本信息:airflow:2.5.1, python:3.7
  18. 有人能解释一下发生了什么吗?
  19. 期望输出:代码应该可以无错误运行,因为start_date不是一个必需的参数
  20. 实际输出: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:

  1. Broken DAG: [/opt/airflow/dags/dag_api_to_minio.py] Traceback (most recent call last):
  2. File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 1039, in dag
  3. dag.add_task(self)
  4. File "/home/airflow/.local/lib/python3.7/site-packages/airflow/models/dag.py", line 2328, in add_task
  5. raise AirflowException("DAG is missing the start_date parameter")
  6. airflow.exceptions.AirflowException: DAG is missing the start_date parameter

Here is my dag definition using the TaskFlow API:

  1. @dag(start_date=None,
  2. schedule_interval=None,
  3. max_active_runs=1,
  4. catchup=False,
  5. default_args={
  6. "retries": 1,
  7. "retry_delay": timedelta(minutes=3)
  8. },)

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.

huangapple
  • 本文由 发表于 2023年2月16日 09:10:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75466901.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定