rawwar commented on code in PR #44051:
URL: https://github.com/apache/airflow/pull/44051#discussion_r1847183374


##########
airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -322,7 +333,85 @@ def get_task_instances(
         session,
     )
 
-    task_instances = session.scalars(task_instance_select).all()
+    task_instances = session.scalars(task_instance_select)
+
+    return TaskInstanceCollectionResponse(
+        task_instances=[
+            TaskInstanceResponse.model_validate(task_instance, 
from_attributes=True)
+            for task_instance in task_instances
+        ],
+        total_entries=total_entries,
+    )
+
+
+@task_instances_router.post(
+    "/list",

Review Comment:
   I just tested this
   
   ```
   (Pdb) res2 = 
test_client.post("/public/dags/invalid/dagRuns/invalid/taskInstances/list",json=payload)
   [2024-11-19T01:31:35.756+0530] {_client.py:1026} INFO - HTTP Request: POST 
http://testserver/public/dags/invalid/dagRuns/invalid/taskInstances/list 
"HTTP/1.1 200 OK"
   (Pdb) res2.json()
   {'task_instances': [{'id': '019340dd-0cd7-7a08-89b0-376b507b375e', 
'task_id': 'print_the_context', 'dag_id': 'example_python_operator', 
'dag_run_id': 'TEST_DAG_RUN_ID', 'map_index': -1, 'logical_date': 
'2020-01-01T00:00:00Z', 'start_date': '2020-01-02T00:00:00Z', 'end_date': 
'2020-01-03T00:00:00Z', 'duration': 10000.0, 'state': 'running', 'try_number': 
0, 'max_tries': 0, 'task_display_name': 'print_the_context', 'hostname': '', 
'unixname': 'kalyan', 'pool': 'default_pool', 'pool_slots': 1, 'queue': 
'test_queue_1', 'priority_weight': 9, 'operator': 'PythonOperator', 
'queued_when': None, 'pid': 100, 'executor': None, 'executor_config': '{}', 
'note': 'placeholder-note', 'rendered_map_index': None, 'rendered_fields': {}, 
'trigger': None, 'triggerer_job': None}, {'id': 
'019340dd-0cd8-75e5-b78c-b53d99943d86', 'task_id': 'log_sql_query', 'dag_id': 
'example_python_operator', 'dag_run_id': 'TEST_DAG_RUN_ID', 'map_index': -1, 
'logical_date': '2020-01-01T00:00:00Z', 'start_date': '2020-01-02
 T00:00:00Z', 'end_date': '2020-01-03T00:00:00Z', 'duration': 10000.0, 'state': 
'running', 'try_number': 0, 'max_tries': 0, 'task_display_name': 
'log_sql_query', 'hostname': '', 'unixname': 'kalyan', 'pool': 'default_pool', 
'pool_slots': 1, 'queue': 'test_queue_2', 'priority_weight': 7, 'operator': 
'PythonOperator', 'queued_when': None, 'pid': 100, 'executor': None, 
'executor_config': '{}', 'note': 'placeholder-note', 'rendered_map_index': 
None, 'rendered_fields': {}, 'trigger': None, 'triggerer_job': None}], 
'total_entries': 2}
   ```



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