-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdag_using_taskflow_api.py
53 lines (41 loc) · 1.26 KB
/
dag_using_taskflow_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from datetime import datetime, timedelta
from airflow.models import DAG, Variable
from airflow.operators.bash import BashOperator
from airflow.operators.python import PythonOperator
from airflow.decorators import dag, task
default_args = {
'owner': 'Aditya Shah',
'retries': 5,
'retry_delay': timedelta(minutes=2)
}
@dag(
dag_id = 'dag_using_taskflow_V02',
default_args = default_args,
description = 'This is the first attempt at a DAG.',
schedule_interval = '* * * * *',
start_date = datetime(year=2022, month=8, day=13),
catchup = False
)
def hello_world_etl():
@task(multiple_outputs = True)
def get_name():
return {
'first_name': 'Aditya',
'last_name': 'Shah'
}
@task()
def get_age():
return 23
@task()
def greet(first_name, last_name, age):
print(
f'Hello World! My name is {first_name} {last_name}. ' +
f'I am {age} years old!'
)
name_dict = get_name()
age = get_age()
greet(
first_name = name_dict['first_name'],
last_name = name_dict['last_name'],
age = age)
greet_dag = hello_world_etl()