[ARVADOS] updated: c400bf1e7a52d5557c2031bdf2c8de9957425577

Git user git at public.curoverse.com
Mon Jun 6 20:29:08 EDT 2016


Summary of changes:
 apps/workbench/app/helpers/application_helper.rb   |   4 +
 apps/workbench/app/models/job_work_unit.rb         |  50 ++++++-
 .../app/models/pipeline_instance_work_unit.rb      |  10 +-
 apps/workbench/app/models/proxy_work_unit.rb       | 152 +++++++++++++--------
 apps/workbench/app/models/work_unit.rb             |   4 -
 .../app/views/work_unit/_show_child.html.erb       |  22 +--
 .../app/views/work_unit/_show_component.html.erb   |  59 +-------
 7 files changed, 164 insertions(+), 137 deletions(-)

       via  c400bf1e7a52d5557c2031bdf2c8de9957425577 (commit)
      from  aface0b74e6b3cfaaa8d773218a5ada423a7654b (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 c400bf1e7a52d5557c2031bdf2c8de9957425577
Author: radhika <radhika at curoverse.com>
Date:   Mon Jun 6 20:28:21 2016 -0400

    8876: Use JobWorkUnit for pipeline components and cleanup.

diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index 14b1c34..a37ecda 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -498,6 +498,10 @@ module ApplicationHelper
     raw("<span class='utc-date' data-utc-date='#{date}' data-utc-date-opts='noseconds'>#{date}</span>")
   end
 
+  def render_time duration, use_words, round_to_min=true
+    render_runtime duration, use_words, round_to_min
+  end
+
 private
   def is_textile?( object, attr )
     is_textile = object.textile_attributes.andand.include?(attr)
diff --git a/apps/workbench/app/models/job_work_unit.rb b/apps/workbench/app/models/job_work_unit.rb
index 49f490d..a0a7c87 100644
--- a/apps/workbench/app/models/job_work_unit.rb
+++ b/apps/workbench/app/models/job_work_unit.rb
@@ -1,6 +1,6 @@
 class JobWorkUnit < ProxyWorkUnit
   def children
-    return self.my_children if self.my_children
+    return @my_children if @my_children
 
     # Jobs components
     items = []
@@ -20,7 +20,7 @@ class JobWorkUnit < ProxyWorkUnit
       end
     end
 
-    self.my_children = items
+    @my_children = items
   end
 
   def child_summary
@@ -31,8 +31,52 @@ class JobWorkUnit < ProxyWorkUnit
     end
   end
 
+  def parameters
+    get(:script_parameters)
+  end
+
+  def repository
+    get(:repository)
+  end
+
+  def script
+    get(:script)
+  end
+
+  def script_version
+    get(:script_version)
+  end
+
+  def supplied_script_version
+    get(:supplied_script_version)
+  end
+
+  def docker_image
+    get(:docker_image_locator)
+  end
+
+  def nondeterministic
+    get(:nondeterministic)
+  end
+
+  def runtime_constraints
+    get(:runtime_constraints)
+  end
+
+  def priority
+    get(:priority)
+  end
+
+  def log_collection
+    get(:log)
+  end
+
+  def output
+    get(:output)
+  end
+
   def can_cancel?
-    true
+    state_label.in? ["Queued", "Running"]
   end
 
   def uri
diff --git a/apps/workbench/app/models/pipeline_instance_work_unit.rb b/apps/workbench/app/models/pipeline_instance_work_unit.rb
index 8285424..bc2b3e7 100644
--- a/apps/workbench/app/models/pipeline_instance_work_unit.rb
+++ b/apps/workbench/app/models/pipeline_instance_work_unit.rb
@@ -1,11 +1,11 @@
 class PipelineInstanceWorkUnit < ProxyWorkUnit
   def children
-    return self.my_children if self.my_children
+    return @my_children if @my_children
 
     items = []
 
     jobs = {}
-    results = Job.where(uuid: self.proxied.job_ids.values).results
+    results = Job.where(uuid: @proxied.job_ids.values).results
     results.each do |j|
       jobs[j.uuid] = j
     end
@@ -21,15 +21,15 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
             items << JobWorkUnit.new(job, name)
           end
         else
-          items << ProxyWorkUnit.new(c, name)
+          items << JobWorkUnit.new(c, name)
         end
       else
-        self.unreadable_children = true
+        @unreadable_children = true
         break
       end
     end
 
-    self.my_children = items
+    @my_children = items
   end
 
   def uri
diff --git a/apps/workbench/app/models/proxy_work_unit.rb b/apps/workbench/app/models/proxy_work_unit.rb
index 231145a..0342a40 100644
--- a/apps/workbench/app/models/proxy_work_unit.rb
+++ b/apps/workbench/app/models/proxy_work_unit.rb
@@ -7,12 +7,12 @@ class ProxyWorkUnit < WorkUnit
   attr_accessor :unreadable_children
 
   def initialize proxied, label
-    self.lbl = label
-    self.proxied = proxied
+    @lbl = label
+    @proxied = proxied
   end
 
   def label
-    self.lbl
+    @lbl
   end
 
   def uuid
@@ -145,50 +145,6 @@ class ProxyWorkUnit < WorkUnit
     end
   end
 
-  def parameters
-    get(:script_parameters)
-  end
-
-  def repository
-    get(:repository)
-  end
-
-  def script
-    get(:script)
-  end
-
-  def script_version
-    get(:script_version)
-  end
-
-  def supplied_script_version
-    get(:supplied_script_version)
-  end
-
-  def docker_image
-    get(:docker_image_locator)
-  end
-
-  def nondeterministic
-    get(:nondeterministic)
-  end
-
-  def runtime_constraints
-    get(:runtime_constraints)
-  end
-
-  def priority
-    get(:priority)
-  end
-
-  def log_collection
-    get(:log)
-  end
-
-  def output
-    get(:output)
-  end
-
   def children
     []
   end
@@ -198,7 +154,7 @@ class ProxyWorkUnit < WorkUnit
   end
 
   def has_unreadable_children
-    self.unreadable_children
+    @unreadable_children
   end
 
   def readable?
@@ -237,8 +193,7 @@ class ProxyWorkUnit < WorkUnit
   def cputime
     if state_label != "Queued"
       if started_at
-        (runtime_constraints.andand[:min_nodes] || 1) *
-             ((finished_at || Time.now()) - started_at)
+        (runtime_constraints.andand[:min_nodes] || 1) * ((finished_at || Time.now()) - started_at)
       end
     end
   end
@@ -273,10 +228,6 @@ class ProxyWorkUnit < WorkUnit
     state_label == 'Failed'
   end
 
-  def can_be_canceled?
-    state_label.in? ["Queued", "Running"] and can_cancel?
-  end
-
   def ran_for_str
     ran_for = nil
     if state_label
@@ -308,13 +259,98 @@ class ProxyWorkUnit < WorkUnit
     end
   end
 
+  def show_runtime
+    runningtime = ApplicationController.helpers.determine_wallclock_runtime(children)
+
+    walltime = 0
+    if started_at
+      walltime = if finished_at then (finished_at - started_at) else (Time.now - started_at) end
+    end
+
+    resp = '<p>'
+
+    if started_at
+      resp << "This #{title} started at "
+      resp << ApplicationController.helpers.render_localized_date(started_at)
+      resp << ". It "
+      if state_label == 'Complete'
+        resp << "completed in "
+      elsif state_label == 'Failed'
+         resp << "failed after "
+      else
+        resp << "has been active for "
+      end
+
+      if walltime > runningtime
+        resp << ApplicationController.helpers.render_time(walltime, false)
+      else
+       resp << ApplicationController.helpers.render_time(runningtime, false)
+      end
+
+      if finished_at
+        resp << " at "
+        resp << ApplicationController.helpers.render_localized_date(finished_at)
+      end
+      resp << "."
+    else
+      if state_label
+        resp << "This #{title} is "
+        resp << if state_label == 'Running' then 'active' else state_label.downcase end
+        resp << "."
+      end
+    end
+
+    if is_failed?
+      resp << " Check the Log tab for more detail about why it failed."
+    end
+    resp << "</p>"
+
+    resp << "<p>"
+    if state_label
+      resp << "It "
+      if state_label == 'Running'
+        resp << "has run"
+      else
+        resp << "ran"
+      end
+      resp << " for "
+
+      cpu_time = 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
+
+      resp << ApplicationController.helpers.render_time(runningtime, false)
+      if (walltime - runningtime) > 0
+        resp << "("
+        resp << ApplicationController.helpers.render_time(walltime - runningtime, false)
+        resp << "queued)"
+      end
+      if cpu_time == 0
+        resp << "."
+      else
+        resp << " and used "
+        resp << ApplicationController.helpers.render_time(cpu_time, false)
+        resp << " of node allocation time ("
+        resp << (cpu_time/runningtime).round(1).to_s
+        resp << "⨯ scaling)."
+      end
+    end
+    resp << "</p>"
+
+    resp
+  end
+
   protected
 
   def get key
-    if self.proxied.respond_to? key
-      self.proxied.send(key)
-    elsif self.proxied.is_a?(Hash)
-      self.proxied[key]
+    if @proxied.respond_to? key
+      @proxied.send(key)
+    elsif @proxied.is_a?(Hash)
+      @proxied[key]
     end
   end
 end
diff --git a/apps/workbench/app/models/work_unit.rb b/apps/workbench/app/models/work_unit.rb
index 5328953..b83847e 100644
--- a/apps/workbench/app/models/work_unit.rb
+++ b/apps/workbench/app/models/work_unit.rb
@@ -156,10 +156,6 @@ class WorkUnit
     # is this work unit in failed state?
   end
 
-  def can_be_canceled?
-    # true if work unit is in queued or running states and supports can_cancel?
-  end
-
   def ran_for_str
     # display string for how long it has run
   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 70e48cb..b9e758f 100644
--- a/apps/workbench/app/views/work_unit/_show_child.html.erb
+++ b/apps/workbench/app/views/work_unit/_show_child.html.erb
@@ -2,7 +2,6 @@
   <div class="panel-heading">
     <div class="container-fluid">
       <div class="row-fluid">
-        <%# column offset 0 %>
         <div class="col-md-2" style="word-break:break-all;">
           <h4 class="panel-title">
             <a data-toggle="collapse" href="#collapse<%= i %>">
@@ -11,12 +10,10 @@
           </h4>
         </div>
 
-        <%# column offset 2 %>
         <div class="col-md-2 pipeline-instance-spacing">
           <%= render partial: 'work_unit/progress', locals: {wu: current_obj} %>
         </div>
 
-        <%# column offset 4 %>
         <% if not current_obj %>
           <div class="col-md-8"></div>
         <% else %>
@@ -24,31 +21,27 @@
             <%= current_obj.link_to_log %>
           </div>
 
-          <%# column offset 5 %>
           <% walltime = current_obj.walltime %>
           <% cputime = current_obj.cputime %>
-          <% if walltime and cputime %>
           <div class="col-md-3">
-              <%= render_runtime(walltime, false) %>
-              <% if cputime > 0 %> / <%= render_runtime(cputime, false) %> (<%= (cputime/walltime).round(1) %>⨯)<% end %>
-          </div>
+          <% if walltime and cputime %>
+            <%= render_runtime(walltime, false) %>
+            <% if cputime > 0 %> / <%= render_runtime(cputime, false) %> (<%= (cputime/walltime).round(1) %>⨯)<% end %>
           <% end %>
+          </div>
 
           <% queuetime = current_obj.queuedtime %>
           <% if queuetime %>
-            <%# column offset 5 %>
             <div class="col-md-6">
               Queued for <%= render_runtime(queuetime, false) %>.
             </div>
           <% elsif current_obj.show_child_summary %>
-            <%# column offset 8 %>
             <div class="col-md-3">
               <span class="task-summary-status">
                 <%= current_obj.child_summary_str %>
               </span>
             </div>
           <% elsif current_obj.is_finished? %>
-            <%# column offset 8 %>
             <div class="col-md-4 text-overflow-ellipsis">
               <% if current_obj.output %>
                 <%= link_to_arvados_object_if_readable(current_obj.output, 'Output data not available', link_text: "Output of #{current_obj.label}") %>
@@ -58,15 +51,14 @@
             </div>
           <% end %>
 
-          <% if current_obj.can_be_canceled? and @object.editable? %>
-            <%# column offset 11 %>
-            <div class="col-md-1 pipeline-instance-spacing">
+          <div class="col-md-1 pipeline-instance-spacing">
+          <% if current_obj.can_cancel? and @object.editable? %>
               <%= 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-child-button"} %>
               <% end %>
-            </div>
           <% end %>
+          </div>
         <% end %>
       </div>
     </div>
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 9789934..58b8aa8 100644
--- a/apps/workbench/app/views/work_unit/_show_component.html.erb
+++ b/apps/workbench/app/views/work_unit/_show_component.html.erb
@@ -8,22 +8,22 @@
       <div class="pull-right">
         <div class="container-fluid">
           <div class="row-fulid pipeline-instance-spacing">
+            <div class="col-md-8">
             <% if wu.is_running? and wu.child_summary_str %>
-              <div class="col-md-8">
                 <%= wu.child_summary_str %>
-              </div>
             <% end %>
+            </div>
             <div class="col-md-3">
               <%= render partial: 'work_unit/progress', locals: {wu: wu} %>
             </div>
-            <% if wu.can_be_canceled? and @object.editable? %>
-                <div class="col-md-1">
+            <div class="col-md-1">
+              <% if wu.can_cancel? and @object.editable? %>
                   <%= 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-obj-button"} %>
                   <% end %>
-                </div>
-            <% end %>
+              <% end %>
+            </div>
           </div>
         </div>
       </div>
@@ -38,52 +38,7 @@
         </p>
       <% end %>
 
-      <% runningtime = determine_wallclock_runtime(wu.children) %>
-      <% walltime = 0 %>
-      <% if wu.started_at %>
-        <% walltime = if wu.finished_at then (wu.finished_at - wu.started_at) else (Time.now - wu.started_at) end %>
-      <% end %>
-
-      <p>
-        <% active_for_str = wu.started_and_active_for_str %>
-        <% if active_for_str %>
-          <%= active_for_str[0] %>
-          <%= render_localized_date(wu.started_at) %>.
-          <%= active_for_str[1] %>
-          <%= 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 %>
-        <% end %>
-
-        <% if wu.is_failed? %>
-          Check the Log tab for more detail about why it failed.
-        <% end %>
-      </p>
-
-      <% ran_for_str = wu.ran_for_str %>
-      <% if ran_for_str %>
-        <p>
-            <%= ran_for_str %>
-            <%
-                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 %>
+      <%= raw(wu.show_runtime) %>
     </div>
   </div>
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list