atul-astronomer opened a new issue, #55250:
URL: https://github.com/apache/airflow/issues/55250

   ### Apache Airflow version
   
   main (development)
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   
https://github.com/user-attachments/assets/579f4248-b39f-45b9-ae6d-041040708139
   
   ### What you think should happen instead?
   
   _No response_
   
   ### How to reproduce
   
   Run the below dag and try expanding and collapsing task groups:
   
   ```python
   from airflow.sdk import DAG
   from airflow.decorators import task
   from airflow.providers.standard.operators.empty import EmptyOperator
   from airflow.utils.task_group import TaskGroup
   from datetime import datetime
   from dataclasses import dataclass
   from dataclasses_json import dataclass_json
   from random import seed, randint
   
   @dataclass_json
   @dataclass
   class Payload:
   
       seed: int
       a: str
       b: str
       c: str
       d: str
   
       def make(i):
           return Payload(
               seed=i, a=str(i) * 5, b=str(i) * 10, c=str(i) * 15, d=str(i) * 20
           )
   
       def transform(self):
           self.a = str(int(int(self.a) / 5))
           self.b = str(int(int(self.a) / 10))
           self.c = str(int(int(self.a) / 15))
           self.d = str(int(int(self.a) / 20))
   
   
   @task
   def mk_payloads(i):
       return [Payload.make(j).to_dict() for j in range(1, i)]
   
   
   @task
   def transform(_payload):
       payload = Payload.from_dict(_payload)
       payload.transform()
       return payload.to_dict()
   
   
   @task
   def check_transformed(_payload):
       payload: Payload = Payload.from_dict(_payload)
       orig = Payload.make(payload.seed)
       orig.transform()
   
       # same transformation made to same data
       # results should be same, otherwise something got lost along the way
       assert orig == payload
   
   
   minmax_map_indices_per_lane = (5, 60)
   lanes = 10
   
   
   with DAG(
       dag_id="many_expand", schedule=None, start_date=datetime(1970, 1, 1), 
catchup=False,tags=["taskmap"]
   ) as dag:
   
       seed(42)  # be deterministic
   
       for i in range(lanes):
           with TaskGroup(group_id=f"lane{i+1}"):
               min_map, max_map = minmax_map_indices_per_lane
               mapped = randint(min_map, max_map)
               check_transformed.expand(
                   _payload=transform.expand(_payload=mk_payloads(mapped))
               )
   
   ``` 
   
   ### Operating System
   
   Linux
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Other
   
   ### 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: [email protected]

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

Reply via email to