[ARVADOS] updated: a4f061a5bf48f0335238da72b8d03ca349fa7553

Git user git at public.curoverse.com
Mon May 23 16:56:44 EDT 2016


Summary of changes:
 .../app/helpers/pipeline_instances_helper.rb       |   1 -
 apps/workbench/app/models/job_work_unit.rb         |  38 +++++---
 .../app/models/pipeline_instance_work_unit.rb      |  28 +++++-
 apps/workbench/app/models/proxy_work_unit.rb       |  48 ++++++----
 apps/workbench/app/models/work_unit.rb             |  16 ++++
 .../app/views/work_unit/_component_detail.html.erb |   5 +-
 .../app/views/work_unit/_show_child.html.erb       |  26 +++---
 .../app/views/work_unit/_show_component.html.erb   | 100 +++++++++++----------
 8 files changed, 167 insertions(+), 95 deletions(-)

       via  a4f061a5bf48f0335238da72b8d03ca349fa7553 (commit)
      from  2d7b22fd7d905e4fa44452775d9db6a06a50da8c (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 a4f061a5bf48f0335238da72b8d03ca349fa7553
Author: radhika <radhika at curoverse.com>
Date:   Mon May 23 16:56:24 2016 -0400

    8876: work unit views

diff --git a/apps/workbench/app/helpers/pipeline_instances_helper.rb b/apps/workbench/app/helpers/pipeline_instances_helper.rb
index b2486c1..c025e2d 100644
--- a/apps/workbench/app/helpers/pipeline_instances_helper.rb
+++ b/apps/workbench/app/helpers/pipeline_instances_helper.rb
@@ -69,7 +69,6 @@ module PipelineInstancesHelper
   def determine_wallclock_runtime jobs
     timestamps = []
     jobs.each do |j|
-      insert_at = 0
       started_at = j.started_at
       finished_at = (if j.finished_at then j.finished_at else Time.now end)
       if started_at
diff --git a/apps/workbench/app/models/job_work_unit.rb b/apps/workbench/app/models/job_work_unit.rb
index 8246e8a..6bef50f 100644
--- a/apps/workbench/app/models/job_work_unit.rb
+++ b/apps/workbench/app/models/job_work_unit.rb
@@ -1,7 +1,8 @@
 class JobWorkUnit < ProxyWorkUnit
   def children
     # Job tasks
-    tasks = JobTask.filter([['job_uuid', '=', self.proxied.uuid]]).results
+    uuid = (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
+    tasks = JobTask.filter([['job_uuid', '=', uuid]]).results
     items = []
     tasks.each do |t|
       items << t.work_unit("task #{items.size}")
@@ -13,14 +14,16 @@ class JobWorkUnit < ProxyWorkUnit
   end
 
   def progress
-    if self.proxied.state == 'Complete'
+    state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+    if state == 'Complete'
       return 1.0
     end
 
-    failed = self.proxied.tasks_summary[:failed] || 0 rescue 0
-    done = self.proxied.tasks_summary[:done] || 0 rescue 0
-    running = self.proxied.tasks_summary[:running] || 0 rescue 0
-    todo = self.proxied.tasks_summary[:todo] || 0 rescue 0
+    tasks_summary = (self.proxied.tasks_summary if self.proxied.respond_to?(:tasks_summary)) || self.proxied[:tasks_summary]
+    failed = tasks_summary[:failed] || 0 rescue 0
+    done = tasks_summary[:done] || 0 rescue 0
+    running = tasks_summary[:running] || 0 rescue 0
+    todo = tasks_summary[:todo] || 0 rescue 0
     if done + running + failed + todo > 0
       total_tasks = done + running + failed + todo
       (done+failed).to_f / total_tasks
@@ -30,22 +33,35 @@ class JobWorkUnit < ProxyWorkUnit
   end
 
   def docker_image
-    self.proxied[:docker_image_locator]
+    (self.proxied.docker_image_locator if self.proxied.respond_to?(:docker_image_locator)) || self.proxied[:docker_image_locator]
   end
 
   def nondeterministic
-    self.proxied[:nondeterministic]
+    (self.proxied.nondeterministic if self.proxied.respond_to?(:nondeterministic)) || self.proxied[:nondeterministic]
   end
 
   def priority
-    self.proxied[:priority]
+    (self.proxied.priority if self.proxied.respond_to?(:priority)) || self.proxied[:priority]
   end
 
   def log_collection
-    self.proxied.log
+    (self.proxied.log if self.proxied.respond_to?(:log)) || self.proxied[:log]
   end
 
   def output
-    self.proxied.output
+    (self.proxied.output if self.proxied.respond_to?(:output)) || self.proxied[:output]
+  end
+
+  def uri
+    uuid = (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
+    "/jobs/#{uuid}"
+  end
+
+  def child_summary
+    (self.proxied.tasks_summary if self.proxied.respond_to?(:tasks_summary)) || self.proxied[:tasks_summary]
+  end
+
+  def title
+    "job"
   end
 end
diff --git a/apps/workbench/app/models/pipeline_instance_work_unit.rb b/apps/workbench/app/models/pipeline_instance_work_unit.rb
index 94990ee..9d6db39 100644
--- a/apps/workbench/app/models/pipeline_instance_work_unit.rb
+++ b/apps/workbench/app/models/pipeline_instance_work_unit.rb
@@ -8,15 +8,21 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
       jobs[j.uuid] = j
     end
 
-    components = self.proxied.components
+    components = (self.proxied.components if self.proxied.respond_to?(:components)) || self.proxied[:components]
     components.each do |name, c|
       if c.is_a?(Hash)
         job = c[:job]
-        if job and job[:uuid] and jobs[job[:uuid]]
-          items << jobs[job[:uuid]].work_unit(name)
+        if job
+          if job[:uuid] and jobs[job[:uuid]]
+            items << jobs[job[:uuid]].work_unit(name)
+          else
+            items << JobWorkUnit.new(job, name)
+          end
         else
           items << ProxyWorkUnit.new(c, name)
         end
+      else
+        break
       end
     end
 
@@ -24,7 +30,8 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
   end
 
   def progress
-    if self.proxied.state == 'Complete'
+    state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+    if state == 'Complete'
       return 1.0
     end
 
@@ -48,4 +55,17 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
       0.0
     end
   end
+
+  def can_cancel?
+    true
+  end
+
+  def uri
+    uuid = (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
+    "/pipeline_instances/#{uuid}"
+  end
+
+  def title
+    "pipeline"
+  end
 end
diff --git a/apps/workbench/app/models/proxy_work_unit.rb b/apps/workbench/app/models/proxy_work_unit.rb
index e780678..cba57d0 100644
--- a/apps/workbench/app/models/proxy_work_unit.rb
+++ b/apps/workbench/app/models/proxy_work_unit.rb
@@ -1,4 +1,6 @@
 class ProxyWorkUnit < WorkUnit
+  require 'time'
+
   attr_accessor :lbl
   attr_accessor :proxied
 
@@ -12,35 +14,40 @@ class ProxyWorkUnit < WorkUnit
   end
 
   def uuid
-    self.proxied[:uuid]
+    (self.proxied.uuid if self.proxied.respond_to?(:uuid)) || self.proxied[:uuid]
   end
 
   def modified_by_user_uuid
-    self.proxied[: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]
   end
 
   def created_at
-    self.proxied[:created_at]
+    t= (self.proxied.created_at if self.proxied.respond_to?(:created_at)) || self.proxied[:created_at]
+    t.to_datetime if t
   end
 
   def started_at
-    self.proxied[:started_at]
+    t = (self.proxied.started_at if self.proxied.respond_to?(:started_at)) || self.proxied[:started_at]
+    t.to_datetime if t
   end
 
   def finished_at
-    self.proxied[:finished_at]
+    t = (self.proxied.finished_at if self.proxied.respond_to?(:finished_at)) || self.proxied[:finished_at]
+    t.to_datetime if t
   end
 
   def state_label
-    if ["Running", "RunningOnServer", "RunningOnClient"].include? self.proxied[:state].to_s
+    state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+    if ["Running", "RunningOnServer", "RunningOnClient"].include? state
       "Running"
     else
-      self.proxied[:state].to_s
+      state
     end
   end
 
   def state_bootstrap_class
-    case self.proxied[:state]
+    state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+    case state
     when 'Complete'
       'success'
     when 'Failed', 'Cancelled'
@@ -53,9 +60,10 @@ class ProxyWorkUnit < WorkUnit
   end
 
   def success?
-    if self.proxied[:state] == 'Complete'
+    state = (self.proxied.state if self.proxied.respond_to?(:state)) || self.proxied[:state]
+    if state == 'Complete'
       true
-    elsif self.proxied[:state] == 'Failed'
+    elsif state == 'Failed'
       false
     else
       nil
@@ -63,30 +71,34 @@ class ProxyWorkUnit < WorkUnit
   end
 
   def parameters
-    self.proxied[:script_parameters]
+    (self.proxied.script_parameters if self.proxied.respond_to?(:script_parameters)) || self.proxied[:script_parameters]
   end
 
-  def script
-    self.proxied[:script]
+  def repository
+    (self.proxied.repository if self.proxied.respond_to?(:repository)) || self.proxied[:repository]
   end
 
-  def repository
-    self.proxied[:repository]
+  def script
+    (self.proxied.script if self.proxied.respond_to?(:script)) || self.proxied[:script]
   end
 
   def script_version
-    self.proxied[:script_version]
+    (self.proxied.send(:script_version) if self.proxied.respond_to?(:script_version)) || self.proxied[:script_version]
   end
 
   def supplied_script_version
-    self.proxied[:supplied_script_version]
+    (self.proxied.supplied_script_version if self.proxied.respond_to?(:supplied_script_version)) || self.proxied[:supplied_script_version]
   end
 
   def runtime_constraints
-    self.proxied[:runtime_constraints]
+    (self.proxied.runtime_constraints if self.proxied.respond_to?(:runtime_constraints)) || self.proxied[:runtime_constraints]
   end
 
   def children
     []
   end
+
+  def title
+    "work unit"
+  end
 end
diff --git a/apps/workbench/app/models/work_unit.rb b/apps/workbench/app/models/work_unit.rb
index 4185519..4353352 100644
--- a/apps/workbench/app/models/work_unit.rb
+++ b/apps/workbench/app/models/work_unit.rb
@@ -91,4 +91,20 @@ class WorkUnit
   def output
     # returns uuid or pdh of output data, if any
   end
+
+  def can_cancel?
+    # returns if this work unit is cancelable
+  end
+
+  def uri
+    # returns the uri for this work unit
+  end
+
+  def child_summary
+    # summary status of any children of this work unit
+  end
+
+  def title
+    # title for the work unit
+  end
 end
diff --git a/apps/workbench/app/views/work_unit/_component_detail.html.erb b/apps/workbench/app/views/work_unit/_component_detail.html.erb
index 13b942e..0d2f800 100644
--- a/apps/workbench/app/views/work_unit/_component_detail.html.erb
+++ b/apps/workbench/app/views/work_unit/_component_detail.html.erb
@@ -2,7 +2,7 @@
         <div class="row">
           <div class="col-md-5">
             <table>
-              <% [:uuid, :modified_by_user_uuid, :created_at, :started_at, :finished_at, :priority].each do |k| %>
+              <% [:uuid, :modified_by_user_uuid, :created_at, :started_at, :finished_at, :output, :priority].each do |k| %>
                 <% val = current_obj.send(k) if current_obj.respond_to?(k) %>
                 <% unless val.nil? %>
                 <tr>
@@ -16,6 +16,8 @@
                       <%= link_to_arvados_object_if_readable(val, val, friendly_name: true) %>
                     <% elsif k.to_s.end_with? '_at' %>
                       <%= render_localized_date(val) %>
+                    <% elsif k == :output %>
+                      <%= link_to_arvados_object_if_readable(val, 'Output data not available', friendly_name: true) %>
                     <% else %>
                       <%= val %>
                     <% end %>
@@ -79,6 +81,7 @@
             </table>
           </div>
         </div>
+
         <% unless current_obj.parameters.nil? %>
         <div class="row">
           <div class="col-md-6">
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 dc88a21..7478d22 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">
-          <%= current_obj.progress %>
+          <span class="label label-<%= current_obj.state_bootstrap_class %>"><%= current_obj.progress%></span>
         </div>
 
         <%# column offset 4 %>
@@ -60,15 +60,17 @@
               Queued for <%= render_runtime(queuetime, false) %>.
             </div>
           <% elsif current_obj.state_label == "Running" %>
-            <%# column offset 8 %>
-            <div class="col-md-3">
-              <span class="task-summary-status">
-                <%= current_obj.tasks_summary[:done] %> <%= "task".pluralize(current_obj.tasks_summary[:done]) %> done,
-                <%= current_obj.tasks_summary[:failed] %> failed,
-                <%= current_obj.tasks_summary[:running] %> running,
-                <%= current_obj.tasks_summary[:todo] %> pending
-              </span>
-            </div>
+            <% if current_obj.child_summary %>
+              <%# column offset 8 %>
+              <div class="col-md-3">
+                <span class="task-summary-status">
+                  <%= current_obj.child_summary[:done] %> <%= "task".pluralize(current_obj.child_summary[:done]) %> done,
+                  <%= current_obj.child_summary[:failed] %> failed,
+                  <%= current_obj.child_summary[:running] %> running,
+                  <%= current_obj.child_summary[:todo] %> pending
+                </span>
+              </div>
+            <% end %>
           <% elsif current_obj.state_label.in? ["Complete", "Failed", "Cancelled"] %>
             <%# column offset 8 %>
             <div class="col-md-4 text-overflow-ellipsis">
@@ -82,10 +84,10 @@
             </div>
           <% end %>
 
-          <% if current_obj.state_label.in? ["Queued", "Running"] and @object.editable? %>
+          <% if current_obj.state_label.in? ["Queued", "Running"] and @object.work_unit(@object.name).can_cancel? and @object.editable? %>
             <%# column offset 11 %>
             <div class="col-md-1 pipeline-instance-spacing">
-              <%= form_tag "/jobs/#{current_obj.uuid}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
+              <%= form_tag "#{current_obj.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 %>
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 cea3395..6bd6f02 100644
--- a/apps/workbench/app/views/work_unit/_show_component.html.erb
+++ b/apps/workbench/app/views/work_unit/_show_component.html.erb
@@ -1,18 +1,20 @@
 <%# Work unit status %>
 
-<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>
+<% 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 %>
 
 <% if wu.state_label == 'Paused' %>
   <p>
-    This work unit is paused. Work unit children that are
+    This <%= wu.title %> is paused. Children that are
     already running will continue to run, but no new work units will be submitted.
   </p>
 <% end %>
@@ -21,7 +23,7 @@
 
 <p>
   <% if wu.started_at %>
-    This work unit started at <%= render_localized_date(wu.started_at) %>.
+    This <%= wu.title %> started at <%= render_localized_date(wu.started_at) %>.
     It
     <% if wu.state_label == 'Complete' %>
       completed in
@@ -42,39 +44,41 @@
         else
           render_runtime(runningtime, false)
         end %><% if wu.finished_at %> at <%= render_localized_date(wu.finished_at) %><% end %>.
-    <% else %>
-      It is <%= if wu.state_label == 'Running' then 'active' else wu.state.downcase end %>.
-        <% walltime = 0%>
-    <% 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>
 
-<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>
+<% 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>
   <%= render(partial: 'work_unit/component_detail', locals: {current_obj: wu}) %>
@@ -83,18 +87,18 @@
 <%# Work unit children %>
 
 <%
-  job_uuids = wu.children.collect {|c| c.uuid}.compact
-  if job_uuids.any?
-    resource_class = resource_class_for_uuid(job_uuids.first, friendly_name: true)
-    preload_objects_for_dataclass resource_class, job_uuids
+  uuids = wu.children.collect {|c| c.uuid}.compact
+  if uuids.any?
+    resource_class = resource_class_for_uuid(uuids.first, friendly_name: true)
+    preload_objects_for_dataclass resource_class, uuids
   end
 
-  job_collections = wu.children.collect {|j| j.output}.compact
-  job_collections.concat wu.children.collect {|j| j.docker_image}.uniq.compact
-  job_collections_pdhs = job_collections.select {|x| !(m = CollectionsHelper.match(x)).nil?}.uniq.compact
-  job_collections_uuids = job_collections - job_collections_pdhs
-  preload_collections_for_objects job_collections_uuids if job_collections_uuids.any?
-  preload_for_pdhs job_collections_pdhs if job_collections_pdhs.any?
+  collections = wu.children.collect {|j| j.output}.compact
+  collections.concat wu.children.collect {|j| j.docker_image}.uniq.compact
+  collections_pdhs = collections.select {|x| !(m = CollectionsHelper.match(x)).nil?}.uniq.compact
+  collections_uuids = collections - collections_pdhs
+  preload_collections_for_objects collections_uuids if collections_uuids.any?
+  preload_for_pdhs collections_pdhs if collections_pdhs.any?
 %>
 
 <% @descendent_count = 0 if !@descendent_count %>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list