You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/03/08 07:52:34 UTC

[GitHub] [airflow] amaury-bhg opened a new issue #22072: @task decorator does not handle "templates_exts" argument correctly (files are not rendered)

amaury-bhg opened a new issue #22072:
URL: https://github.com/apache/airflow/issues/22072


   ### Apache Airflow version
   
   2.2.2
   
   ### What happened
   
   When I use Taskflow, and especially the `@task` decorator to create a task, the template files are not correctly rendered : I still have the filename inside `templates_dict` instead of the templated file content, even though I supplied a valid `templates_exts` argument (at least one which works with `PythonOperator`).
   
   I do not encounter the same issue using the old  `PythonOperator` syntax.
   
   ### What you expected to happen
   
   I expect that the behavior of the ̀@task` decorator would be the same as the `PythonOperator` class, or at least have a workaround explained in the documentation such as other arguments I would need to provide.
   
   ### How to reproduce
   
   ̀̀Sample code below :
   
   ```python
   from airflow.decorators import task
   
   @task(templates_dict={"query": "sql/sample.sql"}, templates_exts=[".sql"])
   def aggregate_logs(**kwargs):
       logging.info("query: %s", str(kwargs["templates_dict"]["query"]))
   ̀̀```
   Which returns `INFO - query: sql/sample.sql`.
   
   However, if I use a `PythonOperator` with the old syntax it works :
   ̀̀```python
   from airflow.operators.python import PythonOperator
   
   def aggregate_logs(**kwargs):
       logging.info("query: %s", str(kwargs["templates_dict"]["query"]))
   
   aggregate_task = PythonOperator(
       python_callable=aggregate_logs,
       templates_dict={"query": "sql/sample.sql"},
       templates_exts=[".sql"],
   )
   ̀̀```
   I get the entire templated file inside `kwargs["templates_dict"]["query"]`, not just its name.
   
   ### Operating System
   
   AWS MWAA
   
   ### Versions of Apache Airflow Providers
   
   Not sure if relevant here since I only use Airflow packages in the example.
   
   ### Deployment
   
   MWAA
   
   ### 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
   
   - [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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] boring-cyborg[bot] commented on issue #22072: @task decorator does not handle "templates_exts" argument correctly (files are not rendered)

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #22072:
URL: https://github.com/apache/airflow/issues/22072#issuecomment-1061500200


   Thanks for opening your first issue here! Be sure to follow the issue template!
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] xingularity commented on issue #22072: @task decorator does not handle "templates_exts" argument correctly (files are not rendered)

Posted by GitBox <gi...@apache.org>.
xingularity commented on issue #22072:
URL: https://github.com/apache/airflow/issues/22072#issuecomment-1066041776


   I am interested in this issue and I would like to work on it.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org