ephraimbuddy commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443754097



##########
File path: airflow/api_connexion/endpoints/extra_link_endpoint.py
##########
@@ -18,9 +18,41 @@
 # TODO(mik-laj): We have to implement it.
 #     Do you want to help? Please look at: 
https://github.com/apache/airflow/issues/8140
 
+from flask import current_app
 
-def get_extra_links():
+from airflow import DAG
+from airflow.api_connexion.exceptions import NotFound
+from airflow.exceptions import TaskNotFound
+from airflow.models.dagbag import DagBag
+from airflow.models.dagrun import DagRun as DR
+from airflow.utils.session import provide_session
+
+
+@provide_session
+def get_extra_links(dag_id: str, dag_run_id: str, task_id: str, session):
     """
     Get extra links for task instance
     """
-    raise NotImplementedError("Not implemented yet.")
+    dagbag: DagBag = current_app.dag_bag
+    dag: DAG = dagbag.get_dag(dag_id)
+    if not dag:
+        raise NotFound("DAG not found")
+
+    try:
+        task = dag.get_task(task_id)
+    except TaskNotFound:
+        raise NotFound("Task not found")
+
+    execution_date = (
+        session.query(DR.execution_date).filter(DR.dag_id == 
dag_id).filter(DR.run_id == dag_run_id).scalar()

Review comment:
       ```suggestion
           session.query(DR.execution_date).filter(DR.dag_id == dag_id, 
DR.run_id == dag_run_id).one()
   ```
   I'm wrong about using `one`. `scalar()` or `first()` is better




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to