[ARVADOS] updated: 17e79aa5b26b8c0b3228247451172999ad81baff

Git user git at public.curoverse.com
Thu May 26 15:20:22 EDT 2016


Summary of changes:
 .../app/helpers/pipeline_instances_helper.rb       |   4 +-
 apps/workbench/app/models/job_task_work_unit.rb    |   3 +
 apps/workbench/app/models/job_work_unit.rb         |  24 +--
 .../app/models/pipeline_instance_work_unit.rb      |  11 +-
 apps/workbench/app/models/proxy_work_unit.rb       |  61 ++++++--
 apps/workbench/app/models/work_unit.rb             |   4 +
 .../_show_components_json.html.erb                 |   2 +
 .../app/views/work_unit/_progress.html.erb         |   7 +
 .../app/views/work_unit/_show_child.html.erb       |   2 +-
 .../app/views/work_unit/_show_component.html.erb   | 172 ++++++++++++---------
 apps/workbench/test/integration/jobs_test.rb       |   2 +-
 11 files changed, 178 insertions(+), 114 deletions(-)
 create mode 100644 apps/workbench/app/views/work_unit/_progress.html.erb

       via  17e79aa5b26b8c0b3228247451172999ad81baff (commit)
      from  a4f061a5bf48f0335238da72b8d03ca349fa7553 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 17e79aa5b26b8c0b3228247451172999ad81baff
Author: radhika <radhika at curoverse.com>
Date:   Thu May 26 15:18:36 2016 -0400

    8876: progress bar and strage component display

diff --git a/apps/workbench/app/helpers/pipeline_instances_helper.rb b/apps/workbench/app/helpers/pipeline_instances_helper.rb
index c025e2d..1ed9e3e 100644
--- a/apps/workbench/app/helpers/pipeline_instances_helper.rb
+++ b/apps/workbench/app/helpers/pipeline_instances_helper.rb
@@ -69,8 +69,8 @@ module PipelineInstancesHelper
   def determine_wallclock_runtime jobs
     timestamps = []
     jobs.each do |j|
-      started_at = j.started_at
-      finished_at = (if j.finished_at then j.finished_at else Time.now end)
+      started_at = (j.started_at if j.respond_to?(:started_at)) || (j[:started_at] if j.is_a?(Hash))
+      finished_at = (j.finished_at if j.respond_to?(:finished_at)) || (j[:finished_at] if j.is_a?(Hash)) || Time.now
       if started_at
         timestamps = merge_range timestamps, started_at, finished_at
       end
diff --git a/apps/workbench/app/models/job_task_work_unit.rb b/apps/workbench/app/models/job_task_work_unit.rb
index b4ad6f2..47d53ca 100644
--- a/apps/workbench/app/models/job_task_work_unit.rb
+++ b/apps/workbench/app/models/job_task_work_unit.rb
@@ -1,2 +1,5 @@
 class JobTaskWorkUnit < ProxyWorkUnit
+  def title
+    "job task"
+  end
 end
diff --git a/apps/workbench/app/models/job_work_unit.rb b/apps/workbench/app/models/job_work_unit.rb
index 6bef50f..9b06048 100644
--- a/apps/workbench/app/models/job_work_unit.rb
+++ b/apps/workbench/app/models/job_work_unit.rb
@@ -1,7 +1,7 @@
 class JobWorkUnit < ProxyWorkUnit
   def children
     # Job tasks
-    uuid = (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
+    uuid = get(:uuid)
     tasks = JobTask.filter([['job_uuid', '=', uuid]]).results
     items = []
     tasks.each do |t|
@@ -14,12 +14,12 @@ class JobWorkUnit < ProxyWorkUnit
   end
 
   def progress
-    state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+    state = get(:state)
     if state == 'Complete'
       return 1.0
     end
 
-    tasks_summary = (self.proxied.tasks_summary if self.proxied.respond_to?(:tasks_summary)) || self.proxied[:tasks_summary]
+    tasks_summary = get(:tasks_summary)
     failed = tasks_summary[:failed] || 0 rescue 0
     done = tasks_summary[:done] || 0 rescue 0
     running = tasks_summary[:running] || 0 rescue 0
@@ -33,32 +33,36 @@ class JobWorkUnit < ProxyWorkUnit
   end
 
   def docker_image
-    (self.proxied.docker_image_locator if self.proxied.respond_to?(:docker_image_locator)) || self.proxied[:docker_image_locator]
+    get(:docker_image_locator)
   end
 
   def nondeterministic
-    (self.proxied.nondeterministic if self.proxied.respond_to?(:nondeterministic)) || self.proxied[:nondeterministic]
+    get(:nondeterministic)
   end
 
   def priority
-    (self.proxied.priority if self.proxied.respond_to?(:priority)) || self.proxied[:priority]
+    get(:priority)
   end
 
   def log_collection
-    (self.proxied.log if self.proxied.respond_to?(:log)) || self.proxied[:log]
+    get(:log)
   end
 
   def output
-    (self.proxied.output if self.proxied.respond_to?(:output)) || self.proxied[:output]
+    get(:output)
+  end
+
+  def can_cancel?
+    true
   end
 
   def uri
-    uuid = (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
+    uuid = get(:uuid)
     "/jobs/#{uuid}"
   end
 
   def child_summary
-    (self.proxied.tasks_summary if self.proxied.respond_to?(:tasks_summary)) || self.proxied[:tasks_summary]
+    get(:tasks_summary)
   end
 
   def title
diff --git a/apps/workbench/app/models/pipeline_instance_work_unit.rb b/apps/workbench/app/models/pipeline_instance_work_unit.rb
index 9d6db39..578e193 100644
--- a/apps/workbench/app/models/pipeline_instance_work_unit.rb
+++ b/apps/workbench/app/models/pipeline_instance_work_unit.rb
@@ -8,7 +8,7 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
       jobs[j.uuid] = j
     end
 
-    components = (self.proxied.components if self.proxied.respond_to?(:components)) || self.proxied[:components]
+    components = get(:components)
     components.each do |name, c|
       if c.is_a?(Hash)
         job = c[:job]
@@ -22,6 +22,7 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
           items << ProxyWorkUnit.new(c, name)
         end
       else
+        self.unreadable_children = true
         break
       end
     end
@@ -30,7 +31,7 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
   end
 
   def progress
-    state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+    state = get(:state)
     if state == 'Complete'
       return 1.0
     end
@@ -56,12 +57,8 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
     end
   end
 
-  def can_cancel?
-    true
-  end
-
   def uri
-    uuid = (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
+    uuid = get(:uuid)
     "/pipeline_instances/#{uuid}"
   end
 
diff --git a/apps/workbench/app/models/proxy_work_unit.rb b/apps/workbench/app/models/proxy_work_unit.rb
index cba57d0..52c8447 100644
--- a/apps/workbench/app/models/proxy_work_unit.rb
+++ b/apps/workbench/app/models/proxy_work_unit.rb
@@ -3,6 +3,7 @@ class ProxyWorkUnit < WorkUnit
 
   attr_accessor :lbl
   attr_accessor :proxied
+  attr_accessor :unreadable_children
 
   def initialize proxied, label
     self.lbl = label
@@ -14,30 +15,42 @@ class ProxyWorkUnit < WorkUnit
   end
 
   def uuid
-    (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
+    get(:uuid)
   end
 
   def modified_by_user_uuid
-    (self.proxied.modified_by_user_uuid if self.proxied.respond_to?(:modified_by_user_uuid)) || self.proxied[:modified_by_user_uuid]
+    get(:modified_by_user_uuid)
   end
 
   def created_at
-    t= (self.proxied.created_at if self.proxied.respond_to?(:created_at)) || self.proxied[:created_at]
-    t.to_datetime if t
+    t = get(:created_at)
+    if t.andand.class == String
+      Time.parse t
+    else
+      t
+    end
   end
 
   def started_at
-    t = (self.proxied.started_at if self.proxied.respond_to?(:started_at)) || self.proxied[:started_at]
-    t.to_datetime if t
+    t = get(:started_at)
+    if t.andand.class == String
+      Time.parse t
+    else
+      t
+    end
   end
 
   def finished_at
-    t = (self.proxied.finished_at if self.proxied.respond_to?(:finished_at)) || self.proxied[:finished_at]
-    t.to_datetime if t
+    t = get(:finished_at)
+    if t.andand.class == String
+      Time.parse t
+    else
+      t
+    end
   end
 
   def state_label
-    state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+    state = get(:state)
     if ["Running", "RunningOnServer", "RunningOnClient"].include? state
       "Running"
     else
@@ -46,7 +59,7 @@ class ProxyWorkUnit < WorkUnit
   end
 
   def state_bootstrap_class
-    state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+    state = get(:state)
     case state
     when 'Complete'
       'success'
@@ -60,7 +73,7 @@ class ProxyWorkUnit < WorkUnit
   end
 
   def success?
-    state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+    state = get(:state)
     if state == 'Complete'
       true
     elsif state == 'Failed'
@@ -71,27 +84,27 @@ class ProxyWorkUnit < WorkUnit
   end
 
   def parameters
-    (self.proxied.script_parameters if self.proxied.respond_to?(:script_parameters)) || self.proxied[:script_parameters]
+    get(:script_parameters)
   end
 
   def repository
-    (self.proxied.repository if self.proxied.respond_to?(:repository)) || self.proxied[:repository]
+    get(:repository)
   end
 
   def script
-    (self.proxied.script if self.proxied.respond_to?(:script)) || self.proxied[:script]
+    get(:script)
   end
 
   def script_version
-    (self.proxied.send(:script_version) if self.proxied.respond_to?(:script_version)) || self.proxied[:script_version]
+    get(:script_version)
   end
 
   def supplied_script_version
-    (self.proxied.supplied_script_version if self.proxied.respond_to?(:supplied_script_version)) || self.proxied[:supplied_script_version]
+    get(:supplied_script_version)
   end
 
   def runtime_constraints
-    (self.proxied.runtime_constraints if self.proxied.respond_to?(:runtime_constraints)) || self.proxied[:runtime_constraints]
+    get(:runtime_constraints)
   end
 
   def children
@@ -101,4 +114,18 @@ class ProxyWorkUnit < WorkUnit
   def title
     "work unit"
   end
+
+  def has_unreadable_children
+    self.unreadable_children
+  end
+
+  protected
+
+  def get key
+    if self.proxied.respond_to? key
+      self.proxied.send(key)
+    elsif self.proxied.is_a?(Hash)
+      self.proxied[key]
+    end
+  end
 end
diff --git a/apps/workbench/app/models/work_unit.rb b/apps/workbench/app/models/work_unit.rb
index 4353352..aea0f12 100644
--- a/apps/workbench/app/models/work_unit.rb
+++ b/apps/workbench/app/models/work_unit.rb
@@ -107,4 +107,8 @@ class WorkUnit
   def title
     # title for the work unit
   end
+
+  def has_unreadable_children
+    # accept it if you can't understand your own children
+  end
 end
diff --git a/apps/workbench/app/views/pipeline_instances/_show_components_json.html.erb b/apps/workbench/app/views/pipeline_instances/_show_components_json.html.erb
index 9d1edbf..6486f73 100644
--- a/apps/workbench/app/views/pipeline_instances/_show_components_json.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/_show_components_json.html.erb
@@ -15,6 +15,7 @@
           <pre><%= Oj.dump(@object.components, indent: 2) %></pre>
         </div>
       </div>
+      <% if backtrace %>
       <div class="panel-heading">
         <h4 class="panel-title">
           <a data-toggle="collapse" data-parent="#components-accordion" href="#components-backtrace">
@@ -27,4 +28,5 @@
           <pre><%= backtrace %></pre>
         </div>
       </div>
+      <% end %>
     </div>
diff --git a/apps/workbench/app/views/work_unit/_progress.html.erb b/apps/workbench/app/views/work_unit/_progress.html.erb
new file mode 100644
index 0000000..caee251
--- /dev/null
+++ b/apps/workbench/app/views/work_unit/_progress.html.erb
@@ -0,0 +1,7 @@
+<% if wu.state_label == 'Running' %>
+  <div class="progress" style="margin-bottom: 0px">
+    <span class="progress-bar progress-bar-<%= wu.state_bootstrap_class %>" style="width: <%= wu.progress*100 %>%;"></span>
+  </div>
+<% else %>
+  <span class="label label-<%= wu.state_bootstrap_class %>"><%= wu.state_label%></span>
+<% end %>
diff --git a/apps/workbench/app/views/work_unit/_show_child.html.erb b/apps/workbench/app/views/work_unit/_show_child.html.erb
index 7478d22..a38d900 100644
--- a/apps/workbench/app/views/work_unit/_show_child.html.erb
+++ b/apps/workbench/app/views/work_unit/_show_child.html.erb
@@ -13,7 +13,7 @@
 
         <%# column offset 2 %>
         <div class="col-md-2 pipeline-instance-spacing">
-          <span class="label label-<%= current_obj.state_bootstrap_class %>"><%= current_obj.progress%></span>
+          <%= render partial: 'work_unit/progress', locals: {wu: current_obj} %>
         </div>
 
         <%# column offset 4 %>
diff --git a/apps/workbench/app/views/work_unit/_show_component.html.erb b/apps/workbench/app/views/work_unit/_show_component.html.erb
index 6bd6f02..a42c3c0 100644
--- a/apps/workbench/app/views/work_unit/_show_component.html.erb
+++ b/apps/workbench/app/views/work_unit/_show_component.html.erb
@@ -1,84 +1,100 @@
 <%# Work unit status %>
 
-<% if wu.state_label %>
-  <div class="pull-right" style="padding-left: 1em">
-    Current state: <span class="badge badge-<%= wu.state_bootstrap_class %>" data-wu-state="<%= wu.state_label %>">
-      <% if wu.state_label == "running" %>
-        Active
-      <% else %>
-        <%= wu.state_label %>
-      <% end %>
-    </span> 
-  </div>
-<% end %>
+<div class="container-fluid>
+  <div class="row-fluid">
+    <%# Need additional handling for main object display  %>
+    <% if @object.uuid == wu.uuid %>
+      <div class="col-md-2 pull-right">
+        <div class="container-fluid">
+          <div class="row-fluid">
+            <%# column offset 0 %>
+            <% if wu.state_label.in? ["Queued", "Running"] and wu.can_cancel? and @object.editable? %>
+                <div class="col-md-1">
+                  <%= form_tag "#{wu.uri}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
+                    <%= hidden_field_tag :return_to, url_for(@object) %>
+                    <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-job-button"} %>
+                  <% end %>
+                </div>
+            <% end %>
+            <%# column offset 1 %>
+            <div class="pull-right col-md-5 pipeline-instance-spacing">
+              <%= render partial: 'work_unit/progress', locals: {wu: wu} %>
+            </div>
+          </div>
+        </div>
+      </div>
+    <% end %>
 
-<% if wu.state_label == 'Paused' %>
-  <p>
-    This <%= wu.title %> is paused. Children that are
-    already running will continue to run, but no new work units will be submitted.
-  </p>
-<% end %>
+    <div class="col-md-10" >
+      <% if wu.state_label == 'Paused' %>
+        <p>
+          This <%= wu.title %> is paused. Children that are
+          already running will continue to run, but no new work units will be submitted.
+        </p>
+      <% end %>
 
-<% runningtime = determine_wallclock_runtime(wu.children) %>
+      <% runningtime = determine_wallclock_runtime(wu.children) %>
 
-<p>
-  <% if wu.started_at %>
-    This <%= wu.title %> started at <%= render_localized_date(wu.started_at) %>.
-    It
-    <% if wu.state_label == 'Complete' %>
-      completed in
-    <% elsif wu.state_label == 'Failed' %>
-      failed after
-    <% else %>
-      has been active for
-    <% end %>
+      <p>
+        <% if wu.started_at %>
+          This <%= wu.title %> started at <%= render_localized_date(wu.started_at) %>.
+          It
+          <% if wu.state_label == 'Complete' %>
+            completed in
+          <% elsif wu.state_label == 'Failed' %>
+            failed after
+          <% else %>
+            has been active for
+          <% end %>
 
-    <% walltime = if wu.finished_at then
-                    wu.finished_at - wu.started_at
-                  else
-                    Time.now - wu.started_at
-                  end %>
+          <% walltime = if wu.finished_at then
+                          wu.finished_at - wu.started_at
+                        else
+                          Time.now - wu.started_at
+                        end %>
 
-    <%= if walltime > runningtime
-          render_runtime(walltime, false)
-        else
-          render_runtime(runningtime, false)
-        end %><% if wu.finished_at %> at <%= render_localized_date(wu.finished_at) %><% end %>.
-  <% else %>
-    <% if wu.state_label %> This <%= wu.title %> is <%= if wu.state_label == 'Running' then 'active' else wu.state_label.downcase end %>. <% end %>
-      <% walltime = 0%>
-  <% end %>
+          <%= if walltime > runningtime
+                render_runtime(walltime, false)
+              else
+                render_runtime(runningtime, false)
+              end %><% if wu.finished_at %> at <%= render_localized_date(wu.finished_at) %><% end %>.
+        <% else %>
+          <% if wu.state_label %> This <%= wu.title %> is <%= if wu.state_label == 'Running' then 'active' else wu.state_label.downcase end %>. <% end %>
+            <% walltime = 0%>
+        <% end %>
 
-  <% if wu.state_label == 'Failed' %>
-    Check the Log tab for more detail about why it failed.
-  <% end %>
-</p>
+        <% if wu.state_label == 'Failed' %>
+          Check the Log tab for more detail about why it failed.
+        <% end %>
+      </p>
 
-<% if wu.state_label %>
-  <p>
-      It
-      <% if wu.state_label == 'Running' %>
-        has run
-      <% else %>
-        ran
-      <% end %>
-      for
-      <%
-          cputime = wu.children.map { |c|
-          if c.started_at
-            (c.runtime_constraints.andand[:min_nodes] || 1) * ((c.finished_at || Time.now()) - c.started_at)
-          else
-            0
-          end
-         }.reduce(:+) || 0 %>
-      <%= render_runtime(runningtime, false) %><% if (walltime - runningtime) > 0 %>
-        (<%= render_runtime(walltime - runningtime, false) %> queued)<% end %><% if cputime == 0 %>.<% else %>
-        and used
-      <%= render_runtime(cputime, false) %>
-      of node allocation time (<%= (cputime/runningtime).round(1) %>⨯ scaling).
+      <% if wu.state_label %>
+        <p>
+            It
+            <% if wu.state_label == 'Running' %>
+              has run
+            <% else %>
+              ran
+            <% end %>
+            for
+            <%
+                cputime = wu.children.map { |c|
+                if c.started_at
+                  (c.runtime_constraints.andand[:min_nodes] || 1) * ((c.finished_at || Time.now()) - c.started_at)
+                else
+                  0
+                end
+               }.reduce(:+) || 0 %>
+            <%= render_runtime(runningtime, false) %><% if (walltime - runningtime) > 0 %>
+              (<%= render_runtime(walltime - runningtime, false) %> queued)<% end %><% if cputime == 0 %>.<% else %>
+              and used
+            <%= render_runtime(cputime, false) %>
+            of node allocation time (<%= (cputime/runningtime).round(1) %>⨯ scaling).
+            <% end %>
+        </p>
       <% end %>
-  </p>
-<% end %>
+    </div>
+  </div>
 
 <p>
   <%= render(partial: 'work_unit/component_detail', locals: {current_obj: wu}) %>
@@ -101,9 +117,13 @@
   preload_for_pdhs collections_pdhs if collections_pdhs.any?
 %>
 
-<% @descendent_count = 0 if !@descendent_count %>
-
-<% wu.children.each_with_index do |c, i| %>
-  <% @descendent_count += 1 %>
-  <%= render(partial: 'work_unit/show_child', locals: {current_obj: c, i: @descendent_count, expanded: false}) %>
+<% if wu.has_unreadable_children %>
+  <%= render(partial: "pipeline_instances/show_components_json",
+             locals: {error_name: "Unreadable components", backtrace: nil, wu: wu}) %>
+<% else %>
+  <% @descendent_count = 0 if !@descendent_count %>
+  <% wu.children.each_with_index do |c, i| %>
+    <% @descendent_count += 1 %>
+    <%= render(partial: 'work_unit/show_child', locals: {current_obj: c, i: @descendent_count, expanded: false}) %>
+  <% end %>
 <% end %>
diff --git a/apps/workbench/test/integration/jobs_test.rb b/apps/workbench/test/integration/jobs_test.rb
index 0c407b3..350e732 100644
--- a/apps/workbench/test/integration/jobs_test.rb
+++ b/apps/workbench/test/integration/jobs_test.rb
@@ -101,7 +101,7 @@ class JobsTest < ActionDispatch::IntegrationTest
       if expect_options
         assert_text 'supplied_script_version: master'
       else
-        assert_text 'supplied_script_version: (none)'
+        assert_no_text 'supplied_script_version: (none)'
       end
 
       assert_triggers_dom_event 'shown.bs.modal' do

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list