GayathriSrividya commented on PR #67867:
URL: https://github.com/apache/airflow/pull/67867#issuecomment-4668201324

   > > I do not have before/after UI screenshots yet from Breeze runtime in 
this environment. I can add them as soon as I complete a full local UI run
   > 
   > Sure, please post the screenshots when you do
   
   **Reproduction script:**
   
   ```python
   from __future__ import annotations
   from datetime import datetime
   from airflow.sdk import DAG, task
   from airflow.sdk.bases.sensor import PokeReturnValue
   
   with DAG(
       dag_id="sensor_reschedule_map_index_demo",
       start_date=datetime(2025, 1, 1),
       schedule=None,
       catchup=False,
   ):
       @task
       def fan_out() -> list[dict]:
           return [{"id": "alpha"}, {"id": "beta"}, {"id": "gamma"}]
   
       @task.sensor(
           poke_interval=10,
           timeout=600,
           mode="reschedule",
           map_index_template="{{ map_index_template }}",
       )
       def poll(item: dict) -> PokeReturnValue:
           from airflow.sdk import get_current_context
   
           ctx = get_current_context()
           ctx["map_index_template"] = f"poll_{item['id']}"
           return PokeReturnValue(is_done=False)
   
       poll.expand(item=fan_out())
   ```
   
   **What I did to reproduce:**
   
   I ran two Airflow 3.1.2 instances locally at the same time: one without the 
fix on `localhost:8080`, and one with the fix on `localhost:8082`. I triggered 
the same DAG on both and opened the Task Instances page side by side.
   
   **Before — `localhost:8080`**
   
   While the sensors are waiting to re-poke, the Map Index column shows `0`, 
`1`, `2` instead of the rendered names.
   
   **After — `localhost:8082`**
   
   The same task instances show `poll_alpha`, `poll_beta`, and `poll_gamma` in 
the Map Index column while they are in `Up For Reschedule`.
   
   **Why this happens:**
   
   When a sensor reschedules itself, Airflow was not saving the rendered map 
index to the database. Other paths already persist it, but the reschedule path 
was missing it. This fix adds that in three places:
   
   * 
[`[TIRescheduleStatePayload](https://github.com/apache/airflow/pull/67867/files#diff-airflow-core-src-airflow-api_fastapi-execution_api-datamodels-taskinstance)`](https://github.com/apache/airflow/pull/67867/files#diff-airflow-core-src-airflow-api_fastapi-execution_api-datamodels-taskinstance)
 — adds the `rendered_map_index` field to the payload model
   * [`task_instances.py` 
route](https://github.com/apache/airflow/pull/67867/files#diff-airflow-core-src-airflow-api_fastapi-execution_api-routes-task_instances)
 — writes the rendered map index to the database
   * 
[`[task_runner.py](https://github.com/apache/airflow/pull/67867/files#diff-task-sdk-src-airflow-sdk-execution_time-task_runner)`](https://github.com/apache/airflow/pull/67867/files#diff-task-sdk-src-airflow-sdk-execution_time-task_runner)
 — renders and passes it in the `RescheduleTask` message
   
   <img width="1600" height="970" alt="airflow-1" 
src="https://github.com/user-attachments/assets/d1cd7d13-a125-4346-a528-d3e6c0708d01";
 />
   <img width="1600" height="978" alt="airflow-2" 
src="https://github.com/user-attachments/assets/5aa9af76-edda-4bc7-93b7-fe14891bef00";
 />
    
    <img width="1600" height="978" alt="airflow-2" 
src="https://github.com/user-attachments/assets/5aa9af76-edda-4bc7-93b7-fe14891bef00";
 />
   <img width="1600" height="970" alt="airflow-1" 
src="https://github.com/user-attachments/assets/d1cd7d13-a125-4346-a528-d3e6c0708d01";
 />
   
   
   


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