Skip to content

Dynamic generated Dag using JINJA templete is not appearing in the Airflow UI #48955

Description

@kkrishrao

Apache Airflow version

2.10.5

If "Other Airflow 2 version" selected, which one?

No response

What happened?

Hello Team
we generate the dag using below JINJA templet and its created a dag1.py ...but it is not appearing in Airflow UI and also not Runnings as per schedule time
when I am using a command inside worker pod
airflow dags reserialize
its appeared in UI and runs and dissapeared.In production some one cannot do this every time.How to fix
Airflow version is 2.10.x

from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime, timedelta

def print_hello():
print("Hello World {{ dag_id }}")

default_args = {
'owner': 'fasadmin',
'depends_on_past': False,
'start_date': datetime(2024, 10, 15),
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
}

dag = DAG(
'{{ dag_id }}',
default_args=default_args,
description='A simple DAG to print Hello World dynamically',
schedule_interval="*/2 * * * *", # Set to None for on-demand execution
is_paused_upon_creation=False,
catchup=False,
concurrency=1,
max_active_runs=1,
tags=["dynamic"],
)

t1 = PythonOperator(
task_id='print_hello',
python_callable=print_hello,
dag=dag,
)
t1
globals()["{{ dag_id }}"] = dag

What you think should happen instead?

When the DAG is generated in the DAG folder, the DAG should appear immediately

How to reproduce

Create a DAG using ninja template in the default DAG folder.
Login to the Airflow UI and the DAG is not displayed until we forcefully run "airflow dags reserialize"

Operating System

k8s

Versions of Apache Airflow Providers

Bitnami

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions