jhtimmins commented on a change in pull request #9597:
URL: https://github.com/apache/airflow/pull/9597#discussion_r451266925



##########
File path: airflow/api_connexion/endpoints/task_instance_endpoint.py
##########
@@ -14,23 +14,110 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+from typing import Any, List, Optional, Tuple
 
-# TODO(mik-laj): We have to implement it.
-#     Do you want to help? Please look at: 
https://github.com/apache/airflow/issues/8132
+from sqlalchemy import and_, func, or_
 
+from airflow.api_connexion.exceptions import NotFound
+from airflow.api_connexion.parameters import format_datetime, format_parameters
+from airflow.api_connexion.schemas.task_instance_schema import (
+    TaskInstanceCollection, task_instance_collection_schema, 
task_instance_schema,
+)
+from airflow.models.dagrun import DagRun as DR
+from airflow.models.taskinstance import TaskInstance as TI
+from airflow.utils.session import provide_session
+
+
+@provide_session
+def get_task_instance(dag_id: str, dag_run_id: str, task_id: str, 
session=None):
+    query = (
+        session.query(TI)
+        .filter(TI.dag_id == dag_id)
+        .join(DR, and_(TI.dag_id == DR.dag_id, TI.execution_date == 
DR.execution_date))
+        .filter(DR.run_id == dag_run_id)
+        .filter(TI.task_id == task_id)
+    )
+
+    task_instance = query.one_or_none()
+
+    if task_instance is None:
+        raise NotFound("Task instance not found")
+
+    return task_instance_schema.dump(task_instance)
 
-def get_task_instance():
-    """
-    Get a task instance
-    """
-    raise NotImplementedError("Not implemented yet.")
 
+def _apply_array_filter(query, key, values):

Review comment:
       Mmmm actually nevermind. I think it makes sense.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to