Created
March 13, 2025 14:07
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import datetime as dt | |
from airflow.decorators import task, dag | |
default_args = {"owner": "airflow", "start_date": dt.datetime(2024, 2, 1), "retries": 1} | |
@task.branch() | |
def choose_branch(): | |
return random.choice(["task_a", "task_b"]) # Randomly chooses a branch | |
@task | |
def task_a(): | |
print("Task A is running") | |
@task | |
def task_b(): | |
print("Task B is running") | |
@dag(default_args=default_args, catchup=False, schedule="@daily") | |
def my_dag(): | |
choose_branch() >> [task_a(), task_b()] | |
my_dag() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment