brouberol commented on issue #44685:
URL: https://github.com/apache/airflow/issues/44685#issuecomment-2527408486

   I'm trying to reproduce the issue locally, in a breeze environment. 
   
   I've defined the following DAG with mapped tasks:
   
   ```python
   from datetime import datetime
   import time
   from airflow.decorators import task
   from airflow.models.dag import DAG
   
   with DAG(dag_id="example_dynamic_task_mapping", schedule=None, 
start_date=datetime(2022, 3, 4)) as dag:
   
       @task
       def add_one(x: int):
           time.sleep(x)  # to give the DAG time to change status.
           return x + 1
   
       @task
       def sum_it(values):
           total = sum(values)
           print(f"Total was {total}")
   
       added_values = add_one.expand(x=[10, 20, 30])
       sum_it(added_values)
   ```
   
   I'm not seemingly able to reproduce with that setup.
   
   Once I trigger the DAG, I hard refresh the page with the URL set to 
`http://127.0.0.1:28080/dags/example_dynamic_task_mapping/grid`. I do observe 3 
of the 4 `404` responses, mentioning the lack of a `map_index` URL fragment. 
However, the UI does not crash, and correctly loads the task details.
   
   <img width="1495" alt="Screenshot 2024-12-09 at 09 46 14" 
src="https://github.com/user-attachments/assets/0703f460-eefc-4208-942e-5b0407ffb6d5";>
   
   However, as visible on the screenshots, our production DAG is formed of an 
initial task, followed by a mapped task group.
   
   So, to reflect that, I changed the DAG to the following:
   ```python
   from datetime import datetime
   import time
   from airflow.decorators import task, task_group
   from airflow.models.dag import DAG
   
   
   with DAG(dag_id="example_dynamic_task_mapping", schedule=None, 
start_date=datetime(2022, 3, 4)) as dag:
   
       @task
       def expensive_operation():
           time.sleep(60)
           return [1, 2, 3]
   
       @task
       def add_one(x: int):
           time.sleep(x)
           return x + 1
   
       @task
       def add_two(x: int):
           return x + 2
   
       @task
       def sum_it(values):
           total = sum(values)
           print(f"Total was {total}")
   
       @task_group
       def complex_computation(value):
           return add_two(add_one(value))
   
       expensive_operation
       complex_computation.expand(value=expensive_operation())
   ```
   
   I then go to `http://127.0.0.1:28080/dags/example_dynamic_task_mapping/grid` 
and hard refresh the page. While the task group is not being executed, I click 
on the `add_one` task. I'm not seeing any 404 response then, as the map index 
is still set to `-1`.
   <img width="1497" alt="Screenshot 2024-12-09 at 10 34 22" 
src="https://github.com/user-attachments/assets/3d3950ba-f012-45a1-9a3b-5a798776e5fa";>
   
   Once the task group is being executed, I then click on `add_one` again 
(after having hard refreshed the page to  
`http://127.0.0.1:28080/dags/example_dynamic_task_mapping/grid`), and I still 
can't observe any crash.
   
   <img width="1493" alt="Screenshot 2024-12-09 at 10 38 21" 
src="https://github.com/user-attachments/assets/518726d8-64da-40c8-8663-1ce89c33f1bc";>
   
   


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