Apache Airflow version
2.2.5 (latest released)
What happened
When running this dag:
from airflow.models import DAG
from airflow.operators.python import PythonOperator
from airflow.models.renderedtifields import RenderedTaskInstanceFields as rtif
from airflow import settings
import datetime
def template_ext_func(**context):
file = context['templates_dict']['filename']
print(file)
with DAG(
dag_id="python_template_searchpath_bug",
start_date=datetime.datetime(2021, 1, 1),
schedule_interval=datetime.timedelta(days=365),
render_template_as_native_obj=True,
tags=["core", "python-operator"]
) as dag:
py0 = PythonOperator(
task_id="templates_dict_test",
python_callable=template_ext_func,
templates_dict={"filename": "/usr/local/airflow/include/python_template_exts.txt"},
templates_exts=[".txt"]
)
I get the exception of jinja2.exceptions.TemplateNotFound: /usr/local/airflow/include/python_template_exts.txt
However when I add a template searchpath of '/' to the dag's parameters the template is found by airflow. It seems like airflow is prepending the default location of the template_searchpath to the absolute path of the filename.
What you think should happen instead
I think if an absolute path is provided as a filename with templates_exts=[".txt"] then airflow should either be able to find the templated file or it should recognize that an absolute path was passed in as the filename or it should show where airflow is looking for the templated file.
How to reproduce
No response
Operating System
Docker (debian:buster)
Versions of Apache Airflow Providers
No response
Deployment
Astronomer
Deployment details
Using the Astro CLI with this image:
FROM quay.io/astronomer/ap-airflow:2.2.5-onbuild
Anything else
No response
Are you willing to submit PR?
Code of Conduct
Apache Airflow version
2.2.5 (latest released)
What happened
When running this dag:
I get the exception of
jinja2.exceptions.TemplateNotFound: /usr/local/airflow/include/python_template_exts.txtHowever when I add a template searchpath of '/' to the dag's parameters the template is found by airflow. It seems like airflow is prepending the default location of the template_searchpath to the absolute path of the filename.
What you think should happen instead
I think if an absolute path is provided as a filename with
templates_exts=[".txt"]then airflow should either be able to find the templated file or it should recognize that an absolute path was passed in as the filename or it should show where airflow is looking for the templated file.How to reproduce
No response
Operating System
Docker (debian:buster)
Versions of Apache Airflow Providers
No response
Deployment
Astronomer
Deployment details
Using the Astro CLI with this image:
FROM quay.io/astronomer/ap-airflow:2.2.5-onbuild
Anything else
No response
Are you willing to submit PR?
Code of Conduct