jedcunningham commented on code in PR #39440:
URL: https://github.com/apache/airflow/pull/39440#discussion_r1591617013


##########
airflow/www/views.py:
##########
@@ -2233,18 +2234,22 @@ def _clear_dag_tis(
         session: Session,
     ):
         if confirmed:
-            count = dag.clear(
+            tis = dag.clear(
                 start_date=start_date,
                 end_date=end_date,
                 task_ids=task_ids,
                 include_subdags=recursive,
                 include_parentdag=recursive,
                 only_failed=only_failed,
                 session=session,
+                return_cleared_task_instances=True,
             )
-
-            msg = f"{count} task instances have been cleared"
-            return redirect_or_json(origin, msg)
+            log = TaskContextLogger("webserver", call_site_logger=logger)
+            if isinstance(tis, list):  # necessary for mypy
+                for ti in tis:
+                    log.info("Task was manually cleared from the UI, 
rerunning", ti=ti)
+                msg = f"{len(tis)} task instances have been cleared"
+                return redirect_or_json(origin, msg)

Review Comment:
   ```suggestion
               if typing.TYPE_CHECKING:
                   assert isinstance(tis, list)
               for ti in tis:
                   log.info("Task was manually cleared from the UI, rerunning", 
ti=ti)
               msg = f"{len(tis)} task instances have been cleared"
               return redirect_or_json(origin, msg)
   ```
   
   This is a better way to handle mypy.



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

Reply via email to