show provenance
authorTom Clegg <tom@clinicalfuture.com>
Tue, 9 Jul 2013 23:06:25 +0000 (19:06 -0400)
committerTom Clegg <tom@clinicalfuture.com>
Tue, 9 Jul 2013 23:06:25 +0000 (19:06 -0400)
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/views/collections/show.html.erb
services/api/app/models/job.rb

index bad1378622a56f7b25b5a1e1d368d24027201b04..71e882c5eebc46dc14f0ab6e579a6a26b04a6783 100644 (file)
@@ -49,7 +49,25 @@ class CollectionsController < ApplicationController
     @sourcedata = {params[:uuid] => {uuid: params[:uuid]}}
     @protected = {}
 
-    # TODO: compile provenance data using Job.where(...)
+    colorindex = -1
+    any_hope_left = true
+    while any_hope_left
+      any_hope_left = false
+      Job.where(output: @sourcedata.keys).sort_by { |a| a.finished_at || a.created_at }.reverse.each do |job|
+        if !@output2colorindex[job.output]
+          any_hope_left = true
+          @output2colorindex[job.output] = (colorindex += 1) % 10
+          @provenance << {job: job, output: job.output}
+          @sourcedata.delete job.output
+          @output2job[job.output] = job
+          job.dependencies.each do |new_source_data|
+            unless @output2colorindex[new_source_data]
+              @sourcedata[new_source_data] = {uuid: new_source_data}
+            end
+          end
+        end
+      end
+    end
 
     Link.where(head_uuid: @sourcedata.keys | @output2job.keys).each do |link|
       if link.link_class == 'resources' and link.name == 'wants'
index f8f9c0c8fb7df58fdebc29cae06372e061e22e72..8c6b420998fed7be06ab3314e8b9969540a4072f 100644 (file)
              <% j.script_parameters.each do |k,v| %>
               <tr>
                 <td style="width: 60%">
-                  <% re = v.match(/^([0-9a-f]+)/) %>
-                  <% justhash = (re and re[1].length == 32) ? re[1] : nil %>
-                 <% if justhash and @output2job.has_key? justhash %>
+                 <% if v and @output2job.has_key? v %>
                  <tt class="label colorseries-10-<%= @output2colorindex[v] %>"><%= v %></tt>
-                  <% elsif justhash %>
-                 <tt class="label colorseries-nil"><%= justhash %></tt><br /><span class="deemphasize"><%= v %></span>
+                  <% elsif v %>
+                 <tt class="label colorseries-nil"><%= v %></tt><br /><span class="deemphasize"><%= v %></span>
                   <% else %>
                  <span class="deemphasize"><%= v %></span>
                   <% end %>
                 </td><td style="text-align: center; width: 20%">
-                  <% if justhash
-                       if @protected[justhash]
+                  <% if v
+                       if @protected[v]
                          labelclass = 'success'
                          labeltext = 'keep'
                        else
index 5d520007d1ecd0926da3b38de3758a3c93c72f81..bb67bda97aa6d6eb86d4012e412e0c42ddd5bf2d 100644 (file)
@@ -78,8 +78,7 @@ class Job < ArvadosModel
     self.script_parameters.values.each do |v|
       next unless v.is_a? String
       v.match(/^(([0-9a-f]{32})\b(\+[^,]+)?,?)*$/) do |locator|
-        bare_locator = locator[0].gsub(/\+[^,]+/,'')
-        deps[bare_locator] = true
+        deps[locator] = true
       end
     end
     deps.keys