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

   ### Apache Airflow version
   
   2.7.2
   
   ### What happened
   
   Hi Guys,
   
   All our dags which use the PythonVirtualEnvOperator and call a python 
function using python_callable param, they fail due to FileNotFoundError for 
the tmp_dir/script.out file.
   Can someone explain why this is happening and what is expected for the 
script.out file? Is the python function supposed to print or return someting to 
write into the script.out file?
   
   ```
   Executing cmd: /tmp/venvx9cl8fpi/bin/python /tmp/venvx9cl8fpi/script.py 
/tmp/venvx9cl8fpi/script.in /tmp/venvx9cl8fpi/script.out 
/tmp/venvx9cl8fpi/string_args.txt
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.9/site-packages/airflow/operators/python.py", 
line 356, in execute
       return super().execute(context=serializable_context)
     File 
"/home/airflow/.local/lib/python3.9/site-packages/airflow/operators/python.py", 
line 175, in execute
       return_value = self.execute_callable()
     File 
"/home/airflow/.local/lib/python3.9/site-packages/airflow/operators/python.py", 
line 553, in execute_callable
       return self._execute_python_callable_in_subprocess(python_path, tmp_path)
     File 
"/home/airflow/.local/lib/python3.9/site-packages/airflow/operators/python.py", 
line 421, in _execute_python_callable_in_subprocess
       return self._read_result(output_path)
     File 
"/home/airflow/.local/lib/python3.9/site-packages/airflow/operators/python.py", 
line 373, in _read_result
       if path.stat().st_size == 0:
     File "/usr/local/lib/python3.9/pathlib.py", line 1232, in stat
       return self._accessor.stat(self)
   FileNotFoundError: [Errno 2] No such file or directory: 
'/tmp/venvx9cl8fpi/script.out'
   ```
   
   ### What you think should happen instead
   
   It seems that the PythonVirtualEnv operator class expects mandatory 
arguement for output file directory containing 'script.out'. This behaviour is 
not happening in PythonOperator but we have to use the Virtual env operator to 
pass specific python requirements also. What needs to be passed here - 
https://github.com/apache/airflow/blob/main/airflow/operators/python.py#L426
   
   
   ### How to reproduce
   
   Create DAG which calls Python script using PythonVirtualEnv operator. DAG 
fails expecting 'script.out' file to be present in directory.
   
   ### Operating System
   
   Debian 11 Bullseye
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### 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-unsubscr...@airflow.apache.org.apache.org

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

Reply via email to