airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] ashb commented on a change in pull request #6722: [AIRFLOW-4922]Fix task get log by Web UI
Date Fri, 20 Dec 2019 16:05:24 GMT
ashb commented on a change in pull request #6722: [AIRFLOW-4922]Fix task get log by Web UI
URL: https://github.com/apache/airflow/pull/6722#discussion_r360437500
 
 

 ##########
 File path: airflow/utils/log/file_task_handler.py
 ##########
 @@ -81,6 +82,34 @@ def _render_filename(self, ti, try_number):
                                              execution_date=ti.execution_date.isoformat(),
                                              try_number=try_number)
 
+    @provide_session
+    def query_task_hostname(self, ti, try_number, session=None):
+        """
+        Get task log hostname by log table and try_number
+
+        :param ti: task instance record
+        :param try_number: current try_number to read log from
+        :param session: database session
+        :type session: sqlalchemy.orm.session.Session
+        :return: log message hostname
+        """
+        from airflow import models
+        res_log = session.query(models.Log).filter(
+            models.Log.dag_id == ti.dag_id,
+            models.Log.task_id == ti.task_id,
+            models.Log.execution_date == ti.execution_date,
+            models.Log.owner != 'anonymous',
+            models.Log.event == 'cli_run',
+            models.Log.extra.like('%--raw%')
+        ).order_by(models.Log.id).limit(1).offset(try_number - 1).first()
 
 Review comment:
   Which cases is this needed in? This seems like an awful lot of conditions here.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message