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 2020/10/19 20:23:22 UTC

[GitHub] [airflow] ephraimbuddy opened a new issue #11666: PythonVirtualenvOperator fails to find python_virtualenv_script.jinja2 template

ephraimbuddy opened a new issue #11666:
URL: https://github.com/apache/airflow/issues/11666


   
   
   **Apache Airflow version**: 2.0
   
   
   **Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
   
   **Environment**: Docker
   
   - **Cloud provider or hardware configuration**:
   - **OS** (e.g. from /etc/os-release): Ubuntu
   - **Kernel** (e.g. `uname -a`): 
   - **Install tools**:
   - **Others**:
   
   **What happened**:
   
   The PythonVirtualenvOperator failed because it couldn't find the python_virtualenv_script.jinja2 in jinja2 environment
   
   **What you expected to happen**:
   
   I expected it to run without errors
   
   **How to reproduce it**:
   Run the provided example dag:
   ```
   from airflow import DAG
   from airflow.operators.python import PythonVirtualenvOperator
   from airflow.utils.dates import days_ago
   
   dag = DAG(
       dag_id='virtualenv_python_operator',
       default_args={"owner: Airflow"},
       schedule_interval="@once",
       start_date=days_ago(2),
       tags=['example']
   )
   
   
   def callable_virtualenv():
       """
       Example function that will be performed in a virtual environment.
   
       Importing at the module level ensures that it will not attempt to import the
       library before it is installed.
       """
       from time import sleep
   
       from colorama import Back, Fore, Style
       print(Fore.RED + 'some red text')
       print(Back.GREEN + 'and with a green background')
       print(Style.DIM + 'and in dim text')
       print(Style.RESET_ALL)
       for _ in range(10):
           print(Style.DIM + 'Please wait...', flush=True)
           sleep(10)
       print('Finished')
   
   
   virtualenv_task = PythonVirtualenvOperator(
       task_id="virtualenv_python",
       python_callable=callable_virtualenv,
       requirements=[
           "colorama==0.4.0"
       ],
       system_site_packages=False,
       dag=dag,
   )
   ```
   
   
   **Anything else we need to know**:
   
   The above dag produces the error below in log:
   ```
   [2020-10-19 19:15:03,694] {taskinstance.py:1348} ERROR - python_virtualenv_script.jinja2
   Traceback (most recent call last):
     File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 1087, in _run_raw_task
       self._prepare_and_execute_task_with_callbacks(context, task)
     File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 1209, in _prepare_and_execute_task_with_callbacks
       result = self._execute_task(context, task_copy)
     File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 1254, in _execute_task
       result = task_copy.execute(context=context)
     File "/usr/local/lib/python3.7/site-packages/airflow/operators/python.py", line 485, in execute
       super().execute(context=serializable_context)
     File "/usr/local/lib/python3.7/site-packages/airflow/operators/python.py", line 140, in execute
       return_value = self.execute_callable()
     File "/usr/local/lib/python3.7/site-packages/airflow/operators/python.py", line 514, in execute_callable
       filename=script_filename
     File "/usr/local/lib/python3.7/site-packages/airflow/utils/python_virtualenv.py", line 92, in write_python_script
       template = template_env.get_template('python_virtualenv_script.jinja2')
     File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 883, in get_template
       return self._load_template(name, self.make_globals(globals))
     File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 857, in _load_template
       template = self.loader.load(self, name, globals)
     File "/usr/local/lib/python3.7/site-packages/jinja2/loaders.py", line 115, in load
       source, filename, uptodate = self.get_source(environment, name)
     File "/usr/local/lib/python3.7/site-packages/jinja2/loaders.py", line 197, in get_source
       raise TemplateNotFound(template)
   jinja2.exceptions.TemplateNotFound: python_virtualenv_script.jinja2
   ```
   
   


----------------------------------------------------------------
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.

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



[GitHub] [airflow] mik-laj closed issue #11666: PythonVirtualenvOperator fails to find python_virtualenv_script.jinja2 template

Posted by GitBox <gi...@apache.org>.
mik-laj closed issue #11666:
URL: https://github.com/apache/airflow/issues/11666


   


----------------------------------------------------------------
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.

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