气流 - 如何获得所有未来的运行日期 [英] Airflow - how to get all the future run date

查看:28
本文介绍了气流 - 如何获得所有未来的运行日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在安排气流作业.但是,为了验证我是否安排了正确的作业,我需要查看将来何时运行.

I am working on scheduling a airflow job. However to verify if I have scheduled the correct job I need to see when it will run in the future.

Airflow 具有以下命令,可让我进行下一次运行.但是,这对于某些用例来说还不够.例如,我安排了每隔一个星期五运行一次作业.我如何验证这一点.

Airflow has following command which gives me the next run. however, that's not sufficient for some use cases. for example, I have scheduled a job run every other Friday. How do I verify that.

airflow next_execution <dag_id>

有没有办法,我可以获得此 dag 运行的所有未来日期.或至少几个?

Is there a way, I can get all the future dates when this dag will run. or atleast couple of ?

推荐答案

虽然大多数进程使用 croniter,但如果您有权访问您的安装,最好获得来自来源"的信息通过现有接口:

While most processes use croniter, if you have access to your installation it's always best to get the information from the "source" via existing interfaces:

from airflow import models
from datetime import datetime, timedelta


dag_bag = models.DagBag()

dag_id = "dag_name"
dag = dag_bag.get_dag(dag_id)

now = datetime.now()
until = now + timedelta(days=21)

runs = dag.get_run_dates(start_date=now, end_date=until)
print(runs)

这篇关于气流 - 如何获得所有未来的运行日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆