forked from astronomer/2-9-example-dags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoy_task_duration_page.py
56 lines (43 loc) · 1.2 KB
/
toy_task_duration_page.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
54
55
56
"""
### Toy with tasks of different durations
Use this DAG to showcase the new task duration page in the UI.
"""
from airflow.decorators import dag, task
import time
import random
from pendulum import datetime
random.seed(42)
@dag(
start_date=datetime(2024, 1, 1),
schedule="@daily",
catchup=False,
doc_md=__doc__,
tags=["UI", "toy"],
)
def toy_task_duration_page():
@task
def two_second_plus_delay_task() -> None:
delay = random.randint(0, 10)
time.sleep(2 + delay)
@task
def five_second_plus_delay_task() -> None:
delay = random.randint(0, 10)
time.sleep(5 + delay)
@task
def ten_second_plus_delay_task() -> None:
delay = random.randint(0, 10)
time.sleep(10 + delay)
@task
def twenty_second_plus_delay_task() -> None:
delay = random.randint(0, 10)
time.sleep(20 + delay)
@task
def thirty_second_plus_delay_task() -> None:
delay = random.randint(0, 10)
time.sleep(30 + delay)
two_second_plus_delay_task()
five_second_plus_delay_task()
ten_second_plus_delay_task()
twenty_second_plus_delay_task()
thirty_second_plus_delay_task()
toy_task_duration_page()