Chais commented on issue #55225:
URL: https://github.com/apache/airflow/issues/55225#issuecomment-5907674742

   Commenting because I see this misbehaviour in 3.3.0. In fact it looks like 
short circuiting doesn't work as soon as mapped tasks are involved.  
   Minimal example:
   ```py
   from datetime import datetime
   from random import random, sample
   from string import ascii_letters
   from typing import List
   from zoneinfo import ZoneInfo
   
   from airflow.sdk import dag, task, task_group
   
   
   @task.short_circuit()
   def no() -> bool:
       return False
   
   
   @task.short_circuit()
   def fifty_fifty() -> bool:
       return random() > 0.5
   
   
   @task.python()
   def printstr(value: str) -> None:
       print(value)
   
   
   @task.python()
   def get_rand_strs(s: int, k: int) -> List[str]:
       return ["".join(sample(ascii_letters, k)) for _ in range(s)]
   
   
   @dag(
       "playground",
       description="Try random things",
       schedule=None,
       start_date=datetime(2024, 11, 1, 0, 0, 0, 0, ZoneInfo("Europe/Berlin")),
       catchup=False,
       dag_display_name="Playground",
   )
   def playground():
       @task_group()
       def group_1(somestr: str):
           (
               fifty_fifty()
               >> printstr(somestr)  # Should be skipped about half the time, 
but isn't
           )
   
       @task_group()
       def group_2(somestr: str):
           printstr(f"{somestr} again")  # Should also be skipped about half 
the time, isn't either
   
       strings = get_rand_strs(20, 10)
       group_1.expand(somestr=strings) >> group_2.expand(somestr=strings)
       no() >> printstr("Should be skipped and is.")
   
   
   playground()
   ```


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