jedcunningham commented on code in PR #51592:
URL: https://github.com/apache/airflow/pull/51592#discussion_r2138712529
##########
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:
So, looking at this a bit closer, I'm not sure we even need this function
any longer. We will always get a ti or tih to this. And typing through the
whole process is also wrong, e.g.
[read_log_stream](https://github.com/apache/airflow/blob/7ea915494a0065fb486567744fd63d60b7586070/airflow-core/src/airflow/utils/log/log_reader.py#L73)
is typed to take ti, but also takes tih in practice.
Can you take a pass at cleaning this up?
--
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]