amoghrajesh commented on code in PR #49818:
URL: https://github.com/apache/airflow/pull/49818#discussion_r2062935658
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -615,7 +619,11 @@ def get_task_instance_count(
group_tasks = _get_group_tasks(dag_id, task_group_id, session,
logical_dates, run_ids)
# Get unique (task_id, map_index) pairs
- task_map_pairs = [(ti.task_id, ti.map_index) for ti in group_tasks]
+ if map_index is None:
+ task_map_pairs = [(ti.task_id, ti.map_index) for ti in group_tasks]
+ else:
+ task_map_pairs = [(ti.task_id, ti.map_index) for ti in group_tasks
if ti.map_index == map_index]
Review Comment:
```suggestion
task_map_pairs = [(ti.task_id, ti.map_index) for ti in group_tasks]
if map_index is not None:
task_map_pairs = [(ti.task_id, ti.map_index) for ti in
group_tasks if ti.map_index == map_index]
```
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -664,12 +673,24 @@ def get_task_instance_states(
results = session.scalars(query).all()
- [run_id_task_state_map[task.run_id].update({task.task_id: task.state}) for
task in results]
-
if task_group_id:
group_tasks = _get_group_tasks(dag_id, task_group_id, session,
logical_dates, run_ids)
- [run_id_task_state_map[task.run_id].update({task.task_id: task.state})
for task in group_tasks]
+ if task_ids:
+ results = results + group_tasks
+ else:
+ results = group_tasks
Review Comment:
```suggestion
results = results + group_tasks if results else group_tasks
```
##########
task-sdk/src/airflow/sdk/api/client.py:
##########
@@ -245,6 +248,7 @@ def get_task_states(
"""Get task states given criteria."""
params = {
"dag_id": dag_id,
+ "map_index": map_index,
Review Comment:
Add a check like this:
```
if map_index is not None and map_index >= 0:
params.update({"map_index": map_index})
```
##########
task-sdk/src/airflow/sdk/api/client.py:
##########
@@ -221,6 +222,7 @@ def get_count(
"""Get count of task instances matching the given criteria."""
params = {
"dag_id": dag_id,
+ "map_index": map_index,
Review Comment:
Same here as below
--
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]