uranusjr commented on code in PR #22679:
URL: https://github.com/apache/airflow/pull/22679#discussion_r843553422
##########
airflow/models/dagrun.py:
##########
@@ -810,20 +822,27 @@ def verify_integrity(self, session: Session =
NEW_SESSION):
task = None
try:
task = dag.get_task(ti.task_id)
+
+ should_restore_task = (task is not None) and ti.state ==
State.REMOVED
+ if should_restore_task:
+ self.log.info("Restoring task '%s' which was previously
removed from DAG '%s'", ti, dag)
+ Stats.incr(f"task_restored_to_dag.{dag.dag_id}", 1, 1)
+ ti.state = State.NONE
except AirflowException:
if ti.state == State.REMOVED:
pass # ti has already been removed, just ignore it
elif self.state != State.RUNNING and not dag.partial:
self.log.warning("Failed to get task '%s' for dag '%s'.
Marking it as removed.", ti, dag)
Stats.incr(f"task_removed_from_dag.{dag.dag_id}", 1, 1)
ti.state = State.REMOVED
+ continue
- should_restore_task = (task is not None) and ti.state ==
State.REMOVED
- if should_restore_task:
- self.log.info("Restoring task '%s' which was previously
removed from DAG '%s'", ti, dag)
- Stats.incr(f"task_restored_to_dag.{dag.dag_id}", 1, 1)
- ti.state = State.NONE
- session.merge(ti)
+ if task.is_mapped and task.mapped_args_are_literals: # type:
ignore
+ # Check if the number of mapped literals has changed and we
need to mark this TI as removed
+ if ti.map_index >= task.mapped_args_count: # type: ignore
+ ti.state = State.REMOVED
+ elif ti.map_index < 0:
+ ti.state = State.REMOVED
Review Comment:
Way too many `type: ignore` annotations, we should straighten out the types
here.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]