sunank200 commented on code in PR #51592:
URL: https://github.com/apache/airflow/pull/51592#discussion_r2138649191


##########
airflow-core/src/airflow/utils/log/file_task_handler.py:
##########
@@ -180,15 +181,18 @@ def _interleave_logs(*logs: str | LogMessages) -> 
Iterable[StructuredLogMessage]
         last = msg
 
 
-def _ensure_ti(ti: TaskInstanceKey | TaskInstance, session) -> TaskInstance:
+def _ensure_ti(
+    ti: TaskInstanceKey | TaskInstance | TaskInstanceHistory, session
+) -> TaskInstance | TaskInstanceHistory:
     """
-    Given TI | TIKey, return a TI object.
+    Return a TaskInstance or TaskInstanceHistory for the given TI, TIKey, or 
TaskInstanceHistory.
 
-    Will raise exception if no TI is found in the database.
+    Raises AirflowException if no TI is found in the database.
     """
     from airflow.models.taskinstance import TaskInstance
+    from airflow.models.taskinstancehistory import TaskInstanceHistory
 
-    if isinstance(ti, TaskInstance):
+    if isinstance(ti, (TaskInstance, TaskInstanceHistory)):
         return ti
     val = (

Review Comment:
   @jedcunningham  `_ensure_ti` doesn't find the right task instance or task 
instance history - it’s just a normalisation step inside the `FileTaskHandler` 
so that, no matter whether you passed in:
   1. latest TaskInstance
   2. TaskInstanceKey
   3.. TaskInstanceHistory
   
   You end up with an object that has `.id`, `.try_number`, and 
`.get_dagrun()`, which is all _render_filename needs.
   



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