admin管理员组文章数量:1244270
I have a pretty simple DAG which has some primary operational tasks, and then some cleanup and reporting tasks. I would like to get the runtime of the operational bits either by the difference of the start time of the first task and the end time of the last operational one, or if I can do this by putting them in a task group, that would be even easier.
I'm not clear how to do this though. My tasks are built on custom operators built from the base Airflow operator class.
My ideal would be
def get_time_delta(start_task, end_task) -> int:
"""Determine time delta in seconds between two airflow tasks."""
# This is the bit I don't know where to find
return end_task.dt - start_task.dt
@dag(...)
def my_dag():
task1 = MyCustomOperator1(...)
task2 = MyCustomOperator2(...)
task3 = MyCustomEmitMetricOperator(runtime=get_time_delta(task1, task2))
task1 >> task2 >> task3
Any support on how to achieve this would be greatly appreciated.
本文标签: How to find runtime for a set of tasks in an Airflow DAGStack Overflow
版权声明:本文标题:How to find run-time for a set of tasks in an Airflow DAG - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740184351a2237925.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论