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

jedcunningham pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 60da13d191 Don't require that a teardown have a "work" task (#33018)
60da13d191 is described below

commit 60da13d191dd345c4d73e0f685c598a4c28f9b4a
Author: Daniel Standish <[email protected]>
AuthorDate: Tue Aug 1 19:05:59 2023 -0700

    Don't require that a teardown have a "work" task (#33018)
---
 airflow/models/dag.py    |  5 -----
 tests/models/test_dag.py | 24 ------------------------
 2 files changed, 29 deletions(-)

diff --git a/airflow/models/dag.py b/airflow/models/dag.py
index 8a5f6c714b..ba4278a8da 100644
--- a/airflow/models/dag.py
+++ b/airflow/models/dag.py
@@ -717,11 +717,6 @@ class DAG(LoggingMixin):
         :meta private:
         """
         for task in self.tasks:
-            if task.is_teardown and all(x.is_setup for x in 
task.upstream_list):
-                raise AirflowDagInconsistent(
-                    f"Dag has teardown task without an upstream work task: 
dag='{self.dag_id}',"
-                    f" task='{task.task_id}'"
-                )
             FailStopDagInvalidTriggerRule.check(dag=self, 
trigger_rule=task.trigger_rule)
 
     def __repr__(self):
diff --git a/tests/models/test_dag.py b/tests/models/test_dag.py
index a4be6396be..cd296c0ddc 100644
--- a/tests/models/test_dag.py
+++ b/tests/models/test_dag.py
@@ -45,7 +45,6 @@ from airflow.configuration import conf
 from airflow.datasets import Dataset
 from airflow.decorators import setup, task as task_decorator, teardown
 from airflow.exceptions import (
-    AirflowDagInconsistent,
     AirflowException,
     DuplicateTaskIdFound,
     ParamValidationError,
@@ -3898,26 +3897,3 @@ class TestTaskClearingSetupTeardownBehavior:
                 "my_setup", include_upstream=upstream, 
include_downstream=downstream
             ).tasks
         } == expected
-
-    def test_validate_setup_teardown_dag(self, dag_maker):
-        """Test some invalid setups and teardowns in a dag"""
-        with dag_maker("test_dag") as dag:
-            s1, w1, w2, t1 = self.make_tasks(dag, "s1, w1, w2, t1")
-            w1 >> w2
-            with s1 >> t1:
-                ...
-        with pytest.raises(
-            AirflowDagInconsistent,
-            match="Dag has teardown task without an upstream work task: 
dag='test_dag', task='t1'",
-        ):
-            dag.validate()
-
-        with dag_maker("test_dag") as dag:
-            s1, w1, w2, t1 = self.make_tasks(dag, "s1, w1, w2, t1")
-            s1 >> t1 >> w1 >> w2
-
-        with pytest.raises(
-            AirflowDagInconsistent,
-            match="Dag has teardown task without an upstream work task: 
dag='test_dag', task='t1'",
-        ):
-            dag.validate()

Reply via email to