pedro-cf opened a new issue, #43355:
URL: https://github.com/apache/airflow/issues/43355

   ### Apache Airflow version
   
   2.10.2
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   When using the `@task.virtualenv` decorator and raising an 
`AirflowSkipException` inside the task, the task is incorrectly marked as 
failed instead of skipped. This behavior differs from regular `@task` decorated 
functions, where raising an `AirflowSkipException` correctly marks the task as 
skipped.
   
   ### What you think should happen instead?
   
   The task should be marked as skipped when the `AirflowSkipException` is 
raised, consistent with the behavior of regular `@task` decorated functions.
   
   
   ### How to reproduce
   
   Run the following DAG:
   
   ```python
   from datetime import datetime
   from airflow.decorators import dag, task
   
   
   @dag(
       dag_id='taskflow_raise_skip_in_venv',
       start_date=datetime(2023, 1, 1),
       schedule=None,
       is_paused_upon_creation=False,
       catchup=False
   )
   def taskflow_raise_skip_in_venv():
   
       @task.virtualenv(
           requirements=["stomp-py==8.1.2", "requests==2.31.0"],
           venv_cache_path="/tmp",
       )
       def potentially_skipped_task():
           from airflow.exceptions import AirflowSkipException
           raise AirflowSkipException("This task should be skipped!")
       
       potentially_skipped_task()
   
   taskflow_raise_skip_in_venv()
   ```
   
   ### Operating System
   
   Ubuntu 22
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   LocalExecutor
   
   ### Anything else?
   
   Error logs:
   
   ```
   1cc17766fc4d
   *** Found local files:
   ***   * 
/opt/airflow/logs/dag_id=taskflow_raise_skip_in_venv/run_id=manual__2024-10-24T15:28:21.408988+00:00/task_id=potentially_skipped_task/attempt=1.log
   [2024-10-24, 15:28:22 UTC] {local_task_job_runner.py:123} ▶ Pre task 
execution logs
   [2024-10-24, 15:28:22 UTC] {python.py:809} INFO - Python virtual environment 
will be cached in /tmp/venv-ab7e4c2f
   [2024-10-24, 15:28:22 UTC] {python.py:823} INFO - Re-using cached Python 
virtual environment in /tmp/venv-ab7e4c2f
   [2024-10-24, 15:28:22 UTC] {process_utils.py:186} INFO - Executing cmd: 
/tmp/venv-ab7e4c2f/bin/python /tmp/venv-callgdxwk2nh/script.py 
/tmp/venv-callgdxwk2nh/script.in /tmp/venv-callgdxwk2nh/script.out 
/tmp/venv-callgdxwk2nh/string_args.txt /tmp/venv-callgdxwk2nh/termination.log
   [2024-10-24, 15:28:22 UTC] {process_utils.py:190} INFO - Output:
   [2024-10-24, 15:28:25 UTC] {process_utils.py:194} INFO - Traceback (most 
recent call last):
   [2024-10-24, 15:28:25 UTC] {process_utils.py:194} INFO -   File 
"/tmp/venv-callgdxwk2nh/script.py", line 47, in <module>
   [2024-10-24, 15:28:25 UTC] {process_utils.py:194} INFO -     res = 
potentially_skipped_task(*arg_dict["args"], **arg_dict["kwargs"])
   [2024-10-24, 15:28:25 UTC] {process_utils.py:194} INFO -           
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   [2024-10-24, 15:28:25 UTC] {process_utils.py:194} INFO -   File 
"/tmp/venv-callgdxwk2nh/script.py", line 20, in potentially_skipped_task
   [2024-10-24, 15:28:25 UTC] {process_utils.py:194} INFO -     raise 
AirflowSkipException("This task should be skipped!")
   [2024-10-24, 15:28:25 UTC] {process_utils.py:194} INFO - 
***.exceptions.AirflowSkipException: This task should be skipped!
   [2024-10-24, 15:28:25 UTC] {taskinstance.py:3310} ERROR - Task failed with 
exception
   ```
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to