[ARVADOS] created: f9ac3734498a72657adf82004d012ebfae87f5cd

Git user git at public.curoverse.com
Thu Jun 2 19:54:37 EDT 2016


        at  f9ac3734498a72657adf82004d012ebfae87f5cd (commit)


commit f9ac3734498a72657adf82004d012ebfae87f5cd
Author: radhika <radhika at curoverse.com>
Date:   Thu Jun 2 19:53:24 2016 -0400

    9318: "Active" and "Recently finished" panes in dashboard are updated to use work_unit interface.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 4c3d3f8..3e5afbd 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -828,11 +828,45 @@ class ApplicationController < ActionController::Base
     pi
   end
 
+  helper_method :running_processes
+  def running_processes lim
+    lim = 8 if lim.nil?
+
+    pipelines = PipelineInstance.limit(lim).order(["started_at desc", "created_at desc"]).filter([["state", "in", ["RunningOnServer", "RunningOnClient"]]])
+
+    crs = ContainerRequest.order(["modified_at desc"]).filter([["requesting_container_uuid", "!=", nil], ["state", "=", "Committed"]])
+    cr_uuids = crs.results.collect { |c| c.container_uuid }
+    containers = Container.limit(lim).order(["started_at desc", "created_at desc"]).filter([["uuid", "in", cr_uuids], ["state", "=", "Running"]]).results if cr_uuids.any?
+
+    procs = {}
+    pipelines.results.each { |pi| procs[pi] = (pi.started_at || pi.created_at)}
+    containers.each { |c| procs[c] = c.created_at } if !containers.nil?
+
+    Hash[procs.sort_by {|key, value| value}].keys.reverse.first(lim)
+  end
+
   helper_method :finished_pipelines
   def finished_pipelines lim
     PipelineInstance.limit(lim).order(["finished_at desc"]).filter([["state", "in", ["Complete", "Failed", "Paused"]], ["finished_at", "!=", nil]])
   end
 
+  helper_method :finished_processes
+  def finished_processes lim
+    lim = 8 if lim.nil?
+
+    pipelines = PipelineInstance.limit(lim).order(["finished_at desc"]).filter([["state", "in", ["Complete", "Failed", "Paused"]], ["finished_at", "!=", nil]])
+
+    crs = ContainerRequest.order(["modified_at desc"]).filter([["requesting_container_uuid", "!=", nil], ["state", "=", "Final"]])
+    cr_uuids = crs.results.collect { |c| c.container_uuid }
+    containers = Container.limit(lim).order(["finished_at desc"]).filter([["uuid", "in", cr_uuids], ["state", "in", ["Complete", "Canceled"]], ["finished_at", "!=", nil]]).results if cr_uuids.any?
+
+    procs = {}
+    pipelines.results.each { |pi| procs[pi] = pi.finished_at }
+    containers.each { |pi| procs[pi] = pi.finished_at } if !containers.nil?
+
+    Hash[procs.sort_by {|key, value| value}].keys.reverse.first(lim)
+  end
+
   helper_method :recent_collections
   def recent_collections lim
     c = Collection.limit(lim).order(["modified_at desc"]).filter([["owner_uuid", "is_a", "arvados#group"]])
diff --git a/apps/workbench/app/models/proxy_work_unit.rb b/apps/workbench/app/models/proxy_work_unit.rb
index 5d3ecab..a131cfe 100644
--- a/apps/workbench/app/models/proxy_work_unit.rb
+++ b/apps/workbench/app/models/proxy_work_unit.rb
@@ -189,6 +189,17 @@ class ProxyWorkUnit < WorkUnit
     get(:output)
   end
 
+  def outputs
+    items = []
+    children.each do |c|
+      items << c.output if c.output
+    end
+    if !items.any?
+      items << get(:output) if get(:output)
+    end
+    items
+  end
+
   def children
     []
   end
diff --git a/apps/workbench/app/models/work_unit.rb b/apps/workbench/app/models/work_unit.rb
index fba9015..9459cd1 100644
--- a/apps/workbench/app/models/work_unit.rb
+++ b/apps/workbench/app/models/work_unit.rb
@@ -91,6 +91,11 @@ class WorkUnit
     # returns uuid or pdh of output data, if any
   end
 
+  def outputs
+    # returns array containing uuid or pdh of output data of all children
+    # if no children, return output data if any
+  end
+
   def child_summary
     # summary status of any children of this work unit
   end
diff --git a/apps/workbench/app/views/projects/_show_dashboard.html.erb b/apps/workbench/app/views/projects/_show_dashboard.html.erb
index 47a2723..ef43668 100644
--- a/apps/workbench/app/views/projects/_show_dashboard.html.erb
+++ b/apps/workbench/app/views/projects/_show_dashboard.html.erb
@@ -1,7 +1,7 @@
   <div class="row">
     <div class="col-md-6">
       <div class="panel panel-default" style="min-height: 10.5em">
-        <div class="panel-heading"><span class="panel-title">Active pipelines</span>
+        <div class="panel-heading"><span class="panel-title">Active processes</span>
           <% if current_user.andand.is_active %>
           <span class="pull-right">
           <%= link_to(
@@ -18,46 +18,41 @@
           <% end %>
         </div>
 
-        <% _running_pipelines = running_pipelines %>
-        <% _finished_pipelines = finished_pipelines(8) %>
-        <% lookup = preload_objects_for_dataclass PipelineTemplate, (_running_pipelines.map(&:pipeline_template_uuid) + _finished_pipelines.map(&:pipeline_template_uuid)) %>
-
-        <div class="panel-body">
-          <% if _running_pipelines.empty? %>
-            No pipelines are currently running.
+        <% _running_processes = running_processes(8) %>
+        <% _finished_processes = finished_processes(8) %>
+        <div class="panel-body active-processes">
+          <% if _running_processes.empty? %>
+            No processes are currently running.
           <% else %>
-          <% _running_pipelines.each do |p| %>
+          <% _running_processes.each do |p| %>
+            <% wu = p.work_unit %>
             <div class="dashboard-panel-info-row">
               <div class="clearfix">
-                <%= link_to_if_arvados_object p, {friendly_name: true, lookup: lookup} %>
-
+                <%= link_to_if_arvados_object p, {friendly_name: true} %>
                 <div class="pull-right" style="width: 40%">
                   <div class="progress" style="margin-bottom: 0px">
-                    <% p.components.each do |k, v| %>
-                      <% if v.is_a? Hash and v[:job] %>
-                        <%= render partial: 'job_progress', locals: {:j => v[:job], :scaleby => (1.0/p.components.size)} %>
-                      <% end %>
-                    <% end %>
+                    <% wu.progress %>
                   </div>
                 </div>
               </div>
 
               <%
-                running = p.components.select { |k, c| c.is_a? Hash and c[:job].andand[:state] == "Running" }
-                queued = p.components.select { |k, c| c.is_a? Hash and c[:job].andand[:state] == "Queued" }
+                children = wu.children
+                running = children.select { |c| c.andand.state_label == "Running" }
+                queued = children.select { |c| c.andand.state_label == "Queued" }
                 %>
 
               <div class="clearfix">
-                Started at <%= render_localized_date(p[:started_at] || p[:created_at], "noseconds") %>.
-                <% pipeline_time = Time.now - (p[:started_at] || p[:created_at]) %>
-                Active for <%= render_runtime(pipeline_time, false) %>.
+                Started at <%= render_localized_date(wu.started_at || wu.created_at, "noseconds") %>.
+                <% wu_time = Time.now - (wu.started_at || wu.created_at) %>
+                Active for <%= render_runtime(wu_time, false) %>.
 
                 <div class="pull-right">
-                  <% running.each do |k,v| %>
-                    <%= render partial: 'job_progress', locals: {:j => v[:job], :show_progress_bar => false, :title => k} %>
+                  <% running.each do |r| %>
+                    <span class="label label-<%= r.state_bootstrap_class %>"> <%= r.label || r.state_label || 'Not ready' %> </span>
                   <% end %>
-                  <% queued.each do |k,v| %>
-                    <%= render partial: 'job_progress', locals: {:j => v[:job], :show_progress_bar => false, :title => k} %>
+                  <% queued.each do |q| %>
+                    <span class="label label-<%= q.state_bootstrap_class %>"> <%= q.label || r.state_label || 'Not ready' %> </span>
                   <% end %>
                 </div>
               </div>
@@ -68,51 +63,49 @@
       </div>
 
       <div class="panel panel-default">
-        <div class="panel-heading"><span class="panel-title">Recently finished pipelines</span>
+        <div class="panel-heading"><span class="panel-title">Recently finished processes</span>
           <span class="pull-right">
             <%= link_to pipeline_instances_path, class: 'btn btn-default btn-xs' do %>
               All pipelines <i class="fa fa-fw fa-arrow-circle-right"></i>
             <% end %>
           </span>
         </div>
-        <div class="panel-body">
-          <% _finished_pipelines.each do |p| %>
+        <div class="panel-body finished-processes">
+          <% _finished_processes.each do |p| %>
+            <% wu = p.work_unit %>
             <div class="dashboard-panel-info-row">
               <div class="row">
                 <div class="col-md-6 text-overflow-ellipsis">
-                  <%= link_to_if_arvados_object p, {friendly_name: true, lookup: lookup} %>
+                  <%= link_to_if_arvados_object p, {friendly_name: true} %>
                 </div>
                 <div class="col-md-2">
-                  <%= render partial: "pipeline_status_label", locals: {p: p}%>
+                  <span class="label label-<%=wu.state_bootstrap_class%>"><%=wu.state_label%></span>
                 </div>
                 <div class="col-md-4">
-                  <%= render_localized_date(p[:finished_at] || p[:modified_at], "noseconds") %>
+                  <%= render_localized_date(wu.finished_at || wu.modified_at, "noseconds") %>
                 </div>
               </div>
               <div class="row">
                 <div class="col-md-12">
-                  <% if p[:started_at] and p[:finished_at] %>
-                    <% pipeline_time = p[:finished_at] - p[:started_at] %>
-                    Active for <%= render_runtime(pipeline_time, false) %>
+                  <% if wu.started_at and wu.finished_at %>
+                    <% wu_time = wu.finished_at - wu.started_at %>
+                    Active for <%= render_runtime(wu_time, false) %>
                   <% end %>
 
                   <span class="pull-right text-overflow-ellipsis" style="max-width: 100%">
-                    <% outputs = [] %>
-                    <% p.components.each do |k, c| %>
-                      <% outputs << c[:output_uuid] if c[:output_uuid] %>
-                    <% end %>
+                    <% outputs = wu.outputs %>
                     <% if outputs.size == 0 %>
                       No output.
                     <% elsif outputs.size == 1 %>
                       <i class="fa fa-fw fa-archive"></i> <%= link_to_if_arvados_object outputs[0], friendly_name: true %>
                     <% else %>
-                      <a href="#<%= p[:uuid] %>-outputs" data-toggle="collapse">Outputs <span class="caret"></span></a>
+                      <a href="#<%= wu.uuid %>-outputs" data-toggle="collapse">Outputs <span class="caret"></span></a>
                     <% end %>
                   </span>
                 </div>
               </div>
 
-              <div class="row collapse" id="<%= p[:uuid] %>-outputs" >
+              <div class="row collapse" id="<%= wu.uuid %>-outputs" >
                 <div class="col-md-12">
                   <div class="pull-right" style="max-width: 100%">
                     <% outputs.each do |out| %>
diff --git a/apps/workbench/app/views/work_unit/_progress.html.erb b/apps/workbench/app/views/work_unit/_progress.html.erb
index ef7dcd9..27f19ec 100644
--- a/apps/workbench/app/views/work_unit/_progress.html.erb
+++ b/apps/workbench/app/views/work_unit/_progress.html.erb
@@ -1,5 +1,5 @@
 <% if wu.state_label == 'Running' %>
-  <% if @object.uuid == wu.uuid and wu.progress == 0.0 %>
+  <% if @object.andand.uuid == wu.uuid and wu.progress == 0.0 %>
     <span class="label label-<%= wu.state_bootstrap_class %>"> Active </span>
   <% else%>
     <div class="progress" style="margin-bottom: 0px">
diff --git a/apps/workbench/test/integration/application_layout_test.rb b/apps/workbench/test/integration/application_layout_test.rb
index 4a6a553..d00eb88 100644
--- a/apps/workbench/test/integration/application_layout_test.rb
+++ b/apps/workbench/test/integration/application_layout_test.rb
@@ -179,7 +179,23 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
 
         first('button', text: 'x').click
       end
-      assert_text 'Active pipelines' # seeing dashboard now
+      assert_text 'Active processes' # seeing dashboard now
+      if token == 'active'
+        within('.active-processes') do
+          assert_text 'zzzzz-dz642-runningcontainr'
+          assert_text 'zzzzz-dz642-runningcontain2'
+          assert_text 'zzzzz-d1hrv-partdonepipelin'
+          assert_no_text 'zzzzz-d1hrv-twodonepipeline'
+          assert_no_text 'zzzzz-xvhdp-cr4queuedcontnr'
+        end
+        within('.finished-processes') do
+          assert_text 'zzzzz-d1hrv-twodonepipeline'
+          assert_text 'zzzzz-dz642-compltcontainer'
+          assert_text 'zzzzz-dz642-compltcontainr2'
+          assert_no_text 'zzzzz-d1hrv-partdonepipelin'
+          assert_no_text 'zzzzz-dz642-runningcontainr'
+        end
+      end
     end
   end
 
diff --git a/apps/workbench/test/integration/logins_test.rb b/apps/workbench/test/integration/logins_test.rb
index 2e2de70..fb8c906 100644
--- a/apps/workbench/test/integration/logins_test.rb
+++ b/apps/workbench/test/integration/logins_test.rb
@@ -7,7 +7,7 @@ class LoginsTest < ActionDispatch::IntegrationTest
 
   test "login with api_token works after redirect" do
     visit page_with_token('active_trustedclient')
-    assert page.has_text?('Active pipelines'), "Missing 'Active pipelines' from page"
+    assert page.has_text?('Active processes'), "Missing 'Active processes' from page"
     assert_no_match(/\bapi_token=/, current_path)
   end
 
diff --git a/apps/workbench/test/integration/pipeline_templates_test.rb b/apps/workbench/test/integration/pipeline_templates_test.rb
index 19a5109..0b04c73 100644
--- a/apps/workbench/test/integration/pipeline_templates_test.rb
+++ b/apps/workbench/test/integration/pipeline_templates_test.rb
@@ -35,7 +35,7 @@ class PipelineTemplatesTest < ActionDispatch::IntegrationTest
     assert page.has_text? 'Textile description for pipeline template'
     assert page.has_link? 'Go to dashboard'
     click_link 'Go to dashboard'
-    assert page.has_text? 'Active pipelines'
+    assert page.has_text? 'Active processes'
 
     # again visit recent templates page and verify edited description
     visit page_with_token("active", "/pipeline_templates")
diff --git a/apps/workbench/test/integration/user_profile_test.rb b/apps/workbench/test/integration/user_profile_test.rb
index 41d115a..86bf14a 100644
--- a/apps/workbench/test/integration/user_profile_test.rb
+++ b/apps/workbench/test/integration/user_profile_test.rb
@@ -20,7 +20,7 @@ class UserProfileTest < ActionDispatch::IntegrationTest
         assert page.has_text?('Save profile'), 'No text - Save profile'
         add_profile user
       else
-        assert page.has_text?('Active pipelines'), 'Not found text - Active pipelines'
+        assert page.has_text?('Active processes'), 'Not found text - Active processes'
         assert page.has_no_text?('Save profile'), 'Found text - Save profile'
       end
     elsif invited
@@ -119,7 +119,7 @@ class UserProfileTest < ActionDispatch::IntegrationTest
     end
 
     # profile saved and in home page now
-    assert page.has_text?('Active pipelines'), 'No text - Active pipelines'
+    assert page.has_text?('Active processes'), 'No text - Active processes'
   end
 
   [
diff --git a/services/api/test/fixtures/container_requests.yml b/services/api/test/fixtures/container_requests.yml
index 1e474bb..87c712e 100644
--- a/services/api/test/fixtures/container_requests.yml
+++ b/services/api/test/fixtures/container_requests.yml
@@ -15,6 +15,40 @@ queued:
   container_uuid: zzzzz-dz642-queuedcontainer
   requesting_container_uuid: zzzzz-dz642-requestingcntnr
 
+running:
+  uuid: zzzzz-xvhdp-cr4runningcntnr
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  name: running
+  state: Committed
+  priority: 1
+  created_at: 2016-01-11 11:11:11.111111111 Z
+  updated_at: 2016-01-11 11:11:11.111111111 Z
+  modified_at: 2016-01-11 11:11:11.111111111 Z
+  modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  container_image: test
+  cwd: test
+  output_path: test
+  command: ["echo", "hello"]
+  container_uuid: zzzzz-dz642-runningcontainr
+  requesting_container_uuid: zzzzz-dz642-requestingcntnr
+
+running-older:
+  uuid: zzzzz-xvhdp-cr4runningcntn2
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  name: running
+  state: Committed
+  priority: 1
+  created_at: 2016-01-11 11:11:11.111111111 Z
+  updated_at: 2016-01-11 11:11:11.111111111 Z
+  modified_at: 2016-01-12 11:11:11.111111111 Z
+  modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  container_image: test
+  cwd: test
+  output_path: test
+  command: ["echo", "hello"]
+  container_uuid: zzzzz-dz642-runningcontain2
+  requesting_container_uuid: zzzzz-dz642-requestingcntnr
+
 completed:
   uuid: zzzzz-xvhdp-cr4completedctr
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
@@ -32,11 +66,11 @@ completed:
   container_uuid: zzzzz-dz642-compltcontainer
   requesting_container_uuid: zzzzz-dz642-requestingcntnr
 
-running:
-  uuid: zzzzz-xvhdp-cr4runningcntnr
+completed-older:
+  uuid: zzzzz-xvhdp-cr4completedcr2
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
-  name: running
-  state: Committed
+  name: completed
+  state: Final
   priority: 1
   created_at: 2016-01-11 11:11:11.111111111 Z
   updated_at: 2016-01-11 11:11:11.111111111 Z
@@ -46,5 +80,5 @@ running:
   cwd: test
   output_path: test
   command: ["echo", "hello"]
-  container_uuid: zzzzz-dz642-requestingcntnr
+  container_uuid: zzzzz-dz642-compltcontainr2
   requesting_container_uuid: zzzzz-dz642-requestingcntnr
diff --git a/services/api/test/fixtures/containers.yml b/services/api/test/fixtures/containers.yml
index 4c8c8c1..6fc3fd1 100644
--- a/services/api/test/fixtures/containers.yml
+++ b/services/api/test/fixtures/containers.yml
@@ -1,6 +1,6 @@
 queued:
   uuid: zzzzz-dz642-queuedcontainer
-  owner_uuid: zzzzz-tpzed-000000000000000
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   state: Queued
   priority: 1
   created_at: 2016-01-11 11:11:11.111111111 Z
@@ -14,13 +14,49 @@ queued:
     ram: 12000000000
     vcpus: 4
 
+running:
+  uuid: zzzzz-dz642-runningcontainr
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  state: Running
+  priority: 1
+  created_at: 2016-01-11 11:11:11.111111111 Z
+  updated_at: 2016-01-11 11:11:11.111111111 Z
+  started_at: 2016-01-11 11:11:11.111111111 Z
+  container_image: test
+  cwd: test
+  output: test
+  output_path: test
+  command: ["echo", "hello"]
+  runtime_constraints:
+    ram: 12000000000
+    vcpus: 4
+
+running-older:
+  uuid: zzzzz-dz642-runningcontain2
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  state: Running
+  priority: 1
+  created_at: 2016-01-11 11:11:11.111111111 Z
+  updated_at: 2016-01-11 11:11:11.111111111 Z
+  started_at: 2016-01-12 11:11:11.111111111 Z
+  container_image: test
+  cwd: test
+  output: test
+  output_path: test
+  command: ["echo", "hello"]
+  runtime_constraints:
+    ram: 12000000000
+    vcpus: 4
+
 completed:
   uuid: zzzzz-dz642-compltcontainer
-  owner_uuid: zzzzz-tpzed-000000000000000
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   state: Complete
   priority: 1
   created_at: 2016-01-11 11:11:11.111111111 Z
   updated_at: 2016-01-11 11:11:11.111111111 Z
+  started_at: 2016-01-11 11:11:11.111111111 Z
+  finished_at: 2016-01-12 11:12:13.111111111 Z
   container_image: test
   cwd: test
   output: test
@@ -30,13 +66,15 @@ completed:
     ram: 12000000000
     vcpus: 4
 
-running:
-  uuid: zzzzz-dz642-runningcontainr
-  owner_uuid: zzzzz-tpzed-000000000000000
-  state: Running
+completed_older:
+  uuid: zzzzz-dz642-compltcontainr2
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  state: Complete
   priority: 1
   created_at: 2016-01-11 11:11:11.111111111 Z
   updated_at: 2016-01-11 11:11:11.111111111 Z
+  started_at: 2016-01-13 11:11:11.111111111 Z
+  finished_at: 2016-01-14 11:12:13.111111111 Z
   container_image: test
   cwd: test
   output: test
diff --git a/services/api/test/fixtures/pipeline_instances.yml b/services/api/test/fixtures/pipeline_instances.yml
index 41a7fc9..41f98ee 100644
--- a/services/api/test/fixtures/pipeline_instances.yml
+++ b/services/api/test/fixtures/pipeline_instances.yml
@@ -388,6 +388,8 @@ complete_pipeline_with_two_jobs:
   uuid: zzzzz-d1hrv-twodonepipeline
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   state: Complete
+  started_at: <%= 10.minute.ago.to_s(:db) %>
+  finished_at: <%= 9.minute.ago.to_s(:db) %>
   components:
    ancient:
     job:

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list