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

   ### Apache Airflow Provider(s)
   
   cncf-kubernetes
   
   ### Versions of Apache Airflow Providers
   
   ```
   $ pip freeze | grep apache-airflow-providers
   apache-airflow-providers-cncf-kubernetes==4.4.0
   ```
   
   ### Apache Airflow version
   
   2.4.1
   
   ### Operating System
   
   macos-12.6
   
   ### Deployment
   
   Other Docker-based deployment
   
   ### Deployment details
   
   Using the astro cli.
   
   ### What happened
   
   Trying to test the `@task.kubernetes` decorator with Airflow 2.4.1 and the 
`apache-airflow-providers-cncf-kubernetes==4.4.0` package, I get the following 
error:
   
   ```
   [2022-10-06, 10:49:01 UTC] {taskinstance.py:1851} ERROR - Task failed with 
exception
   Traceback (most recent call last):
     File 
"/Users/jeff/tmp/penv/lib/python3.9/site-packages/airflow/providers/cncf/kubernetes/decorators/kubernetes.py",
 line 95, in execute
       write_python_script(jinja_context=jinja_context, 
filename=script_filename)
     File 
"/Users/jeff/tmp/penv/lib/python3.9/site-packages/airflow/providers/cncf/kubernetes/python_kubernetes_script.py",
 line 79, in write_python_script
       template = template_env.get_template('python_kubernetes_script.jinja2')
     File 
"/Users/jeff/tmp/penv/lib/python3.9/site-packages/jinja2/environment.py", line 
1010, in get_template
       return self._load_template(name, globals)
     File 
"/Users/jeff/tmp/penv/lib/python3.9/site-packages/jinja2/environment.py", line 
969, in _load_template
       template = self.loader.load(self, name, self.make_globals(globals))
     File "/Users/jeff/tmp/penv/lib/python3.9/site-packages/jinja2/loaders.py", 
line 126, in load
       source, filename, uptodate = self.get_source(environment, name)
     File "/Users/jeff/tmp/penv/lib/python3.9/site-packages/jinja2/loaders.py", 
line 218, in get_source
       raise TemplateNotFound(template)
   jinja2.exceptions.TemplateNotFound: python_kubernetes_script.jinja2
   ```
   
   Looking the [source 
file](https://files.pythonhosted.org/packages/5d/54/0ea031a9771ded6036d05ad951359f7361995e1271a302ba2af99bdce1af/apache-airflow-providers-cncf-kubernetes-4.4.0.tar.gz)
 for the `apache-airflow-providers-cncf-kubernetes==4.4.0` package, I can see 
that `python_kubernetes_script.py` is there but 
`python_kubernetes_script.jinja2`
   
   ``` 
   $ tar -ztvf apache-airflow-providers-cncf-kubernetes-4.4.0.tar.gz 
'apache-airflow-providers-cncf-kubernetes-4.4.0/airflow/providers/cncf/kubernetes/py*'
   -rw-r--r--  0 root   root     2949 Sep 22 15:25 
apache-airflow-providers-cncf-kubernetes-4.4.0/airflow/providers/cncf/kubernetes/python_kubernetes_script.py
   ```
   
   
   ### What you think should happen instead
   
   The `python_kubernetes_script.jinja2` file that is available here 
https://github.com/apache/airflow/blob/main/airflow/providers/cncf/kubernetes/python_kubernetes_script.jinja2
 should be included in the `apache-airflow-providers-cncf-kubernetes==4.4.0` 
pypi package.
   
   ### How to reproduce
   
   With a default installation of `apache-airflow==2.4.1` and 
`apache-airflow-providers-cncf-kubernetes==4.4.0`, running the following DAG 
will reproduce the issue.
   
   ```
   import pendulum
   from airflow.decorators import dag, task
   
   @dag(
       schedule_interval=None,
       start_date=pendulum.datetime(2022, 7, 20, tz="UTC"),
       catchup=False,
       tags=['xray_classifier'],
   )
   def k8s_taskflow():
   
       @task.kubernetes(
           image="python:3.8-slim-buster",
           name="k8s_test",
           namespace="default",
           in_cluster=False,
           config_file="/path/to/config"
       )
       def execute_in_k8s_pod():
           import time
           print("Hello from k8s pod")
           time.sleep(2)
   
   
       execute_in_k8s_pod_instance = execute_in_k8s_pod()        
   
   k8s_taskflow_dag = k8s_taskflow()
   ```
   
   ### Anything else
   
   If I manually add the `python_kubernetes_script.jinja2` into my 
`site-packages/airflow/providers/cncf/kubernetes/` folder, then it works as 
expected.
   
   ### 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