Reputation: 169
Please help me with
{{ execution_date.subtract(hours = 5) }}
Here instead of hardcoding 5, I want to pass it as a variable.
I am not able to find a way to pass a variable and finally use the value of the variable.
Upvotes: 2
Views: 1849
Reputation: 16139
You can use:
f'echo {{{{ execution_date.subtract(hours = {value}) }}}}'
Example with 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,
)
Upvotes: 3