I want to generate multiple airflow dags using one script. The dag names should be "test_parameter". Below is my script:
from datetime import datetime
# Importing Airflow modules
from airflow.models import DAG
from airflow.operators import DummyOperator
# Specifying the default arguments for the DAG
default_args = {
'owner': 'Test',
'start_date': datetime.now()
}
parameter_list = ["abc", "pqr", "xyz"]
for parameter in parameter_list:
dag = DAG("test_"+parameter,
default_args=default_args,
schedule_interval=None)
dag.doc_md = "This is a test dag"
# Creating Start Dummy Operator
start = DummyOperator(
task_id="start",
dag=dag)
# Creating End Dummy Operator
end = DummyOperator(
task_id="end",
dag=dag)
# Design workflow of tasks in the dag
end.set_upstream(start)
So in this case, it should create 3 dags: "test_abc", "test_pqr" and "test_xyz".
But on running the script, it creates only one dag "test_xyz". Any insights on how to solve this issue. Thanks in advance :)