while we are trying to pass dag conf variables as parameters and running in a loop with decorator we are getting below error. is there a way to fix
error in **taskinfo >> completed **
with DAG(
dag_id="test_dag",
start_date=datetime(2022, 1, 24),
schedule_interval=None,
render_template_as_native_obj=True,
default_args={},
params={
"param2": "arya2@gmail.com",
"sourcedir": ['/home/arya/'],
"timenum": 0
},
catchup=False
) as dag:
@task
def make_list(lst):
context = get_current_context()
srcdir = []
for number in range(0, len(lst)):
srcdir.append(("abc" + lst[number] + "xyz"))
taskinfo = EmptyOperator(task_id=f"taskinfo_{number}")
taskinfo.execute(context)
completed = f"completed{number+1}"
completed = DummyOperator(task_id=completed,trigger_rule='all_success')
taskinfo >> completed
make_list("{{ params.sourcedir }}")
Error: Tried to create relationships between tasks that don't have DAGs yet. Set the DAG for at least one task and try again**