本文介绍了需要在Airflow中的DockerOperator中访问计划时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要在airflow的docker操作员中访问计划时间。例如

Need to access schedule time in airflow's docker operator. For example

t1 = DockerOperator(
task_id="task",
dag=dag,
image="test-runner:1.0",
docker_url="xxx.xxx.xxx.xxx:2376",
environment={"FROM": "{{(execution_date + macros.timedelta(hours=6,minutes=(30))).isoformat()}}"})

基本上,我需要在docker环境中填充调度时间。

Basically, I need to populate schedule time as docker environment.

推荐答案

仅当宏是template_fields时才起作用。其次,您需要检查使用的是哪个版本的气流,如果您使用的是1.9或更低版本,则它可能不适用于DockerOperator,注释中提到了@ tobi6,因为template_fields仅包含命令()


但是,那里有1.10稳定的DockerOperator添加环境。

First macros only works if it is a template_fields. Second, you need to check which version of airflow you are using, if you are using 1.9 or below, it is likely it won't work for DockerOperator which @tobi6 mentioned in the comment, since template_fields only included command (https://github.com/apache/incubator-airflow/blob/v1-9-stable/airflow/operators/docker_operator.py#L91)
However, 1.10 stable add environment there for DockerOperator. https://github.com/apache/incubator-airflow/blob/v1-10-stable/airflow/operators/docker_operator.py#L103

这篇关于需要在Airflow中的DockerOperator中访问计划时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 21:52