Initial commit
This commit is contained in:
parent
d4028fca11
commit
a578239c4f
32 changed files with 2559 additions and 0 deletions
48
Demo/stackit-02-regular-operators.py
Normal file
48
Demo/stackit-02-regular-operators.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import pendulum
|
||||
|
||||
from airflow.sdk import dag, task
|
||||
from airflow.operators.bash import BashOperator
|
||||
from textwrap import dedent
|
||||
|
||||
|
||||
@dag(
|
||||
schedule=None,
|
||||
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
|
||||
catchup=False,
|
||||
tags=["demo","stackit-demo"],
|
||||
dag_id="stackit_02_regular_operators",
|
||||
)
|
||||
def regular_operators():
|
||||
t1 = BashOperator(
|
||||
task_id="print_date",
|
||||
bash_command="date",
|
||||
)
|
||||
|
||||
t2 = BashOperator(
|
||||
task_id="sleep",
|
||||
depends_on_past=False,
|
||||
bash_command="sleep 10",
|
||||
retries=3,
|
||||
)
|
||||
|
||||
templated_command = dedent(
|
||||
"""
|
||||
{% for i in range(5) %}
|
||||
echo "{{ ds }}"
|
||||
echo "{{ macros.ds_add(ds, 7)}}"
|
||||
echo "{{ params.my_param }}"
|
||||
{% endfor %}
|
||||
"""
|
||||
)
|
||||
|
||||
t3 = BashOperator(
|
||||
task_id="templated",
|
||||
depends_on_past=False,
|
||||
bash_command=templated_command,
|
||||
params={"my_param": "Parameter I passed in"},
|
||||
)
|
||||
|
||||
t1 >> [t2, t3]
|
||||
|
||||
|
||||
regular_operators()
|
||||
Loading…
Add table
Add a link
Reference in a new issue