Dev-iL commented on code in PR #75381:
URL: https://github.com/apache/airflow/pull/75381#discussion_r4657440519
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_state_store.py:
##########
@@ -47,34 +48,41 @@
)
-def _get_task_scope_for_ti(task_instance_id: UUID, session: Session) ->
TaskScope:
- ti = session.get(TI, task_instance_id)
- if ti is None or ti.working_set is not True:
+async def _get_task_scope_for_ti(task_instance_id: UUID, session:
AsyncSession) -> TaskScope:
+ row = (
+ await session.execute(
+ select(TI.dag_id, TI.run_id, TI.task_id, TI.region_index,
TI.region_id).where(
+ TI.id == task_instance_id, TI.working_set.is_(True)
+ )
+ )
+ ).one_or_none()
+ if row is None:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail={
"reason": "not_found",
"message": f"Task instance {task_instance_id} not found",
},
)
+ dag_id, run_id, task_id, region_index, region_id = row
return TaskScope(
- dag_id=ti.dag_id,
- run_id=ti.run_id,
- task_id=ti.task_id,
- map_index=ti.region_index,
- region_id=ti.region_id,
+ dag_id=dag_id,
+ run_id=run_id,
+ task_id=task_id,
+ map_index=region_index,
Review Comment:
Done
--
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]