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 2020/06/22 14:27:08 UTC

[GitHub] [airflow] mik-laj opened a new pull request #9475: Add extra links endpoint

mik-laj opened a new pull request #9475:
URL: https://github.com/apache/airflow/pull/9475


   Close: https://github.com/apache/airflow/issues/8140
   
   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [X] Description above provides context of the change
   - [X] Unit tests coverage for changes (not needed for documentation changes)
   - [X] Target Github ISSUE in description if exists
   - [X] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [X] Relevant documentation is updated including usage instructions.
   - [X] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   


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



[GitHub] [airflow] ephraimbuddy commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
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()
   ```
   `.scalar()` implicitly calls `.one()` and `one` is most suitable for Rest Api that wants to raise 404 according to sqlalchemy tutorial here https://docs.sqlalchemy.org/en/13/orm/tutorial.html#returning-lists-and-scalars




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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444555490



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

Review comment:
       I removed this note. 




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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444746029



##########
File path: airflow/api_connexion/endpoints/extra_link_endpoint.py
##########
@@ -15,12 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# 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
 
+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
 
-def get_extra_links():
+
+@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", detail=f'DAG with ID = "{dag_id}" not found')
+
+    try:
+        task = dag.get_task(task_id)
+    except TaskNotFound:
+        raise NotFound("Task not found", detail=f'Task with ID = "{task_id}" not found')
+
+    execution_date = (
+        session.query(DR.execution_date).filter(DR.dag_id == dag_id).filter(DR.run_id == dag_run_id).scalar()
+    )
+    if not execution_date:
+        raise NotFound("DAG Run not found", detail=f'DAG Run with ID = "{dag_run_id}" not found')

Review comment:
       Yes. The execution_date attribute is an attribute of the DAG Run object. I didn't fetch the full object because I don't need it. I only need one field.




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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444547278



##########
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")

Review comment:
       I think we should change the title too. Otherwise, it will have a default value - "Object not found".  After that it's a good idea.




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



[GitHub] [airflow] mik-laj merged pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj merged pull request #9475:
URL: https://github.com/apache/airflow/pull/9475


   


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



[GitHub] [airflow] ephraimbuddy commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443764076



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,198 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager
 
+from airflow import DAG
+from airflow.models.baseoperator import BaseOperatorLink
+from airflow.models.dagrun import DagRun
+from airflow.models.xcom import XCom
+from airflow.plugins_manager import AirflowPlugin
+from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
+from airflow.utils.dates import days_ago
+from airflow.utils.session import provide_session
+from airflow.utils.timezone import datetime
+from airflow.utils.types import DagRunType
 from airflow.www import app
+from tests.test_utils.db import clear_db_runs, clear_db_xcom
 
 
 class TestGetExtraLinks(unittest.TestCase):
     @classmethod
     def setUpClass(cls) -> None:
         super().setUpClass()
-        cls.app = app.create_app(testing=True)  # type:ignore
+        with mock.patch.dict('os.environ', SKIP_DAGS_PARSING='True'):
+            cls.app = app.create_app(testing=True)  # type:ignore
+
+    @provide_session
+    def setUp(self, session) -> None:
+        self.now = datetime(2020, 1, 1)
+
+        clear_db_runs()
+        clear_db_xcom()
+
+        self.dag = self._create_dag()
+        self.app.dag_bag.dags = {self.dag.dag_id: self.dag}  # type: ignore  # pylint: disable=no-member
+        self.app.dag_bag.sync_to_db()   # type: ignore  # pylint: disable=no-member
+
+        dr = DagRun(
+            dag_id=self.dag.dag_id,
+            run_id="TEST_DAG_RUN_ID",
+            execution_date=self.now,
+            run_type=DagRunType.MANUAL.value,
+        )
+        session.add(dr)
+        session.commit()
 
-    def setUp(self) -> None:
         self.client = self.app.test_client()  # type:ignore
 
-    @pytest.mark.skip(reason="Not implemented yet")
+    def tearDown(self) -> None:
+        super().tearDown()
+        clear_db_runs()
+        clear_db_xcom()
+
+    @staticmethod
+    def _create_dag():
+        with DAG(dag_id="TEST_DAG_ID", default_args=dict(start_date=days_ago(2),)) as dag:
+            BigQueryExecuteQueryOperator(task_id="TEST_SINGLE_QUERY", sql="SELECT 1")
+            BigQueryExecuteQueryOperator(task_id="TEST_MULTIPLE_QUERY", sql=["SELECT 1", "SELECT 2"])

Review comment:
       ```suggestion
               BigQueryInsertJobOperator(task_id="TEST_SINGLE_QUERY", sql="SELECT 1")
               BigQueryInsertJobOperator(task_id="TEST_MULTIPLE_QUERY", sql=["SELECT 1", "SELECT 2"])
   ```
   This operator `BigQueryExecuteQueryOperator` is deprecated




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



[GitHub] [airflow] turbaszek commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444742601



##########
File path: airflow/api_connexion/endpoints/extra_link_endpoint.py
##########
@@ -15,12 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# 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
 
+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
 
-def get_extra_links():
+
+@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", detail=f'DAG with ID = "{dag_id}" not found')

Review comment:
       Should we create `DagNotFound` and `TaskNotFound` exceptions to unify this between endpoints? 




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



[GitHub] [airflow] ephraimbuddy commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443745818



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

Review comment:
       ```suggestion
   
   ```




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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444546422



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,196 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
-
+from airflow import DAG
+from airflow.models import XCom, BaseOperatorLink
+from airflow.models.dagrun import DagRun
+from airflow.plugins_manager import AirflowPlugin
+from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
+from airflow.utils.dates import days_ago
+from airflow.utils.session import provide_session
+from airflow.utils.timezone import datetime
+from airflow.utils.types import DagRunType
 from airflow.www import app
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager
+from tests.test_utils.db import clear_db_runs, clear_db_xcom
 
 
 class TestGetExtraLinks(unittest.TestCase):
     @classmethod
     def setUpClass(cls) -> None:
         super().setUpClass()
-        cls.app = app.create_app(testing=True)  # type:ignore
+        with mock.patch.dict('os.environ', SKIP_DAGS_PARSING='True'):
+            cls.app = app.create_app(testing=True)  # type:ignore
+
+    @provide_session
+    def setUp(self, session) -> None:
+        self.now = datetime(2020, 1, 1)
+
+        clear_db_runs()
+        clear_db_xcom()
+
+        self.dag = self._create_dag()
+        self.app.dag_bag.dags = {self.dag.dag_id: self.dag}  # pylint: disable=no-member
+        self.app.dag_bag.sync_to_db()  # pylint: disable=no-member
+
+        dr = DagRun(
+            dag_id=self.dag.dag_id,
+            run_id="TEST_DAG_RUN_ID",
+            execution_date=self.now,
+            run_type=DagRunType.MANUAL.value,
+        )
+        session.add(dr)
+        session.commit()
 
-    def setUp(self) -> None:
         self.client = self.app.test_client()  # type:ignore
 
-    @pytest.mark.skip(reason="Not implemented yet")
+    def tearDown(self) -> None:
+        super().tearDown()
+        clear_db_runs()
+        clear_db_xcom()
+
+    @staticmethod
+    def _create_dag():
+        with DAG(dag_id="TEST_DAG_ID", default_args=dict(start_date=days_ago(2),)) as dag:
+            BigQueryExecuteQueryOperator(task_id="TEST_SINGLE_QUERY", sql="SELECT 1")
+            BigQueryExecuteQueryOperator(task_id="TEST_MULTIPLE_QUERY", sql=["SELECT 1", "SELECT 2"])
+        return dag
+
+    @parameterized.expand(
+        [
+            (
+                "/api/v1/dags/INVALID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links",
+                'DAG not found'
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/INVALID/taskInstances/TEST_SINGLE_QUERY/links",
+                "DAG Run not found"
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/INVALID/links",
+                "Task not found"
+            ),
+        ]
+    )
+    def test_should_response_404_on_invalid_task_id(self, url, expected_title):
+        response = self.client.get(url)
+
+        self.assertEqual(404, response.status_code)
+        self.assertEqual({'detail': None, 'status': 404, 'title': expected_title, 'type': 'about:blank'}, response.json)
+
+    @mock_plugin_manager(plugins=[])
     def test_should_response_200(self):
+        XCom.set(
+            key="job_id",
+            value="TEST_JOB_ID",
+            execution_date=self.now,
+            task_id="TEST_SINGLE_QUERY",
+            dag_id=self.dag.dag_id,
+        )
+        response = self.client.get(
+            "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links"
+        )
+
+        self.assertEqual(200, response.status_code, response.data)
+        self.assertEqual(
+            {
+                "BigQuery Console": "https://console.cloud.google.com/bigquery?j=TEST_JOB_ID",
+            },
+            response.json,
+        )
+
+    @mock_plugin_manager(plugins=[])
+    def test_should_response_200_missing_xcom(self):
+        response = self.client.get(
+            "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links"
+        )
+
+        self.assertEqual(200, response.status_code, response.data)
+        self.assertEqual(
+            {
+                "BigQuery Console": None,
+            },
+            response.json,
+        )
+
+    @mock_plugin_manager(plugins=[])
+    def test_should_response_200_multiple_links(self):
+        XCom.set(
+            key="job_id",
+            value=["TEST_JOB_ID_1", "TEST_JOB_ID_2"],
+            execution_date=self.now,
+            task_id="TEST_MULTIPLE_QUERY",
+            dag_id=self.dag.dag_id,
+        )
+        response = self.client.get(
+            "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_MULTIPLE_QUERY/links"
+        )
+
+        self.assertEqual(200, response.status_code, response.data)
+        self.assertEqual(
+            {
+                "BigQuery Console #1": "https://console.cloud.google.com/bigquery?j=TEST_JOB_ID_1",
+                "BigQuery Console #2": "https://console.cloud.google.com/bigquery?j=TEST_JOB_ID_2",
+            },
+            response.json,
+        )
+
+    @mock_plugin_manager(plugins=[])
+    def test_should_response_200_multiple_links_missing_xcom(self):
         response = self.client.get(
-            "/dags/TEST_DG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_TASK_ID/links"
+            "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_MULTIPLE_QUERY/links"
         )
-        assert response.status_code == 200
+
+        self.assertEqual(200, response.status_code, response.data)
+        self.assertEqual(
+            {
+                "BigQuery Console #1": None,
+                "BigQuery Console #2": None,
+            },
+            response.json,
+        )
+
+    def test_should_response_200_support_plugins(self):
+        class GoogleLink(BaseOperatorLink):
+            name = "Google"
+
+            def get_link(self, operator, dttm):
+                return "https://www.google.com"
+
+        class S3LogLink(BaseOperatorLink):
+            name = 'S3'
+            operators = [BigQueryExecuteQueryOperator]
+
+            def get_link(self, operator, dttm):
+                return 'https://s3.amazonaws.com/airflow-logs/{dag_id}/{task_id}/{execution_date}'.format(
+                    dag_id=operator.dag_id,
+                    task_id=operator.task_id,
+                    execution_date=quote(dttm.isoformat()),

Review comment:
       ```2020-01-01T00:00:00+00:00```
   It doesn't make a difference here because we don't have spaces.




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



[GitHub] [airflow] turbaszek commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444743676



##########
File path: airflow/api_connexion/endpoints/extra_link_endpoint.py
##########
@@ -15,12 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# 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
 
+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
 
-def get_extra_links():
+
+@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", detail=f'DAG with ID = "{dag_id}" not found')
+
+    try:
+        task = dag.get_task(task_id)
+    except TaskNotFound:
+        raise NotFound("Task not found", detail=f'Task with ID = "{task_id}" not found')
+
+    execution_date = (
+        session.query(DR.execution_date).filter(DR.dag_id == dag_id).filter(DR.run_id == dag_run_id).scalar()
+    )
+    if not execution_date:
+        raise NotFound("DAG Run not found", detail=f'DAG Run with ID = "{dag_run_id}" not found')
+
+    all_extra_link_pairs = (
+        (link_name, task.get_extra_links(execution_date, link_name)) for link_name in task.extra_links
+    )

Review comment:
       ```suggestion
           (link_name, task.get_extra_links(execution_date, link_name)) 
           for link_name in task.extra_links
       )
   ```




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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444747246



##########
File path: airflow/api_connexion/endpoints/extra_link_endpoint.py
##########
@@ -15,12 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# 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
 
+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
 
-def get_extra_links():
+
+@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", detail=f'DAG with ID = "{dag_id}" not found')

Review comment:
       In the future, this is possible when we focus on improving exceptions to add additional information (type field).




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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443768531



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,198 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager
 
+from airflow import DAG
+from airflow.models.baseoperator import BaseOperatorLink
+from airflow.models.dagrun import DagRun
+from airflow.models.xcom import XCom
+from airflow.plugins_manager import AirflowPlugin
+from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
+from airflow.utils.dates import days_ago
+from airflow.utils.session import provide_session
+from airflow.utils.timezone import datetime
+from airflow.utils.types import DagRunType
 from airflow.www import app
+from tests.test_utils.db import clear_db_runs, clear_db_xcom
 
 
 class TestGetExtraLinks(unittest.TestCase):
     @classmethod
     def setUpClass(cls) -> None:
         super().setUpClass()
-        cls.app = app.create_app(testing=True)  # type:ignore
+        with mock.patch.dict('os.environ', SKIP_DAGS_PARSING='True'):
+            cls.app = app.create_app(testing=True)  # type:ignore
+
+    @provide_session
+    def setUp(self, session) -> None:
+        self.now = datetime(2020, 1, 1)
+
+        clear_db_runs()
+        clear_db_xcom()
+
+        self.dag = self._create_dag()
+        self.app.dag_bag.dags = {self.dag.dag_id: self.dag}  # type: ignore  # pylint: disable=no-member
+        self.app.dag_bag.sync_to_db()   # type: ignore  # pylint: disable=no-member
+
+        dr = DagRun(
+            dag_id=self.dag.dag_id,
+            run_id="TEST_DAG_RUN_ID",
+            execution_date=self.now,
+            run_type=DagRunType.MANUAL.value,
+        )
+        session.add(dr)
+        session.commit()
 
-    def setUp(self) -> None:
         self.client = self.app.test_client()  # type:ignore
 
-    @pytest.mark.skip(reason="Not implemented yet")
+    def tearDown(self) -> None:
+        super().tearDown()
+        clear_db_runs()
+        clear_db_xcom()
+
+    @staticmethod
+    def _create_dag():
+        with DAG(dag_id="TEST_DAG_ID", default_args=dict(start_date=days_ago(2),)) as dag:
+            BigQueryExecuteQueryOperator(task_id="TEST_SINGLE_QUERY", sql="SELECT 1")
+            BigQueryExecuteQueryOperator(task_id="TEST_MULTIPLE_QUERY", sql=["SELECT 1", "SELECT 2"])
+        return dag
+
+    @parameterized.expand(
+        [
+            (
+                "/api/v1/dags/INVALID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links",
+                'DAG not found'
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/INVALID/taskInstances/TEST_SINGLE_QUERY/links",
+                "DAG Run not found"
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/INVALID/links",
+                "Task not found"
+            ),
+        ]
+    )
+    def test_should_response_404_on_invalid_task_id(self, url, expected_title):
+        response = self.client.get(url)
+
+        self.assertEqual(404, response.status_code)
+        self.assertEqual({'detail': None, 'status': 404, 'title': expected_title, 'type': 'about:blank'}, response.json)
+
+    @mock_plugin_manager(plugins=[])
     def test_should_response_200(self):
+        XCom.set(
+            key="job_id",
+            value="TEST_JOB_ID",
+            execution_date=self.now,
+            task_id="TEST_SINGLE_QUERY",
+            dag_id=self.dag.dag_id,
+        )
         response = self.client.get(
-            "/dags/TEST_DG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_TASK_ID/links"
+            "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links"
+        )
+
+        self.assertEqual(200, response.status_code, response.data)

Review comment:
       3 argument is just a message for the developer. It can be in the form of bytes if it is safer and more readable.




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



[GitHub] [airflow] ephraimbuddy commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443754771



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,198 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager
 
+from airflow import DAG
+from airflow.models.baseoperator import BaseOperatorLink
+from airflow.models.dagrun import DagRun
+from airflow.models.xcom import XCom
+from airflow.plugins_manager import AirflowPlugin
+from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
+from airflow.utils.dates import days_ago
+from airflow.utils.session import provide_session
+from airflow.utils.timezone import datetime
+from airflow.utils.types import DagRunType
 from airflow.www import app
+from tests.test_utils.db import clear_db_runs, clear_db_xcom
 
 
 class TestGetExtraLinks(unittest.TestCase):
     @classmethod
     def setUpClass(cls) -> None:
         super().setUpClass()
-        cls.app = app.create_app(testing=True)  # type:ignore
+        with mock.patch.dict('os.environ', SKIP_DAGS_PARSING='True'):
+            cls.app = app.create_app(testing=True)  # type:ignore
+
+    @provide_session
+    def setUp(self, session) -> None:
+        self.now = datetime(2020, 1, 1)

Review comment:
       ```suggestion
           self.default_time = datetime(2020, 1, 1)
   ```
   I suggest we use default_time instead of now




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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444545132



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,198 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager
 
+from airflow import DAG
+from airflow.models.baseoperator import BaseOperatorLink
+from airflow.models.dagrun import DagRun
+from airflow.models.xcom import XCom
+from airflow.plugins_manager import AirflowPlugin
+from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
+from airflow.utils.dates import days_ago
+from airflow.utils.session import provide_session
+from airflow.utils.timezone import datetime
+from airflow.utils.types import DagRunType
 from airflow.www import app
+from tests.test_utils.db import clear_db_runs, clear_db_xcom
 
 
 class TestGetExtraLinks(unittest.TestCase):
     @classmethod
     def setUpClass(cls) -> None:
         super().setUpClass()
-        cls.app = app.create_app(testing=True)  # type:ignore
+        with mock.patch.dict('os.environ', SKIP_DAGS_PARSING='True'):
+            cls.app = app.create_app(testing=True)  # type:ignore
+
+    @provide_session
+    def setUp(self, session) -> None:
+        self.now = datetime(2020, 1, 1)
+
+        clear_db_runs()
+        clear_db_xcom()
+
+        self.dag = self._create_dag()
+        self.app.dag_bag.dags = {self.dag.dag_id: self.dag}  # type: ignore  # pylint: disable=no-member
+        self.app.dag_bag.sync_to_db()   # type: ignore  # pylint: disable=no-member
+
+        dr = DagRun(
+            dag_id=self.dag.dag_id,
+            run_id="TEST_DAG_RUN_ID",
+            execution_date=self.now,
+            run_type=DagRunType.MANUAL.value,
+        )
+        session.add(dr)
+        session.commit()
 
-    def setUp(self) -> None:
         self.client = self.app.test_client()  # type:ignore
 
-    @pytest.mark.skip(reason="Not implemented yet")
+    def tearDown(self) -> None:
+        super().tearDown()
+        clear_db_runs()
+        clear_db_xcom()
+
+    @staticmethod
+    def _create_dag():
+        with DAG(dag_id="TEST_DAG_ID", default_args=dict(start_date=days_ago(2),)) as dag:
+            BigQueryExecuteQueryOperator(task_id="TEST_SINGLE_QUERY", sql="SELECT 1")
+            BigQueryExecuteQueryOperator(task_id="TEST_MULTIPLE_QUERY", sql=["SELECT 1", "SELECT 2"])
+        return dag
+
+    @parameterized.expand(
+        [
+            (
+                "/api/v1/dags/INVALID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links",
+                'DAG not found'
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/INVALID/taskInstances/TEST_SINGLE_QUERY/links",
+                "DAG Run not found"
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/INVALID/links",
+                "Task not found"
+            ),
+        ]
+    )
+    def test_should_response_404_on_invalid_task_id(self, url, expected_title):
+        response = self.client.get(url)

Review comment:
       In many places, we don't use names. We already have one name that allows you to identify a specific test, then the number allows you to specify a specific variant.  Many names will limit the number of tests. What I love in parameterized is the ability to generate many cases in a simple way. It is possible that some cases may overlap, but this may change in the future. 




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



[GitHub] [airflow] ephraimbuddy commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



[GitHub] [airflow] OmairK commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
OmairK commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443740331



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,198 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager
 
+from airflow import DAG
+from airflow.models.baseoperator import BaseOperatorLink
+from airflow.models.dagrun import DagRun
+from airflow.models.xcom import XCom
+from airflow.plugins_manager import AirflowPlugin
+from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
+from airflow.utils.dates import days_ago
+from airflow.utils.session import provide_session
+from airflow.utils.timezone import datetime
+from airflow.utils.types import DagRunType
 from airflow.www import app
+from tests.test_utils.db import clear_db_runs, clear_db_xcom
 
 
 class TestGetExtraLinks(unittest.TestCase):
     @classmethod
     def setUpClass(cls) -> None:
         super().setUpClass()
-        cls.app = app.create_app(testing=True)  # type:ignore
+        with mock.patch.dict('os.environ', SKIP_DAGS_PARSING='True'):
+            cls.app = app.create_app(testing=True)  # type:ignore
+
+    @provide_session
+    def setUp(self, session) -> None:
+        self.now = datetime(2020, 1, 1)
+
+        clear_db_runs()
+        clear_db_xcom()
+
+        self.dag = self._create_dag()
+        self.app.dag_bag.dags = {self.dag.dag_id: self.dag}  # type: ignore  # pylint: disable=no-member
+        self.app.dag_bag.sync_to_db()   # type: ignore  # pylint: disable=no-member
+
+        dr = DagRun(
+            dag_id=self.dag.dag_id,
+            run_id="TEST_DAG_RUN_ID",
+            execution_date=self.now,
+            run_type=DagRunType.MANUAL.value,
+        )
+        session.add(dr)
+        session.commit()
 
-    def setUp(self) -> None:
         self.client = self.app.test_client()  # type:ignore
 
-    @pytest.mark.skip(reason="Not implemented yet")
+    def tearDown(self) -> None:
+        super().tearDown()
+        clear_db_runs()
+        clear_db_xcom()
+
+    @staticmethod
+    def _create_dag():
+        with DAG(dag_id="TEST_DAG_ID", default_args=dict(start_date=days_ago(2),)) as dag:
+            BigQueryExecuteQueryOperator(task_id="TEST_SINGLE_QUERY", sql="SELECT 1")
+            BigQueryExecuteQueryOperator(task_id="TEST_MULTIPLE_QUERY", sql=["SELECT 1", "SELECT 2"])
+        return dag
+
+    @parameterized.expand(
+        [
+            (
+                "/api/v1/dags/INVALID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links",
+                'DAG not found'
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/INVALID/taskInstances/TEST_SINGLE_QUERY/links",
+                "DAG Run not found"
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/INVALID/links",
+                "Task not found"
+            ),
+        ]
+    )
+    def test_should_response_404_on_invalid_task_id(self, url, expected_title):
+        response = self.client.get(url)

Review comment:
       ```suggestion
       @parameterized.expand(
           [
               (
                   "invalid dag_id",
                   "/api/v1/dags/INVALID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links",
                   'DAG not found'
               ),
               (
                   "invalid run_id",
                   "/api/v1/dags/TEST_DAG_ID/dagRuns/INVALID/taskInstances/TEST_SINGLE_QUERY/links",
                   "DAG Run not found"
               ),
               (
                   "invalid task_id",
                   "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/INVALID/links",
                   "Task not found"
               ),
           ]
       )
       def test_should_response_404_on(self, name, url, expected_title):
           del name
           response = self.client.get(url)
   ```
   These tests are dealing with multiple invalid id(s), this is IMO more descriptive, what do you think ?




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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444555388



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,198 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager
 
+from airflow import DAG
+from airflow.models.baseoperator import BaseOperatorLink
+from airflow.models.dagrun import DagRun
+from airflow.models.xcom import XCom
+from airflow.plugins_manager import AirflowPlugin
+from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
+from airflow.utils.dates import days_ago
+from airflow.utils.session import provide_session
+from airflow.utils.timezone import datetime
+from airflow.utils.types import DagRunType
 from airflow.www import app
+from tests.test_utils.db import clear_db_runs, clear_db_xcom
 
 
 class TestGetExtraLinks(unittest.TestCase):
     @classmethod
     def setUpClass(cls) -> None:
         super().setUpClass()
-        cls.app = app.create_app(testing=True)  # type:ignore
+        with mock.patch.dict('os.environ', SKIP_DAGS_PARSING='True'):
+            cls.app = app.create_app(testing=True)  # type:ignore
+
+    @provide_session
+    def setUp(self, session) -> None:
+        self.now = datetime(2020, 1, 1)

Review comment:
       Fixed. Thanks. 




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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444555352



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,198 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager

Review comment:
       Fixed. Thanks. 




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



[GitHub] [airflow] mik-laj commented on pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#issuecomment-648472881


   @turbaszek Can you look at it?


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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444747482



##########
File path: airflow/api_connexion/endpoints/extra_link_endpoint.py
##########
@@ -15,12 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# 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
 
+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
 
-def get_extra_links():
+
+@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", detail=f'DAG with ID = "{dag_id}" not found')
+
+    try:
+        task = dag.get_task(task_id)
+    except TaskNotFound:
+        raise NotFound("Task not found", detail=f'Task with ID = "{task_id}" not found')
+
+    execution_date = (
+        session.query(DR.execution_date).filter(DR.dag_id == dag_id).filter(DR.run_id == dag_run_id).scalar()
+    )
+    if not execution_date:
+        raise NotFound("DAG Run not found", detail=f'DAG Run with ID = "{dag_run_id}" not found')
+
+    all_extra_link_pairs = (
+        (link_name, task.get_extra_links(execution_date, link_name)) for link_name in task.extra_links
+    )

Review comment:
       I use black to automatically format the code.




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



[GitHub] [airflow] mik-laj edited a comment on pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj edited a comment on pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#issuecomment-648472881


   @turbaszek @michalslowikowski00  Can you look at it?


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



[GitHub] [airflow] mik-laj commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443765208



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,198 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager
 
+from airflow import DAG
+from airflow.models.baseoperator import BaseOperatorLink
+from airflow.models.dagrun import DagRun
+from airflow.models.xcom import XCom
+from airflow.plugins_manager import AirflowPlugin
+from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
+from airflow.utils.dates import days_ago
+from airflow.utils.session import provide_session
+from airflow.utils.timezone import datetime
+from airflow.utils.types import DagRunType
 from airflow.www import app
+from tests.test_utils.db import clear_db_runs, clear_db_xcom
 
 
 class TestGetExtraLinks(unittest.TestCase):
     @classmethod
     def setUpClass(cls) -> None:
         super().setUpClass()
-        cls.app = app.create_app(testing=True)  # type:ignore
+        with mock.patch.dict('os.environ', SKIP_DAGS_PARSING='True'):
+            cls.app = app.create_app(testing=True)  # type:ignore
+
+    @provide_session
+    def setUp(self, session) -> None:
+        self.now = datetime(2020, 1, 1)
+
+        clear_db_runs()
+        clear_db_xcom()
+
+        self.dag = self._create_dag()
+        self.app.dag_bag.dags = {self.dag.dag_id: self.dag}  # type: ignore  # pylint: disable=no-member
+        self.app.dag_bag.sync_to_db()   # type: ignore  # pylint: disable=no-member
+
+        dr = DagRun(
+            dag_id=self.dag.dag_id,
+            run_id="TEST_DAG_RUN_ID",
+            execution_date=self.now,
+            run_type=DagRunType.MANUAL.value,
+        )
+        session.add(dr)
+        session.commit()
 
-    def setUp(self) -> None:
         self.client = self.app.test_client()  # type:ignore
 
-    @pytest.mark.skip(reason="Not implemented yet")
+    def tearDown(self) -> None:
+        super().tearDown()
+        clear_db_runs()
+        clear_db_xcom()
+
+    @staticmethod
+    def _create_dag():
+        with DAG(dag_id="TEST_DAG_ID", default_args=dict(start_date=days_ago(2),)) as dag:
+            BigQueryExecuteQueryOperator(task_id="TEST_SINGLE_QUERY", sql="SELECT 1")
+            BigQueryExecuteQueryOperator(task_id="TEST_MULTIPLE_QUERY", sql=["SELECT 1", "SELECT 2"])

Review comment:
       BigQueryInsertJobOperator doesn't have extra links. 




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



[GitHub] [airflow] turbaszek commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444743293



##########
File path: airflow/api_connexion/endpoints/extra_link_endpoint.py
##########
@@ -15,12 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# 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
 
+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
 
-def get_extra_links():
+
+@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", detail=f'DAG with ID = "{dag_id}" not found')
+
+    try:
+        task = dag.get_task(task_id)
+    except TaskNotFound:
+        raise NotFound("Task not found", detail=f'Task with ID = "{task_id}" not found')
+
+    execution_date = (
+        session.query(DR.execution_date).filter(DR.dag_id == dag_id).filter(DR.run_id == dag_run_id).scalar()
+    )
+    if not execution_date:
+        raise NotFound("DAG Run not found", detail=f'DAG Run with ID = "{dag_run_id}" not found')

Review comment:
       I'm not sure if this error is related to `if not execution_date` clause 




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



[GitHub] [airflow] OmairK commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
OmairK commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443731489



##########
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")

Review comment:
       ```suggestion
           raise NotFound(detail=f"DAG with id: '{dag_id}' not found")
   ```
   The errors are a bit more descriptive this way, what do you think?




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



[GitHub] [airflow] ephraimbuddy commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
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).scalar()
   ```
   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:
users@infra.apache.org



[GitHub] [airflow] ephraimbuddy commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443758402



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,198 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager

Review comment:
       ```suggestion
   from tests.test_utils.mock_plugins import mock_plugin_manager
   ```




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



[GitHub] [airflow] OmairK commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
OmairK commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443746796



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,198 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager
 
+from airflow import DAG
+from airflow.models.baseoperator import BaseOperatorLink
+from airflow.models.dagrun import DagRun
+from airflow.models.xcom import XCom
+from airflow.plugins_manager import AirflowPlugin
+from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
+from airflow.utils.dates import days_ago
+from airflow.utils.session import provide_session
+from airflow.utils.timezone import datetime
+from airflow.utils.types import DagRunType
 from airflow.www import app
+from tests.test_utils.db import clear_db_runs, clear_db_xcom
 
 
 class TestGetExtraLinks(unittest.TestCase):
     @classmethod
     def setUpClass(cls) -> None:
         super().setUpClass()
-        cls.app = app.create_app(testing=True)  # type:ignore
+        with mock.patch.dict('os.environ', SKIP_DAGS_PARSING='True'):
+            cls.app = app.create_app(testing=True)  # type:ignore
+
+    @provide_session
+    def setUp(self, session) -> None:
+        self.now = datetime(2020, 1, 1)
+
+        clear_db_runs()
+        clear_db_xcom()
+
+        self.dag = self._create_dag()
+        self.app.dag_bag.dags = {self.dag.dag_id: self.dag}  # type: ignore  # pylint: disable=no-member
+        self.app.dag_bag.sync_to_db()   # type: ignore  # pylint: disable=no-member
+
+        dr = DagRun(
+            dag_id=self.dag.dag_id,
+            run_id="TEST_DAG_RUN_ID",
+            execution_date=self.now,
+            run_type=DagRunType.MANUAL.value,
+        )
+        session.add(dr)
+        session.commit()
 
-    def setUp(self) -> None:
         self.client = self.app.test_client()  # type:ignore
 
-    @pytest.mark.skip(reason="Not implemented yet")
+    def tearDown(self) -> None:
+        super().tearDown()
+        clear_db_runs()
+        clear_db_xcom()
+
+    @staticmethod
+    def _create_dag():
+        with DAG(dag_id="TEST_DAG_ID", default_args=dict(start_date=days_ago(2),)) as dag:
+            BigQueryExecuteQueryOperator(task_id="TEST_SINGLE_QUERY", sql="SELECT 1")
+            BigQueryExecuteQueryOperator(task_id="TEST_MULTIPLE_QUERY", sql=["SELECT 1", "SELECT 2"])
+        return dag
+
+    @parameterized.expand(
+        [
+            (
+                "/api/v1/dags/INVALID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links",
+                'DAG not found'
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/INVALID/taskInstances/TEST_SINGLE_QUERY/links",
+                "DAG Run not found"
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/INVALID/links",
+                "Task not found"
+            ),
+        ]
+    )
+    def test_should_response_404_on_invalid_task_id(self, url, expected_title):
+        response = self.client.get(url)
+
+        self.assertEqual(404, response.status_code)
+        self.assertEqual({'detail': None, 'status': 404, 'title': expected_title, 'type': 'about:blank'}, response.json)
+
+    @mock_plugin_manager(plugins=[])
     def test_should_response_200(self):
+        XCom.set(
+            key="job_id",
+            value="TEST_JOB_ID",
+            execution_date=self.now,
+            task_id="TEST_SINGLE_QUERY",
+            dag_id=self.dag.dag_id,
+        )
         response = self.client.get(
-            "/dags/TEST_DG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_TASK_ID/links"
+            "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links"
+        )
+
+        self.assertEqual(200, response.status_code, response.data)

Review comment:
       ```suggestion
           self.assertEqual(200, response.status_code)
   ```
   I have never used it but I guess response.data returns the response.json in bytes literal? 




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



[GitHub] [airflow] ephraimbuddy commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r443728375



##########
File path: tests/api_connexion/endpoints/test_extra_link_endpoint.py
##########
@@ -15,24 +15,196 @@
 # specific language governing permissions and limitations
 # under the License.
 import unittest
+from unittest import mock
+from urllib.parse import quote
 
-import pytest
-
+from airflow import DAG
+from airflow.models import XCom, BaseOperatorLink
+from airflow.models.dagrun import DagRun
+from airflow.plugins_manager import AirflowPlugin
+from airflow.providers.google.cloud.operators.bigquery import BigQueryExecuteQueryOperator
+from airflow.utils.dates import days_ago
+from airflow.utils.session import provide_session
+from airflow.utils.timezone import datetime
+from airflow.utils.types import DagRunType
 from airflow.www import app
+from parameterized import parameterized
+from test_utils.mock_plugins import mock_plugin_manager
+from tests.test_utils.db import clear_db_runs, clear_db_xcom
 
 
 class TestGetExtraLinks(unittest.TestCase):
     @classmethod
     def setUpClass(cls) -> None:
         super().setUpClass()
-        cls.app = app.create_app(testing=True)  # type:ignore
+        with mock.patch.dict('os.environ', SKIP_DAGS_PARSING='True'):
+            cls.app = app.create_app(testing=True)  # type:ignore
+
+    @provide_session
+    def setUp(self, session) -> None:
+        self.now = datetime(2020, 1, 1)
+
+        clear_db_runs()
+        clear_db_xcom()
+
+        self.dag = self._create_dag()
+        self.app.dag_bag.dags = {self.dag.dag_id: self.dag}  # pylint: disable=no-member
+        self.app.dag_bag.sync_to_db()  # pylint: disable=no-member
+
+        dr = DagRun(
+            dag_id=self.dag.dag_id,
+            run_id="TEST_DAG_RUN_ID",
+            execution_date=self.now,
+            run_type=DagRunType.MANUAL.value,
+        )
+        session.add(dr)
+        session.commit()
 
-    def setUp(self) -> None:
         self.client = self.app.test_client()  # type:ignore
 
-    @pytest.mark.skip(reason="Not implemented yet")
+    def tearDown(self) -> None:
+        super().tearDown()
+        clear_db_runs()
+        clear_db_xcom()
+
+    @staticmethod
+    def _create_dag():
+        with DAG(dag_id="TEST_DAG_ID", default_args=dict(start_date=days_ago(2),)) as dag:
+            BigQueryExecuteQueryOperator(task_id="TEST_SINGLE_QUERY", sql="SELECT 1")
+            BigQueryExecuteQueryOperator(task_id="TEST_MULTIPLE_QUERY", sql=["SELECT 1", "SELECT 2"])
+        return dag
+
+    @parameterized.expand(
+        [
+            (
+                "/api/v1/dags/INVALID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links",
+                'DAG not found'
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/INVALID/taskInstances/TEST_SINGLE_QUERY/links",
+                "DAG Run not found"
+            ),
+            (
+                "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/INVALID/links",
+                "Task not found"
+            ),
+        ]
+    )
+    def test_should_response_404_on_invalid_task_id(self, url, expected_title):
+        response = self.client.get(url)
+
+        self.assertEqual(404, response.status_code)
+        self.assertEqual({'detail': None, 'status': 404, 'title': expected_title, 'type': 'about:blank'}, response.json)
+
+    @mock_plugin_manager(plugins=[])
     def test_should_response_200(self):
+        XCom.set(
+            key="job_id",
+            value="TEST_JOB_ID",
+            execution_date=self.now,
+            task_id="TEST_SINGLE_QUERY",
+            dag_id=self.dag.dag_id,
+        )
+        response = self.client.get(
+            "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links"
+        )
+
+        self.assertEqual(200, response.status_code, response.data)
+        self.assertEqual(
+            {
+                "BigQuery Console": "https://console.cloud.google.com/bigquery?j=TEST_JOB_ID",
+            },
+            response.json,
+        )
+
+    @mock_plugin_manager(plugins=[])
+    def test_should_response_200_missing_xcom(self):
+        response = self.client.get(
+            "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links"
+        )
+
+        self.assertEqual(200, response.status_code, response.data)
+        self.assertEqual(
+            {
+                "BigQuery Console": None,
+            },
+            response.json,
+        )
+
+    @mock_plugin_manager(plugins=[])
+    def test_should_response_200_multiple_links(self):
+        XCom.set(
+            key="job_id",
+            value=["TEST_JOB_ID_1", "TEST_JOB_ID_2"],
+            execution_date=self.now,
+            task_id="TEST_MULTIPLE_QUERY",
+            dag_id=self.dag.dag_id,
+        )
+        response = self.client.get(
+            "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_MULTIPLE_QUERY/links"
+        )
+
+        self.assertEqual(200, response.status_code, response.data)
+        self.assertEqual(
+            {
+                "BigQuery Console #1": "https://console.cloud.google.com/bigquery?j=TEST_JOB_ID_1",
+                "BigQuery Console #2": "https://console.cloud.google.com/bigquery?j=TEST_JOB_ID_2",
+            },
+            response.json,
+        )
+
+    @mock_plugin_manager(plugins=[])
+    def test_should_response_200_multiple_links_missing_xcom(self):
         response = self.client.get(
-            "/dags/TEST_DG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_TASK_ID/links"
+            "/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_MULTIPLE_QUERY/links"
         )
-        assert response.status_code == 200
+
+        self.assertEqual(200, response.status_code, response.data)
+        self.assertEqual(
+            {
+                "BigQuery Console #1": None,
+                "BigQuery Console #2": None,
+            },
+            response.json,
+        )
+
+    def test_should_response_200_support_plugins(self):
+        class GoogleLink(BaseOperatorLink):
+            name = "Google"
+
+            def get_link(self, operator, dttm):
+                return "https://www.google.com"
+
+        class S3LogLink(BaseOperatorLink):
+            name = 'S3'
+            operators = [BigQueryExecuteQueryOperator]
+
+            def get_link(self, operator, dttm):
+                return 'https://s3.amazonaws.com/airflow-logs/{dag_id}/{task_id}/{execution_date}'.format(
+                    dag_id=operator.dag_id,
+                    task_id=operator.task_id,
+                    execution_date=quote(dttm.isoformat()),

Review comment:
       ```suggestion
                       execution_date=quote_plus(dttm.isoformat()),
   ```
   I am thinking that quote_plus will be better here?




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



[GitHub] [airflow] turbaszek commented on a change in pull request #9475: Add extra links endpoint

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9475:
URL: https://github.com/apache/airflow/pull/9475#discussion_r444748743



##########
File path: airflow/api_connexion/endpoints/extra_link_endpoint.py
##########
@@ -15,12 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# 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
 
+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
 
-def get_extra_links():
+
+@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", detail=f'DAG with ID = "{dag_id}" not found')
+
+    try:
+        task = dag.get_task(task_id)
+    except TaskNotFound:
+        raise NotFound("Task not found", detail=f'Task with ID = "{task_id}" not found')
+
+    execution_date = (
+        session.query(DR.execution_date).filter(DR.dag_id == dag_id).filter(DR.run_id == dag_run_id).scalar()
+    )
+    if not execution_date:
+        raise NotFound("DAG Run not found", detail=f'DAG Run with ID = "{dag_run_id}" not found')

Review comment:
       Oh got it, there is `DAG Run not found`, my mistake




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