如何在开始日期而不是执行日期触发气流调度(使执行日期等于开始日期)?

2024-04-24 13:35:52 发布

您现在位置:Python中文网/ 问答频道 /正文

https://airflow.apache.org/scheduler.html

Note that if you run a DAG on a schedule_interval of one day, the run stamped 2016-01-01 will be trigger soon after 2016-01-01T23:59. In other words, the job instance is started once the period it covers has ended.

这一特点很伤人。你知道吗

例如,我有每天运行的etl作业,schedule\u interval是0 1 * * *,因此它将在2019-09-22 01:00:00触发2019-09-23 01:00:00的作业。但是我的etl正在处理开始日期之前的所有数据,这意味着数据范围介于(history,2019-09-23 00:00:00)之间,我们不能使用datetime.now(),因为这无法再现。这迫使我在执行日期前加1天:

etl_end_time = "{{ (execution_date + macros.timedelta(days=1)).strftime('%Y-%m-%d 00:00:00') }}"

但是,当我需要用调度间隔45 2,3,4,5,6 * * *运行作业时,2019-09-22 06:45:00作业将在2019-09-23 02:45:00上运行,这是执行日期(下一次执行时间)后的一天。我没有增加一天,而是改变了调度间隔45 2,3,4,5,6,7 * * *,并在最后一次运行时添加了一个伪操作符。 在这种情况下,您不需要在执行日期上添加一天,这意味着您必须定义两个etl_end_time来表示具有不同计划间隔的作业中的相同日期。你知道吗

所有这些对我来说都很不舒服,有没有配置或内置的方法使执行日期等于开始日期?或者我必须修改源代码。。。你知道吗


Tags: the数据runhttpsorg间隔timeapache
2条回答

对于计划的运行,下次执行日期将返回触发它的确切时间。你知道吗

我发现有个公关 https://github.com/apache/airflow/pull/5787

This change introduces the attribute schedule_interval_edge, a string containing either 'start' or 'end', to DAGs. The scheduler uses the value to determining if a DAG should be scheduled at the start or the end of the schedule interval.

A parameter with the same name was also added to the default_airflow.cfg in the [scheduler] section.

我在这张公关上记下了密码

相关问题 更多 >