ashb commented on a change in pull request #4751: [AIRFLOW-3607] collected 
trigger rule dep check per dag run
URL: https://github.com/apache/airflow/pull/4751#discussion_r364232692
 
 

 ##########
 File path: airflow/models/dagrun.py
 ##########
 @@ -263,48 +262,34 @@ def update_state(self, session=None):
         Determines the overall state of the DagRun based on the state
         of its TaskInstances.
 
+        :param finished_tasks: The finished tasks of this run
+        :type finished_tasks: list[airflow.models.TaskInstance]
         :return: State
         """
 
         dag = self.get_dag()
-
-        tis = self.get_task_instances(session=session)
-        self.log.debug("Updating state for %s considering %s task(s)", self, 
len(tis))
+        ready_tis = []
+        tis = [ti for ti in self.get_task_instances(session=session) if 
ti.state != State.REMOVED]
 
 Review comment:
   ~What was your reason for filtering our removed TIs here?~ Oh we did this 
anyway in the next loop. Gotcha.
   
   I think it would be better if we filtered it by using the existing `state` 
parameter of `get_task_instances` rather than having to filter it like this.
   
   We could either do it by passing in a list of states and exclude REMOVED, or 
if we change `get_task_instances` to return a "Result" (i.e. don't do `return 
tis.all()` in there, but instead `return tis` -- this will behave almost the 
same when iterated over) we can then extend the filtering here. For example:
   
   ```suggestion
           tis = 
self.get_task_instances(session=session).fliter(TaskInstance.state != 
State.REMOVED).all()
   ```

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