[ARVADOS] created: 325ef2d59dd63ea1474cf94f7a11d7d171ec9db8

Git user git at public.curoverse.com
Thu Oct 6 14:32:53 EDT 2016


        at  325ef2d59dd63ea1474cf94f7a11d7d171ec9db8 (commit)


commit 325ef2d59dd63ea1474cf94f7a11d7d171ec9db8
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 0da5956..fcc0b1e 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -1179,15 +1179,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
@@ -1204,8 +1204,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 19f1e401e87dba6f745f30c24bd61edb218cc199
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 2bdf779037ad9420f16d18f28fdc63ea313a8008
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