我已设置气流并运行一些 DAG,安排每天一次“0 0 * * *”。
我想检查下次计划运行特定 dag 的时间,但我看不到可以在管理员中执行此操作的位置。
如果你愿意,你可以使用Airflow
's CLI
, 有next_execution option https://airflow.apache.org/cli.html#next_execution
获取 DAG 的下一个执行日期时间。
airflow next_execution [-h] [-sd SUBDIR] dag_id
UPDATE-1
如果您需要以编程方式执行此操作(在 Airflowtask
),可以参考
-
next_execution(..)功能 https://github.com/apache/airflow/blob/v1-10-stable/airflow/bin/cli.py#L602 of cli.py https://github.com/apache/airflow/blob/v1-10-stable/airflow/bin/cli.py
- (现已移至dag_next_execution(..)功能 https://github.com/apache/airflow/blob/c1f94786b901b8e5dabc963514062f7dda878aae/airflow/cli/commands/dag_command.py#L269 of dag_command.py https://github.com/apache/airflow/blob/c1f94786b901b8e5dabc963514062f7dda878aae/airflow/cli/commands/dag_command.py in master https://github.com/apache/airflow/blob/master/airflow/cli/commands/dag_command.py)
@cli_utils.action_logging
def next_execution(args):
"""
Returns the next execution datetime of a DAG at the command line.
>>> airflow next_execution tutorial
2018-08-31 10:38:00
"""
dag = get_dag(args)
if dag.is_paused:
print("[INFO] Please be reminded this DAG is PAUSED now.")
if dag.latest_execution_date:
next_execution_dttm = dag.following_schedule(dag.latest_execution_date)
if next_execution_dttm is None:
print("[WARN] No following schedule can be found. " +
"This DAG may have schedule interval '@once' or `None`.")
print(next_execution_dttm)
else:
print("[WARN] Only applicable when there is execution record found for the DAG.")
print(None)
UPDATE-2
不仅要获得下一个,还要更进一步execution_date
s,参考Airflow - 如何获取所有未来的运行日期 https://stackoverflow.com/q/63527204/3679900
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)