You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by jl...@apache.org on 2017/03/16 23:34:13 UTC

incubator-airflow git commit: [AIRFLOW-984] Enable subclassing of SubDagOperator

Repository: incubator-airflow
Updated Branches:
  refs/heads/master e08b102c0 -> a8bd1695e


[AIRFLOW-984] Enable subclassing of SubDagOperator

Note this maintains an awkward name check
for backwards compatibility reasons.

Closes #2152 from patrickmckenna/recognize-subdag-
subclasses


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/a8bd1695
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/a8bd1695
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/a8bd1695

Branch: refs/heads/master
Commit: a8bd1695e44e56375a399a9c7a0af0b137922e24
Parents: e08b102
Author: Patrick McKenna <pa...@gmail.com>
Authored: Thu Mar 16 19:33:31 2017 -0400
Committer: Jeremiah Lowin <jl...@apache.org>
Committed: Thu Mar 16 19:33:38 2017 -0400

----------------------------------------------------------------------
 airflow/models.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/a8bd1695/airflow/models.py
----------------------------------------------------------------------
diff --git a/airflow/models.py b/airflow/models.py
index ad3346a..561b002 100755
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -2972,11 +2972,12 @@ class DAG(BaseDag, LoggingMixin):
         """
         # Check SubDag for class but don't check class directly, see
         # https://github.com/airbnb/airflow/issues/1168
+        from airflow.operators.subdag_operator import SubDagOperator
         l = []
         for task in self.tasks:
-            if (
-                    task.__class__.__name__ == 'SubDagOperator' and
-                    hasattr(task, 'subdag')):
+            if (isinstance(task, SubDagOperator) or
+                #TODO remove in Airflow 2.0
+                type(task).__name__ == 'SubDagOperator'):
                 l.append(task.subdag)
                 l += task.subdag.subdags
         return l