stale[bot] closed pull request #2233: [AIRFLOW-1098] Fix issue in setting parent_dag when loading dags URL: https://github.com/apache/incubator-airflow/pull/2233
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/airflow/models.py b/airflow/models.py index e6374d45e0..c7af17bacc 100755 --- a/airflow/models.py +++ b/airflow/models.py @@ -367,7 +367,7 @@ def bag_dag(self, dag, parent_dag, root_dag): for task in dag.tasks: settings.policy(task) - for subdag in dag.subdags: + for subdag in dag.direct_subdags: subdag.full_filepath = dag.full_filepath subdag.parent_dag = dag subdag.is_subdag = True @@ -2994,6 +2994,20 @@ def latest_execution_date(self): session.close() return execution_date + @property + def direct_subdags(self): + """ + Returns only directly connected subdag objects rather than all associated to this DAG + """ + from airflow.operators.subdag_operator import SubDagOperator + l = [] + for task in self.tasks: + if (isinstance(task, SubDagOperator) or + #TODO remove in Airflow 2.0 + type(task).__name__ == 'SubDagOperator'): + l.append(task.subdag) + return l + @property def subdags(self): """ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services