airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] milton0825 commented on a change in pull request #6352: [AIRFLOW-5683] Add propagate_skipped_state to SubDagOperator
Date Fri, 01 Nov 2019 18:39:08 GMT
milton0825 commented on a change in pull request #6352: [AIRFLOW-5683] Add propagate_skipped_state
to SubDagOperator
URL: https://github.com/apache/airflow/pull/6352#discussion_r341702632
 
 

 ##########
 File path: airflow/operators/subdag_operator.py
 ##########
 @@ -157,4 +171,44 @@ def post_execute(self, context, result=None):
 
         if dag_run.state != State.SUCCESS:
             raise AirflowException(
-                "Expected state: SUCCESS. Actual state: {}".format(dag_run.state))
+                "Expected state: SUCCESS. Actual state: {}".format(dag_run.state)
+            )
+
+        if self.propagate_skipped_state and self._check_skipped_states(context):
+            self._skip_downstream_tasks(context)
+
+    def _check_skipped_states(self, context):
+        leaves_tis = self._get_leaves_tis(context['execution_date'])
+
+        if self.propagate_skipped_state == SkippedStatePropagationOptions.ANY_LEAF:
+            return any(ti.state == State.SKIPPED for ti in leaves_tis)
+        if self.propagate_skipped_state == SkippedStatePropagationOptions.ALL_LEAVES:
+            return all(ti.state == State.SKIPPED for ti in leaves_tis)
+        raise AirflowException(
 
 Review comment:
   Should we validate this earlier in the `__init__`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message