This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v1-10-test by this push:
     new c23b5e6  Improve warning messaging for duplicate task_ids in a DAG 
(#11126)
c23b5e6 is described below

commit c23b5e62352be36324164b86c01f78be5ff4ea23
Author: Ben <[email protected]>
AuthorDate: Fri Sep 25 12:01:07 2020 +0200

    Improve warning messaging for duplicate task_ids in a DAG (#11126)
    
    closes: #11125
---
 airflow/models/dag.py    |  4 ++--
 tests/models/test_dag.py | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/airflow/models/dag.py b/airflow/models/dag.py
index de610e2..348e19d 100644
--- a/airflow/models/dag.py
+++ b/airflow/models/dag.py
@@ -1335,10 +1335,10 @@ class DAG(BaseDag, LoggingMixin):
         if task.task_id in self.task_dict and self.task_dict[task.task_id] is 
not task:
             # TODO: raise an error in Airflow 2.0
             warnings.warn(
-                'The requested task could not be added to the DAG because a '
+                'The requested task could not be added to the DAG with dag_id 
{} because a '
                 'task with task_id {} is already in the DAG. Starting in '
                 'Airflow 2.0, trying to overwrite a task will raise an '
-                'exception.'.format(task.task_id),
+                'exception.'.format(self.dag_id, task.task_id),
                 category=PendingDeprecationWarning)
         else:
             self.task_dict[task.task_id] = task
diff --git a/tests/models/test_dag.py b/tests/models/test_dag.py
index b711a8b..05c2674 100644
--- a/tests/models/test_dag.py
+++ b/tests/models/test_dag.py
@@ -918,9 +918,9 @@ class DagTest(unittest.TestCase):
     def test_duplicate_task_ids_raise_warning_with_dag_context_manager(self):
         """Verify tasks with Duplicate task_id show warning"""
 
-        deprecation_msg = "The requested task could not be added to the DAG 
because a task with " \
-                          "task_id t1 is already in the DAG. Starting in 
Airflow 2.0, trying to " \
-                          "overwrite a task will raise an exception."
+        deprecation_msg = "The requested task could not be added to the DAG 
with dag_id test_dag because " \
+                          "a task with task_id t1 is already in the DAG. 
Starting in Airflow 2.0, trying " \
+                          "to overwrite a task will raise an exception."
 
         with pytest.warns(PendingDeprecationWarning) as record:
             with DAG("test_dag", start_date=DEFAULT_DATE) as dag:
@@ -937,9 +937,9 @@ class DagTest(unittest.TestCase):
     def test_duplicate_task_ids_raise_warning(self):
         """Verify tasks with Duplicate task_id show warning"""
 
-        deprecation_msg = "The requested task could not be added to the DAG 
because a task with " \
-                          "task_id t1 is already in the DAG. Starting in 
Airflow 2.0, trying to " \
-                          "overwrite a task will raise an exception."
+        deprecation_msg = "The requested task could not be added to the DAG 
with dag_id test_dag " \
+                          "because a task with task_id t1 is already in the 
DAG. Starting in Airflow 2.0, " \
+                          "trying to overwrite a task will raise an exception."
 
         with pytest.warns(PendingDeprecationWarning) as record:
             dag = DAG("test_dag", start_date=DEFAULT_DATE)

Reply via email to