You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/03/03 14:34:00 UTC

[GitHub] [airflow] ashb commented on a change in pull request #21965: WIP Task instance endpoint

ashb commented on a change in pull request #21965:
URL: https://github.com/apache/airflow/pull/21965#discussion_r818715328



##########
File path: airflow/api_connexion/endpoints/task_instance_endpoint.py
##########
@@ -93,6 +93,54 @@ def get_task_instance(
     return task_instance_schema.dump(task_instance)
 
 
+@security.requires_access(
+    [
+        (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
+        (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN),
+        (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
+    ],
+)
+@provide_session
+def get_mapped_task_instance(
+    *,
+    dag_id: str,
+    dag_run_id: str,
+    task_id: str,
+    map_index: int,
+    session: Session = NEW_SESSION,
+) -> APIResponse:
+    """Get task instance"""
+    query = (
+        session.query(TI)
+        .filter(
+            TI.dag_id == dag_id, DR.run_id == dag_run_id, TI.task_id == task_id, TI.map_index == map_index
+        )
+        .join(TI.dag_run)
+        .outerjoin(
+            SlaMiss,
+            and_(
+                SlaMiss.dag_id == TI.dag_id,
+                SlaMiss.execution_date == DR.execution_date,
+                SlaMiss.task_id == TI.task_id,
+            ),

Review comment:
       TODO/note to future us: SlaMisss is going to need to be migrated to (dag_id,run_id,task_id,map_index) as it's PK soon




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org