For example my folder structure looks like this:
- dags
- __init__.py
- tasks
- __init__.py
- Task_A.py
- Task_B.py
- Main_Dag.py
File Task_A.py
import logging
from airflow.decorators import dag, task
@task()
def Task_A():
logging.info(f"Task A: Received param None")
return "A"
File Mian.py
from airflow.decorators import dag
from airflow.utils.dates import days_ago
from datetime import datetime
from .tasks.TaskA import Task_A
default_args = {"owner": "airflow", "start_date": datetime(2021, 1, 1)}
@dag(default_args=default_args, schedule_interval=None, start_date=days_ago(2))
def Import_Tasks():
a = Task_A()
Import_Tasks_dag = Import_Tasks()