[ARVADOS] updated: 9f7e6c2782c1929de61ecd61e457700730ef9681

Git user git at public.curoverse.com
Wed Oct 12 11:24:09 EDT 2016


Summary of changes:
 .../app/controllers/application_controller.rb      | 32 +++++++++++++++++-----
 apps/workbench/app/helpers/application_helper.rb   |  6 +++-
 apps/workbench/app/models/proxy_work_unit.rb       | 25 -----------------
 apps/workbench/app/models/work_unit.rb             |  8 ------
 .../views/work_units/_component_detail.html.erb    | 11 +++-----
 .../app/views/work_units/_show_child.html.erb      |  2 +-
 .../app/views/work_units/_show_component.html.erb  | 32 ++++++++++++++++++++--
 .../app/views/work_units/_show_log_link.html.erb   | 14 ++++++++++
 .../test/controllers/work_units_controller_test.rb | 23 ++++++++++++++++
 apps/workbench/test/unit/work_unit_test.rb         | 26 ------------------
 10 files changed, 101 insertions(+), 78 deletions(-)
 create mode 100644 apps/workbench/app/views/work_units/_show_log_link.html.erb

       via  9f7e6c2782c1929de61ecd61e457700730ef9681 (commit)
       via  c8d04b26dbeb3dd4401788053bf514b9f172a185 (commit)
       via  aafa79beddaf4a1e94a502eda1f668ebec39e3d3 (commit)
       via  716ee800f3bfcffe19d091c3f5f30d826e69c72a (commit)
       via  c54ead18b1a012f73ac7ea06d93b397ed2f396c6 (commit)
       via  41d7b9bb8a45b0d80fb2bf15af4c9e7b3d77a467 (commit)
       via  c613f893bf36e79801af7d5a712853c51ef56bf9 (commit)
       via  e69f517dbd5ad9bac104d42479d8ef2f515b398e (commit)
       via  654d8fe3decc93b8eb986313cdb9070f22abdca6 (commit)
       via  af67b8e1955ca5a10b43b1701c4b86b0a33edb0b (commit)
       via  31baddea7535d8ba6ca812086264b71efdccbc29 (commit)
      from  25b000e2eefa9d2cfd454bb9a27518a882bb21a1 (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 9f7e6c2782c1929de61ecd61e457700730ef9681
Merge: 25b000e c8d04b2
Author: radhika <radhika at curoverse.com>
Date:   Wed Oct 12 11:23:37 2016 -0400

    refs #10144
    Merge branch '10144-pipeline-display-perf'


commit c8d04b26dbeb3dd4401788053bf514b9f172a185
Author: radhika <radhika at curoverse.com>
Date:   Tue Oct 11 20:27:28 2016 -0400

    10144: call object_for_dataclass only when attr value is not-nil.

diff --git a/apps/workbench/app/views/work_units/_component_detail.html.erb b/apps/workbench/app/views/work_units/_component_detail.html.erb
index f66ff07..7d588ba 100644
--- a/apps/workbench/app/views/work_units/_component_detail.html.erb
+++ b/apps/workbench/app/views/work_units/_component_detail.html.erb
@@ -43,6 +43,7 @@
             <table>
               <% # link to repo tree/file only if the repo is readable and the commit is a sha1
                  repo = (/^[0-9a-f]{40}$/ =~ current_obj.script_version and
+                         current_obj.repository and
                          object_for_dataclass(Repository, current_obj.repository, :name))
                  repo = nil unless repo.andand.http_fetch_url
                  %>

commit aafa79beddaf4a1e94a502eda1f668ebec39e3d3
Author: radhika <radhika at curoverse.com>
Date:   Tue Oct 11 19:07:38 2016 -0400

    10144: limit find_object_by_uuid update to the case where find is used; this will ensure that the object is not fetch again when show is used.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 3591199..f68250b 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -529,18 +529,14 @@ class ApplicationController < ActionController::Base
       elsif params[:uuid].nil? or params[:uuid].empty?
         @object = nil
       elsif not params[:uuid].is_a?(String)
-        @object = object_for_dataclass(model_class, params[:uuid])
+        @object = model_class.where(uuid: params[:uuid]).first
       elsif (model_class != Link and
              resource_class_for_uuid(params[:uuid]) == Link)
         @name_link = Link.find(params[:uuid])
         @object = model_class.find(@name_link.head_uuid)
       else
-        if resource_class_for_uuid(params[:uuid]) == Collection
-          @object = model_class.find(params[:uuid])
-          load_preloaded_objects [@object]
-        else
-          @object = object_for_dataclass(model_class, params[:uuid])
-        end
+        @object = model_class.find(params[:uuid])
+        load_preloaded_objects [@object]
       end
     rescue ArvadosApiClient::NotFoundException, ArvadosApiClient::NotLoggedInException, RuntimeError => error
       if error.is_a?(RuntimeError) and (error.message !~ /^argument to find\(/)

commit 716ee800f3bfcffe19d091c3f5f30d826e69c72a
Author: radhika <radhika at curoverse.com>
Date:   Tue Oct 11 16:56:05 2016 -0400

    10144: Conver the link_to_log tests into controller tests so that the #show is executed.

diff --git a/apps/workbench/test/controllers/work_units_controller_test.rb b/apps/workbench/test/controllers/work_units_controller_test.rb
index 12e0271..ee18861 100644
--- a/apps/workbench/test/controllers/work_units_controller_test.rb
+++ b/apps/workbench/test/controllers/work_units_controller_test.rb
@@ -65,4 +65,27 @@ class WorkUnitsControllerTest < ActionController::TestCase
                           }]
     get :index, encoded_params, session_for(:active)
   end
+
+  [
+    [Job, 'active', 'running_job_with_components', '/jobs/zzzzz-8i9sb-jyq01m7in1jlofj#Log'],
+    [PipelineInstance, 'active', 'pipeline_in_running_state', '/jobs/zzzzz-8i9sb-pshmckwoma9plh7#Log'],
+    [PipelineInstance, nil, 'pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', 'Log unavailable'],
+  ].each do |type, token, fixture, log_link|
+    test "link_to_log for #{fixture} for #{token}" do
+      use_token 'admin'
+      obj = find_fixture(type, fixture)
+
+      @controller = if type == Job then JobsController.new else PipelineInstancesController.new end
+
+      if token
+        get :show, {id: obj['uuid']}, session_for(token)
+      else
+        Rails.configuration.anonymous_user_token =
+          api_fixture("api_client_authorizations", "anonymous", "api_token")
+        get :show, {id: obj['uuid']}
+      end
+
+      assert_includes @response.body, log_link
+    end
+  end
 end
diff --git a/apps/workbench/test/unit/work_unit_test.rb b/apps/workbench/test/unit/work_unit_test.rb
index e59d30d..0ff3814 100644
--- a/apps/workbench/test/unit/work_unit_test.rb
+++ b/apps/workbench/test/unit/work_unit_test.rb
@@ -83,32 +83,6 @@ class WorkUnitTest < ActiveSupport::TestCase
     end
   end
 
-  [
-    [Job, 'active', 'running_job_with_components', true],
-    [Job, 'active', 'queued', false],
-    [Job, nil, 'completed_job_in_publicly_accessible_project', true],
-    [Job, 'active', 'completed_job_in_publicly_accessible_project', true],
-    [PipelineInstance, 'active', 'pipeline_in_running_state', true],  # no log, but while running the log link points to pi Log tab
-    [PipelineInstance, nil, 'pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', false],
-    [PipelineInstance, 'active', 'pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', false], #no log for completed pi
-    [Job, nil, 'job_in_publicly_accessible_project_but_other_objects_elsewhere', false, "Log unavailable"],
-  ].each do |type, token, fixture, has_log, log_link|
-    test "link_to_log for #{fixture} for #{token}" do
-      use_token token if token
-      obj = find_fixture(type, fixture)
-      wu = obj.work_unit
-
-      link = "#{wu.uri}#Log" if has_log
-      link_to_log = wu.link_to_log
-
-      if has_log
-        assert_includes link_to_log, link
-      else
-        assert_equal log_link, link_to_log
-      end
-    end
-  end
-
   test 'can_cancel?' do
     use_token 'active' do
       assert find_fixture(Job, 'running').work_unit.can_cancel?

commit c54ead18b1a012f73ac7ea06d93b397ed2f396c6
Author: radhika <radhika at curoverse.com>
Date:   Tue Oct 11 14:22:30 2016 -0400

    10144: Preload children during (main) component display. The Job.where in pipeline_instance_work_unit is fetching all jobs even if they are not readable.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index d8dc852..3591199 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -526,16 +526,21 @@ class ApplicationController < ActionController::Base
     begin
       if not model_class
         @object = nil
+      elsif params[:uuid].nil? or params[:uuid].empty?
+        @object = nil
       elsif not params[:uuid].is_a?(String)
         @object = object_for_dataclass(model_class, params[:uuid])
-      elsif params[:uuid].empty?
-        @object = nil
       elsif (model_class != Link and
              resource_class_for_uuid(params[:uuid]) == Link)
         @name_link = Link.find(params[:uuid])
         @object = model_class.find(@name_link.head_uuid)
       else
-        @object = object_for_dataclass(model_class, params[:uuid])
+        if resource_class_for_uuid(params[:uuid]) == Collection
+          @object = model_class.find(params[:uuid])
+          load_preloaded_objects [@object]
+        else
+          @object = object_for_dataclass(model_class, params[:uuid])
+        end
       end
     rescue ArvadosApiClient::NotFoundException, ArvadosApiClient::NotLoggedInException, RuntimeError => error
       if error.is_a?(RuntimeError) and (error.message !~ /^argument to find\(/)
diff --git a/apps/workbench/app/views/work_units/_show_component.html.erb b/apps/workbench/app/views/work_units/_show_component.html.erb
index 08405b3..4feb292 100644
--- a/apps/workbench/app/views/work_units/_show_component.html.erb
+++ b/apps/workbench/app/views/work_units/_show_component.html.erb
@@ -39,7 +39,16 @@
 <%# Work unit children %>
 
 <%
-  load_preloaded_objects(wu.children.collect {|j| j})
+  uuids = wu.children.collect {|c| c.uuid}.compact
+  if uuids.any?
+    resource_class = resource_class_for_uuid(uuids.first, friendly_name: true)
+
+    start = 0; inc = 200
+    while start < uuids.length
+      preload_objects_for_dataclass resource_class, uuids[start, inc]
+      start += inc
+    end
+  end
 
   collections = wu.outputs.flatten.uniq
   collections << wu.log_collection if wu.log_collection

commit 41d7b9bb8a45b0d80fb2bf15af4c9e7b3d77a467
Author: radhika <radhika at curoverse.com>
Date:   Tue Oct 11 10:46:45 2016 -0400

    10144: Rename :by_name as "by_attr" for preload_objects_for_dataclass

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index d0ecfe9..d8dc852 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -1180,15 +1180,15 @@ class ApplicationController < ActionController::Base
 
   # helper method to get object of a given dataclass and uuid
   helper_method :object_for_dataclass
-  def object_for_dataclass dataclass, uuid, by_name=nil
+  def object_for_dataclass dataclass, uuid, by_attr=nil
     raise ArgumentError, 'No input argument dataclass' unless (dataclass && uuid)
-    preload_objects_for_dataclass(dataclass, [uuid], by_name)
+    preload_objects_for_dataclass(dataclass, [uuid], by_attr)
     @objects_for[uuid]
   end
 
   # helper method to preload objects for given dataclass and uuids
   helper_method :preload_objects_for_dataclass
-  def preload_objects_for_dataclass dataclass, uuids, by_name=nil
+  def preload_objects_for_dataclass dataclass, uuids, by_attr=nil
     @objects_for ||= {}
 
     raise ArgumentError, 'Argument is not a data class' unless dataclass.is_a? Class
@@ -1205,7 +1205,9 @@ class ApplicationController < ActionController::Base
     uuids.each do |x|
       @objects_for[x] = nil
     end
-    if by_name
+    if by_attr and ![:uuid, :name].include?(by_attr)
+      raise ArgumentError, "Preloading only using lookups by uuid or name are supported: #{by_attr}"
+    elsif by_attr and by_attr == :name
       dataclass.where(name: uuids).each do |obj|
         @objects_for[obj.name] = obj
       end
diff --git a/apps/workbench/app/views/work_units/_component_detail.html.erb b/apps/workbench/app/views/work_units/_component_detail.html.erb
index 45ae978..f66ff07 100644
--- a/apps/workbench/app/views/work_units/_component_detail.html.erb
+++ b/apps/workbench/app/views/work_units/_component_detail.html.erb
@@ -43,7 +43,7 @@
             <table>
               <% # link to repo tree/file only if the repo is readable and the commit is a sha1
                  repo = (/^[0-9a-f]{40}$/ =~ current_obj.script_version and
-                         object_for_dataclass(Repository, current_obj.repository, :by_name))
+                         object_for_dataclass(Repository, current_obj.repository, :name))
                  repo = nil unless repo.andand.http_fetch_url
                  %>
               <% [:script, :repository, :script_version, :supplied_script_version, :nondeterministic,
diff --git a/apps/workbench/app/views/work_units/_show_component.html.erb b/apps/workbench/app/views/work_units/_show_component.html.erb
index 9bf751f..08405b3 100644
--- a/apps/workbench/app/views/work_units/_show_component.html.erb
+++ b/apps/workbench/app/views/work_units/_show_component.html.erb
@@ -68,7 +68,7 @@
   end
 
   repos = wu.children.collect {|c| c.repository}.uniq.compact
-  preload_objects_for_dataclass(Repository, repos, :by_name) if repos.any?
+  preload_objects_for_dataclass(Repository, repos, :name) if repos.any?
 %>
 
 <% if wu.has_unreadable_children %>

commit c613f893bf36e79801af7d5a712853c51ef56bf9
Author: radhika <radhika at curoverse.com>
Date:   Fri Oct 7 15:46:30 2016 -0400

    10144: Preloading all the collection using one single large query is much slower than making several requests
    with a smaller subset of  uuids/pdhs when displaying a pipeline instance with many jobs. Hence, make several
    requests for 200 collections at a time.

diff --git a/apps/workbench/app/views/work_units/_show_component.html.erb b/apps/workbench/app/views/work_units/_show_component.html.erb
index 2290a65..9bf751f 100644
--- a/apps/workbench/app/views/work_units/_show_component.html.erb
+++ b/apps/workbench/app/views/work_units/_show_component.html.erb
@@ -50,8 +50,22 @@
   collections.concat wu.children.collect {|j| j.log_collection}.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?
+
+  if collections_uuids.any?
+    start = 0; inc = 200
+    while start < collections_uuids.length
+      preload_collections_for_objects collections_uuids[start, inc]
+      start += inc
+    end
+  end
+
+  if collections_pdhs.any?
+    start = 0; inc = 200
+    while start < collections_pdhs.length
+      preload_for_pdhs collections_pdhs[start, inc]
+      start += inc
+    end
+  end
 
   repos = wu.children.collect {|c| c.repository}.uniq.compact
   preload_objects_for_dataclass(Repository, repos, :by_name) if repos.any?

commit e69f517dbd5ad9bac104d42479d8ef2f515b398e
Author: radhika <radhika at curoverse.com>
Date:   Thu Oct 6 17:45:22 2016 -0400

    10144: preload work_unit children

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 9f0e40a..d0ecfe9 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -527,7 +527,7 @@ class ApplicationController < ActionController::Base
       if not model_class
         @object = nil
       elsif not params[:uuid].is_a?(String)
-        @object = model_class.where(uuid: params[:uuid]).first
+        @object = object_for_dataclass(model_class, params[:uuid])
       elsif params[:uuid].empty?
         @object = nil
       elsif (model_class != Link and
@@ -535,7 +535,7 @@ class ApplicationController < ActionController::Base
         @name_link = Link.find(params[:uuid])
         @object = model_class.find(@name_link.head_uuid)
       else
-        @object = model_class.find(params[:uuid])
+        @object = object_for_dataclass(model_class, params[:uuid])
       end
     rescue ArvadosApiClient::NotFoundException, ArvadosApiClient::NotLoggedInException, RuntimeError => error
       if error.is_a?(RuntimeError) and (error.message !~ /^argument to find\(/)
@@ -1217,6 +1217,15 @@ class ApplicationController < ActionController::Base
     @objects_for
   end
 
+  # helper method to load objects that are already preloaded
+  helper_method :load_preloaded_objects
+  def load_preloaded_objects objs
+    @objects_for ||= {}
+    objs.each do |obj|
+      @objects_for[obj.uuid] = obj
+    end
+  end
+
   def wiselinks_layout
     'body'
   end
diff --git a/apps/workbench/app/views/work_units/_show_component.html.erb b/apps/workbench/app/views/work_units/_show_component.html.erb
index 2d6f14b..2290a65 100644
--- a/apps/workbench/app/views/work_units/_show_component.html.erb
+++ b/apps/workbench/app/views/work_units/_show_component.html.erb
@@ -39,12 +39,11 @@
 <%# Work unit children %>
 
 <%
-  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
+  load_preloaded_objects(wu.children.collect {|j| j})
 
+  collections = wu.outputs.flatten.uniq
+  collections << wu.log_collection if wu.log_collection
+  collections << wu.docker_image if wu.docker_image
   collections = wu.children.collect {|j| j.outputs}.compact
   collections = collections.flatten.uniq
   collections.concat wu.children.collect {|j| j.docker_image}.uniq.compact

commit 654d8fe3decc93b8eb986313cdb9070f22abdca6
Author: radhika <radhika at curoverse.com>
Date:   Thu Oct 6 13:30:36 2016 -0400

    10144: preload repositories during work unit component display.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 9da1d78..9f0e40a 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -1180,15 +1180,15 @@ class ApplicationController < ActionController::Base
 
   # helper method to get object of a given dataclass and uuid
   helper_method :object_for_dataclass
-  def object_for_dataclass dataclass, uuid
+  def object_for_dataclass dataclass, uuid, by_name=nil
     raise ArgumentError, 'No input argument dataclass' unless (dataclass && uuid)
-    preload_objects_for_dataclass(dataclass, [uuid])
+    preload_objects_for_dataclass(dataclass, [uuid], by_name)
     @objects_for[uuid]
   end
 
   # helper method to preload objects for given dataclass and uuids
   helper_method :preload_objects_for_dataclass
-  def preload_objects_for_dataclass dataclass, uuids
+  def preload_objects_for_dataclass dataclass, uuids, by_name=nil
     @objects_for ||= {}
 
     raise ArgumentError, 'Argument is not a data class' unless dataclass.is_a? Class
@@ -1205,8 +1205,14 @@ class ApplicationController < ActionController::Base
     uuids.each do |x|
       @objects_for[x] = nil
     end
-    dataclass.where(uuid: uuids).each do |obj|
-      @objects_for[obj.uuid] = obj
+    if by_name
+      dataclass.where(name: uuids).each do |obj|
+        @objects_for[obj.name] = obj
+      end
+    else
+      dataclass.where(uuid: uuids).each do |obj|
+        @objects_for[obj.uuid] = obj
+      end
     end
     @objects_for
   end
diff --git a/apps/workbench/app/views/work_units/_component_detail.html.erb b/apps/workbench/app/views/work_units/_component_detail.html.erb
index e15cc44..45ae978 100644
--- a/apps/workbench/app/views/work_units/_component_detail.html.erb
+++ b/apps/workbench/app/views/work_units/_component_detail.html.erb
@@ -41,13 +41,9 @@
           </div>
           <div class="col-md-6">
             <table>
-              <% # link to repo tree/file only if the repo is readable
-                 # and the commit is a sha1...
-                 repo =
-                 (/^[0-9a-f]{40}$/ =~ current_obj.script_version and
-                 Repository.where(name: current_obj.repository).first)
-
-                 # ...and the api server provides an http:// or https:// url
+              <% # link to repo tree/file only if the repo is readable and the commit is a sha1
+                 repo = (/^[0-9a-f]{40}$/ =~ current_obj.script_version and
+                         object_for_dataclass(Repository, current_obj.repository, :by_name))
                  repo = nil unless repo.andand.http_fetch_url
                  %>
               <% [:script, :repository, :script_version, :supplied_script_version, :nondeterministic,
diff --git a/apps/workbench/app/views/work_units/_show_component.html.erb b/apps/workbench/app/views/work_units/_show_component.html.erb
index 47db487..2d6f14b 100644
--- a/apps/workbench/app/views/work_units/_show_component.html.erb
+++ b/apps/workbench/app/views/work_units/_show_component.html.erb
@@ -53,6 +53,9 @@
   collections_uuids = collections - collections_pdhs
   preload_collections_for_objects collections_uuids if collections_uuids.any?
   preload_for_pdhs collections_pdhs if collections_pdhs.any?
+
+  repos = wu.children.collect {|c| c.repository}.uniq.compact
+  preload_objects_for_dataclass(Repository, repos, :by_name) if repos.any?
 %>
 
 <% if wu.has_unreadable_children %>

commit af67b8e1955ca5a10b43b1701c4b86b0a33edb0b
Author: radhika <radhika at curoverse.com>
Date:   Thu Oct 6 13:12:05 2016 -0400

    10144: Update link_to_if_arvados_object to use collection_for_pdh when resource_class is a Collection and attrvalue is a pdh.

diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index b5df9f3..21879a5 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -126,7 +126,11 @@ module ApplicationHelper
           else
             begin
               if resource_class.name == 'Collection'
-                link_name = collections_for_object(link_uuid).andand.first.andand.friendly_link_name
+                if CollectionsHelper.match(link_uuid)
+                  link_name = collection_for_pdh(link_uuid).andand.first.andand.portable_data_hash
+                else
+                  link_name = collections_for_object(link_uuid).andand.first.andand.friendly_link_name
+                end
               else
                 link_name = object_for_dataclass(resource_class, link_uuid).andand.friendly_link_name
               end

commit 31baddea7535d8ba6ca812086264b71efdccbc29
Author: radhika <radhika at curoverse.com>
Date:   Thu Oct 6 13:09:17 2016 -0400

    10144: Replace work_unit -> link_to_log with partial so that preloaded objects are used.

diff --git a/apps/workbench/app/models/proxy_work_unit.rb b/apps/workbench/app/models/proxy_work_unit.rb
index 11ec0ee..44905be 100644
--- a/apps/workbench/app/models/proxy_work_unit.rb
+++ b/apps/workbench/app/models/proxy_work_unit.rb
@@ -173,31 +173,6 @@ class ProxyWorkUnit < WorkUnit
     @unreadable_children
   end
 
-  def readable?
-    resource_class = ArvadosBase::resource_class_for_uuid(uuid)
-    resource_class.where(uuid: [uuid]).first rescue nil
-  end
-
-  def link_to_log
-    if state_label.in? ["Complete", "Failed", "Cancelled"]
-      lc = log_collection
-      if lc
-        logCollection = Collection.find? lc
-        if logCollection
-          ApplicationController.helpers.link_to("Log", "#{uri}#Log")
-        else
-          "Log unavailable"
-        end
-      end
-    elsif state_label == "Running"
-      if readable?
-        ApplicationController.helpers.link_to("Log", "#{uri}#Log")
-      else
-        "Log unavailable"
-      end
-    end
-  end
-
   def walltime
     if state_label != "Queued"
       if started_at
diff --git a/apps/workbench/app/models/work_unit.rb b/apps/workbench/app/models/work_unit.rb
index 924e067..0c384bb 100644
--- a/apps/workbench/app/models/work_unit.rb
+++ b/apps/workbench/app/models/work_unit.rb
@@ -115,10 +115,6 @@ class WorkUnit
     # returns true if this work unit can be canceled
   end
 
-  def readable?
-    # is the proxied object readable by current user?
-  end
-
   def uri
     # returns the uri for this work unit
   end
@@ -132,10 +128,6 @@ class WorkUnit
   end
 
   # view helper methods
-  def link_to_log
-    # display a link to log if present
-  end
-
   def walltime
     # return walltime for a running or completed work unit
   end
diff --git a/apps/workbench/app/views/work_units/_show_child.html.erb b/apps/workbench/app/views/work_units/_show_child.html.erb
index acf19fd..2693334 100644
--- a/apps/workbench/app/views/work_units/_show_child.html.erb
+++ b/apps/workbench/app/views/work_units/_show_child.html.erb
@@ -17,7 +17,7 @@
           <div class="col-md-8"></div>
         <% else %>
           <div class="col-md-1">
-            <%= current_obj.link_to_log %>
+            <%= render partial: 'work_units/show_log_link', locals: {wu: current_obj} %>
           </div>
 
           <% walltime = current_obj.walltime %>
diff --git a/apps/workbench/app/views/work_units/_show_component.html.erb b/apps/workbench/app/views/work_units/_show_component.html.erb
index 89233cf..47db487 100644
--- a/apps/workbench/app/views/work_units/_show_component.html.erb
+++ b/apps/workbench/app/views/work_units/_show_component.html.erb
@@ -48,6 +48,7 @@
   collections = wu.children.collect {|j| j.outputs}.compact
   collections = collections.flatten.uniq
   collections.concat wu.children.collect {|j| j.docker_image}.uniq.compact
+  collections.concat wu.children.collect {|j| j.log_collection}.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?
diff --git a/apps/workbench/app/views/work_units/_show_log_link.html.erb b/apps/workbench/app/views/work_units/_show_log_link.html.erb
new file mode 100644
index 0000000..a54ab32
--- /dev/null
+++ b/apps/workbench/app/views/work_units/_show_log_link.html.erb
@@ -0,0 +1,14 @@
+<% if wu.state_label.in? ["Complete", "Failed", "Cancelled"] %>
+  <% lc = wu.log_collection %>
+  <% if lc and object_readable(lc, Collection) and object_readable(wu.uuid) %>
+    <%= link_to("Log", "#{wu.uri}#Log") %>
+  <% else %>
+    Log unavailable
+  <% end %>
+<% elsif wu.state_label == "Running" %>
+  <% if object_readable(wu.uuid) %>
+    <%= link_to("Log", "#{wu.uri}#Log") %>
+  <% else %>
+    Log unavailable
+  <% end %>
+<% end %>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list