topherinternational commented on issue #54340:
URL: https://github.com/apache/airflow/issues/54340#issuecomment-3218390675

   My example DAG, on Airflow 3.0.4/Python 3.10.18 run locally on OS X via 
`airflow standalone`:
   
   ```python
   from airflow.exceptions import AirflowSkipException
   from airflow.sdk import DAG, task
   
   dag = DAG(dag_id="skipping_dag")
   
   
   @task
   def start_dag():
       pass
   
   
   @task.branch
   def branch_task_with_implicit_skip() -> str | list[str] | None:
       return []
   
   
   @task
   def branch_task_with_implicit_skip_downstream_1():
       pass
   
   
   @task
   def branch_task_with_implicit_skip_downstream_2():
       pass
   
   
   @task.branch
   def branch_task_with_skip_exception() -> str | None:
       raise AirflowSkipException()
   
   
   @task
   def branch_task_with_skip_exception_downstream_1():
       pass
   
   
   @task
   def branch_task_with_skip_exception_downstream_2():
       pass
   
   
   @task.short_circuit
   def short_circuit_task_returns_falsy() -> bool:
       return False
   
   
   @task
   def short_circuit_task_returns_falsy_downstream():
       pass
   
   
   @task.short_circuit
   def short_circuit_task_raises_skip_exception() -> bool:
       raise AirflowSkipException()
   
   
   @task
   def short_circuit_task_raises_skip_exception_downstream():
       pass
   
   
   with dag:
       # task definitions
       START_DAG = start_dag()
   
       BRANCH_TASK_WITH_IMPLICIT_SKIP = branch_task_with_implicit_skip()
       BRANCH_TASK_WITH_IMPLICIT_SKIP_DOWNSTREAM_1 = 
branch_task_with_implicit_skip_downstream_1()
       BRANCH_TASK_WITH_IMPLICIT_SKIP_DOWNSTREAM_2 = 
branch_task_with_implicit_skip_downstream_2()
   
       BRANCH_TASK_WITH_SKIP_EXCEPTION = branch_task_with_skip_exception()
       BRANCH_TASK_WITH_SKIP_EXCEPTION_DOWNSTREAM_1 = 
branch_task_with_skip_exception_downstream_1()
       BRANCH_TASK_WITH_SKIP_EXCEPTION_DOWNSTREAM_2 = 
branch_task_with_skip_exception_downstream_2()
   
       SHORT_CIRCUIT_TASK_RETURNS_FALSY = short_circuit_task_returns_falsy()
       SHORT_CIRCUIT_TASK_RETURNS_FALSY_DOWNSTREAM = 
short_circuit_task_returns_falsy_downstream()
   
       SHORT_CIRCUIT_TASK_RAISES_SKIP_EXCEPTION = 
short_circuit_task_raises_skip_exception()
       SHORT_CIRCUIT_TASK_RAISES_SKIP_EXCEPTION_DOWNSTREAM = 
short_circuit_task_raises_skip_exception_downstream()
   
       # task relationships
       START_DAG >> [BRANCH_TASK_WITH_IMPLICIT_SKIP, 
BRANCH_TASK_WITH_SKIP_EXCEPTION, SHORT_CIRCUIT_TASK_RETURNS_FALSY,
                     SHORT_CIRCUIT_TASK_RAISES_SKIP_EXCEPTION]
   
       BRANCH_TASK_WITH_IMPLICIT_SKIP >> 
[BRANCH_TASK_WITH_IMPLICIT_SKIP_DOWNSTREAM_1,
                                          
BRANCH_TASK_WITH_IMPLICIT_SKIP_DOWNSTREAM_2]
   
       BRANCH_TASK_WITH_SKIP_EXCEPTION >> 
[BRANCH_TASK_WITH_SKIP_EXCEPTION_DOWNSTREAM_1,
                                           
BRANCH_TASK_WITH_SKIP_EXCEPTION_DOWNSTREAM_2]
   
       SHORT_CIRCUIT_TASK_RETURNS_FALSY >> 
SHORT_CIRCUIT_TASK_RETURNS_FALSY_DOWNSTREAM
   
       SHORT_CIRCUIT_TASK_RAISES_SKIP_EXCEPTION >> 
SHORT_CIRCUIT_TASK_RAISES_SKIP_EXCEPTION_DOWNSTREAM
   
   ```
   
   Here is the graph of a run of this DAG, notice how the branch and 
short-circuit tasks show as either green or pink depending on whether they 
return a falsy value or raise a skip exception:
   
   <img width="1104" height="599" alt="Image" 
src="https://github.com/user-attachments/assets/90d90944-2b43-4fd2-9b2a-7939e444c0df";
 />


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