jason810496 commented on code in PR #50175:
URL: https://github.com/apache/airflow/pull/50175#discussion_r2076713853


##########
airflow-core/src/airflow/utils/log/file_task_handler.py:
##########
@@ -474,6 +480,20 @@ def _get_log_retrieval_url(
             hostname = ti.triggerer_job.hostname
             log_relative_path = self.add_triggerer_suffix(log_relative_path, 
job_id=ti.triggerer_job.id)
         else:
+            from airflow.models.taskinstancehistory import TaskInstanceHistory
+
+            ti = (
+                session.query(TaskInstanceHistory)
+                .filter(
+                    TaskInstanceHistory.dag_id == ti.dag_id,
+                    TaskInstanceHistory.task_id == ti.task_id,
+                    TaskInstanceHistory.run_id == ti.run_id,
+                    TaskInstanceHistory.map_index == ti.map_index,
+                    TaskInstanceHistory.try_number == try_number,
+                )
+                .one_or_none()
+                or ti
+            )

Review Comment:
   Thanks for the try. 
   
   IMO, we could still modify the logic on API side to `ti = TIH or TI` ( 
select TIH first, if None, then select TI. It should be the same as your 
approach but implement on API side ).
   
   For the typing part, we can include `TaskInstanceHistory` as well ( `ti: TI 
| TIH` )



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