我如何在dag中获取execution

编程入门 行业动态 更新时间:2024-10-28 04:28:16
本文介绍了我如何在dag中获取execution_date?运营商之外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何在dag之外获取 execution_date 参数?

How can I get an execution_date parameter in outside of dag?

execution_min = "{{execution_date.strftime('%M') }}" if execution_min == '00': logging.info('**** ' + "YES, It's 00") final_task = DummyOperator( task_id='task_y00', ... dag=dag ) else: logging.info('**** ' + "NOPE!!!") final_task = DummyOperator( task_id='task_n00', ... dag=dag )

我想使用execution_date(尤其是分钟)动态设置任务流

I want to set a task stream with dynamically with execution_date (especially minute)

但是Jinja模板不适用于template_fields = ['execution_date']

But Jinja template won't work with template_fields = ['execution_date']

是否有任何解决方案可以从运算符外部获取执行参数(在DAG本身中为=)?

Are there any solutions to get the execution parameter from outside of operator (= in the DAG itself) ???

推荐答案

执行日期特定于DagRun. DagRun信息在DAG定义文件中不可用(在操作员的模板字段中可用,因为它们是在运行时通过Jinja进行解析的).即使没有运行dag,调度程序,Web服务器和辅助程序也会频繁地解析DAG定义文件.这就是为什么在实际的DagRun之外无法访问执行日期之类的原因.

Execution date is specific to a DagRun. DagRun information is not available in a DAG definition file (it is available in an Operator's template fields because these get parsed at run-time via Jinja). DAG definition files are parsed frequently by the scheduler, webserver and workers even when the dag isn't running. This is why outside of an actual DagRun there is no access to things like execution date.

此外,无法在运行时为DAG添加/减去任务.您可以拥有动态dag,它们的结构在运行之前就已确定(例如,将文件解析为DAG结构),但是您无法添加任务或确定DAG在运行时的外观.

Furthermore there is no way to add/subtract tasks to a DAG run at runtime. You can have dynamic dags whose structure is decided before they run (ie. parse a file into a DAG structure), but you can't add tasks or decide what a DAG looks like while it's running.

更多推荐

我如何在dag中获取execution

本文发布于:2023-11-23 17:31:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622297.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   dag   execution

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!