AirFlow dag id访问子任务

时间:2016-07-11 10:23:03

标签: oozie airflow

我有一个DAG有三个bash任务,计划每天运行。

我想在所有bash脚本中访问dag实例的唯一ID(可能是PID)。

有没有办法做到这一点?

我正在寻找与Oozie类似的功能,我们可以在工作流xml或java代码中访问WORKFLOW_ID。

有人可以向我指出AirFlow的文档"如何在AirFlow DAG中使用内置和自定义变量"

非常感谢 帕里

2 个答案:

答案 0 :(得分:1)

可以在jinja2中使用点表示法访问对象的属性(请参见https://airflow.apache.org/code.html#macros)。在这种情况下,它就是:

{{ dag.dag_id }}

答案 1 :(得分:0)

i made use of the fact that the python object for if line[:-2] == ';\n': print(line) prints out the name of the current dag. so i just use jinja2 to change the dag name:

dag

bit of a hack, but it works.

therefore,

{{ dag | replace( '<DAG: ', '' ) | replace( '>', '' ) }}
相关问题