tronlightracer opened a new issue, #23333:
URL: https://github.com/apache/airflow/issues/23333

   ### 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?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to