You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by bo...@apache.org on 2016/06/14 13:06:17 UTC

incubator-airflow git commit: [AIRFLOW-222] Show duration of task instances in ui

Repository: incubator-airflow
Updated Branches:
  refs/heads/master 7d29698b6 -> 5963ac8b7


[AIRFLOW-222] Show duration of task instances in ui

At the moment mousing over a task instance in the Airflow tree view
only shows the duration for completed task, and shows "Duration: null"
for running tasks.

Instead the UI should show the current task instance's duration
for running tasks. This patch addresses this.

Closes #1589 from sekikn/AIRFLOW-222


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/5963ac8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/5963ac8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/5963ac8b

Branch: refs/heads/master
Commit: 5963ac8b7b7c0b3470ce6171b1cd928485bc9884
Parents: 7d29698
Author: Kengo Seki <se...@apache.org>
Authored: Tue Jun 14 15:06:08 2016 +0200
Committer: Bolke de Bruin <bo...@xs4all.nl>
Committed: Tue Jun 14 15:06:08 2016 +0200

----------------------------------------------------------------------
 airflow/www/views.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5963ac8b/airflow/www/views.py
----------------------------------------------------------------------
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 6757122..b468bc1 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -1290,10 +1290,16 @@ class Airflow(BaseView):
             elif children:
                 children_key = "_children"
 
+            def set_duration(tid):
+                if isinstance(tid, dict) and tid.get("state") == State.RUNNING:
+                    d = datetime.now() - dateutil.parser.parse(tid["start_date"])
+                    tid["duration"] = d.total_seconds()
+                return tid
+
             return {
                 'name': task.task_id,
                 'instances': [
-                        task_instances.get((task.task_id, d)) or {
+                        set_duration(task_instances.get((task.task_id, d))) or {
                             'execution_date': d.isoformat(),
                             'task_id': task.task_id
                         }