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

   ### Description
   
   Taskflow is designed to abstract away a lot of the base Airflow concepts 
like xcom, hence the task return values are converted to xcom automatically. 
Similarly you don't have to explicitly mark a task as failed, you can just 
raise an exception.
   
   However there is one gap in this abstraction, namely when you want to do 
both at once. There is nothing in airflow that prevents a task from pushing an 
xcom and also failing, but taskflow provides no abstraction for this. At 
present you would have to explicitly use `push_xcom` and then `raise`. 
Therefore I suggest a new interface for this, which is a new class called 
something like `AirflowResultException`, which takes a value that will get 
pushed to xcom, but the task will still be failed. For example:
   
   ```python
   class AirflowResultException(AirflowException):
       def __init__(self, value: Any):
           ...
   
   @task
   def my_task(x: bool):
       if x:
           return "foo"  # "foo" is pushed as an xcom, and the task status is 
set to succeeded
       else:
           raise AirflowResultException("bar") # "bar" is pushed as an xcom, 
and the task status is set to failed
   ```
   
   ### Use case/motivation
   
   _No response_
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a 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