Python 在气流宏中传递变量
请帮我拿些东西Python 在气流宏中传递变量,python,variables,macros,airflow,Python,Variables,Macros,Airflow,请帮我拿些东西 {{execution\u date.subtract(小时=5)}} 这里不是硬编码5,而是将其作为变量传递。 我无法找到传递变量并最终使用变量值的方法。您可以使用: f'echo {{{{ execution_date.subtract(hours = {value}) }}}}' BashOperator的示例: value = 5 # This can be set dynamically hello_my_task = BashOperator( task_i
{{execution\u date.subtract(小时=5)}}
这里不是硬编码5,而是将其作为变量传递。
我无法找到传递变量并最终使用变量值的方法。您可以使用:
f'echo {{{{ execution_date.subtract(hours = {value}) }}}}'
BashOperator的示例:
value = 5 # This can be set dynamically
hello_my_task = BashOperator(
task_id='my_task',
bash_command=f'echo {{{{ execution_date.subtract(hours = {value}) }}}}',
dag=dag,
)