Skip to content

Instantly share code, notes, and snippets.

@antweiss
Last active April 25, 2023 10:51
Show Gist options
  • Save antweiss/07eb87d3d86cb448d319af22f22dde3d to your computer and use it in GitHub Desktop.
Save antweiss/07eb87d3d86cb448d319af22f22dde3d to your computer and use it in GitHub Desktop.
Aitflow bash operator with templating
from textwrap import dedent
# ...
templated_command = dedent(
"""
{% for i in range(5) %}
echo "{{ ds }}" #a variable (datestamp)
echo "{{ macros.ds_add(ds, 7)}}" #a built-in macro
{% endfor %}
"""
)
t3 = BashOperator(
task_id="templated",
depends_on_past=False,
bash_command=templated_command,
)
t2 >> t3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment