-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskflow_api.py
More file actions
63 lines (35 loc) · 1014 Bytes
/
Copy pathtaskflow_api.py
File metadata and controls
63 lines (35 loc) · 1014 Bytes
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
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from datetime import datetime
from airflow.decorators import dag,task
# Define default arguments
default_args = {
'owner': 'bibek',
'start_date': datetime(2024, 2, 28),
'retries': 1,
}
# Instantiate your DAG old style
#dag = DAG('my_first_dag', default_args=default_args, schedule_interval=None)
@dag(dag_id='dag_code_in_different_style',
default_args=default_args,
tags=['dependencies','python','taskflow_api']
)
def dag_with_taskflow_api():
@task
def task1():
print("Executing Task 1")
@task
def task2():
print("Executing Task 2")
@task
def task3():
print("Executing Task 3")
@task
def task4():
print("Executing Task 4")
@task
def task5():
print("Executing Task 5")
# Set task dependencies
task1() >> [ task2(),task3(),task4()] >> task5()
dag_with_taskflow_api()