feluelle 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_r341739169
 
 

 ##########
 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:
   Actually I only did the "validation" because pylint was complaining that an 
explicit return value is required and raising an exception made the most sense 
to me.
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to