diff --git a/airflow/models.py b/airflow/models.py index 3a5883cf6c38c..4e70e425bbb70 100644 --- a/airflow/models.py +++ b/airflow/models.py @@ -2275,11 +2275,13 @@ def subdags(self): """ Returns a list of the subdag objects associated to this DAG """ - # Late import to prevent circular imports - from airflow.operators import SubDagOperator + # Check SubDag for class but don't check class directly, see + # https://github.com/airbnb/airflow/issues/1168 l = [] for task in self.tasks: - if isinstance(task, SubDagOperator): + if ( + task.__class__.__name__ == 'SubDagOperator' and + hasattr(task, 'subdag')): l.append(task.subdag) l += task.subdag.subdags return l