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

   ### Apache Airflow version
   
   Other Airflow 2 version (please specify below)
   
   ### What happened
   
   I believe that the `@task.short_circuit` operator is missing the code to 
handle the usage of `templates_dict`, as described in the 
[documentation](https://airflow.apache.org/docs/apache-airflow/stable/howto/operator/python.html#id4).
 The code snippet below demonstrates the issue. In it, I create two tasks. The 
first is a basic python task, and in the log, from the print statement, I see 
the contents of the `.sql` file. (So the templating worked correctly.) However, 
in the log for the second task, I see only the string itself, with no jinja 
templating performed. I think this contradicts the documentation.
   
   ```python
   from airflow.decorators import dag, task
   import datetime as dt
   
   @dag(
       dag_id='test_dag',
       schedule=None,
       start_date=dt.datetime(2023, 7, 25, 0, 0, 0, tzinfo=dt.timezone.utc),
   )
   def test_dag():
       @task(task_id='test_task', templates_dict={'query': 'sql/myquery.sql'}, 
templates_exts=['.sql'])
       def test_task(templates_dict=None):
           print(templates_dict['query'])
   
       @task.short_circuit(task_id='test_tasksc', templates_dict={'query': 
'sql/myquery.sql'}, templates_exts=['.sql'])
       def test_tasksc(templates_dict=None):
           print(templates_dict['query'])
           return True
   
       test_task() >> test_tasksc()
   test_dag()
   ```
   
   Output of first task: `SELECT * FROM ...`.
   Output of second task: `sql/myquery.sql`.
   
   As a guess, I think the problem could be in [this 
line](https://github.com/apache/airflow/blob/main/airflow/decorators/short_circuit.py#L41),
 where `templates_dict` and `templatex_ext` are not explicitly passed to the 
super-class's init function. I am happy to make an MR if it's that small of a 
change.
   
   ### What you think should happen instead
   
   Output of first task: `SELECT * FROM ...`.
   Output of second task: `SELECT * FROM ...`.
   
   ### How to reproduce
   
   See MRE above.
   
   ### Operating System
   
   RHEL 7.9 (Maipo)
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow==2.5.0
   
   No relevant providers.
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] 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