oboki commented on code in PR #50175:
URL: https://github.com/apache/airflow/pull/50175#discussion_r2078077637
##########
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:
In my previous attempt, I ran into a type issue right from the beginning,
like this:
```python
Traceback (most recent call last):
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/log/file_task_handler.py",
line 589, in _read_from_logs_server
log_type = LogType.TRIGGER if ti.triggerer_job else LogType.WORKER
^^^^^^^^^^^^^^^^
AttributeError: 'TaskInstanceHistory' object has no attribute 'triggerer_job'
```
And I didn't dig much deeper at the time. But after working around this
`AttributeError`, your approach looks much simpler!
Thanks again!
--
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]