Color-coded graphical pipeline comparison, alternate approach to Tom's
authorPeter Amstutz <peter.amstutz@curoverse.com>
Thu, 30 Jan 2014 22:34:36 +0000 (17:34 -0500)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Thu, 30 Jan 2014 22:34:36 +0000 (17:34 -0500)
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/controllers/pipeline_instances_controller.rb
apps/workbench/app/helpers/provenance_helper.rb

index caf49baa74b1d6aedd4f3d7c18165a0bc2f166da..8ba12d950c8972df03203ba8bfbebd0cf3ca5656 100644 (file)
@@ -99,7 +99,7 @@ class CollectionsController < ApplicationController
     end
     
     Collection.where(uuid: @object.uuid).each do |u|
-      @prov_svg = ProvenanceHelper::create_provenance_graph u.provenance, {:direction => :bottom_up, :combine_jobs => true}
+      @prov_svg = ProvenanceHelper::create_provenance_graph u.provenance, {:direction => :bottom_up, :combine_jobs => :script_only}
     end
   end
 
index a92694010ff522fce305d6a25dfc8ab64537021b..6e7bc980b7152dcc5282c85051459786d9c02b50 100644 (file)
@@ -1,25 +1,56 @@
 class PipelineInstancesController < ApplicationController
 
   def show
+    pipelines = [@object]
+
+    if params[:compare]
+      PipelineInstance.where(uuid: params[:compare]).each do |p| pipelines << p end
+    end
+
+    count = {}    
     provenance = {}
-    somejob = nil
-    collections = []
-    @object.components.each do |k, v|
-      j = v[:job]
-      somejob = j[:uuid]
-      provenance[somejob.intern] = j
-      collections << j[:output].intern
-      j[:dependencies].each do |k|
-        collections << k.intern
+    pips = {}
+    n = 1
+
+    pipelines.each do |p|
+      collections = []
+
+      p.components.each do |k, v|
+        j = v[:job]
+
+        uuid = j[:uuid].intern
+        provenance[uuid] = j
+        pips[uuid] = 0 unless pips[uuid] != nil
+        pips[uuid] |= n
+
+        collections << j[:output]
+        ProvenanceHelper::find_collections(j[:script_parameters]).each do |k|
+          collections << k
+        end
+
+        uuid = j[:script_version].intern
+        provenance[uuid] = {:uuid => uuid}
+        pips[uuid] = 0 unless pips[uuid] != nil
+        pips[uuid] |= n
       end
-    end
 
-    Collection.where(uuid: collections).each do |c|
-      #puts c.uuid
-      provenance[c.uuid.intern] = c
+      Collection.where(uuid: collections).each do |c|
+        uuid = c.uuid.intern
+        provenance[uuid] = c
+        pips[uuid] = 0 unless pips[uuid] != nil
+        pips[uuid] |= n
+      end
+      
+      n = n << 1
     end
 
-    @prov_svg = ProvenanceHelper::create_provenance_graph provenance, {:all_script_parameters => true}
+    puts pips
+
+    @prov_svg = ProvenanceHelper::create_provenance_graph provenance, {
+      :all_script_parameters => true, 
+      :combine_jobs => :script_and_version,
+      :script_version_nodes => true,
+      :pips => pips }
   end
 
 end
index 9d9f44b335919dc2e1b698c4984b543cb2f47cfe..15474bab0001707882cda98b5eb34342124802dd 100644 (file)
@@ -24,17 +24,32 @@ module ProvenanceHelper
       end
     end
 
+    def determine_fillcolor(n)
+      bgcolor = ""
+      case n
+      when 1
+        bgcolor = "style=filled,fillcolor=\"#88ff88\""
+      when 2
+        bgcolor = "style=filled,fillcolor=\"#8888ff\""
+      when 3
+        bgcolor = "style=filled,fillcolor=\"#88ffff\""
+      end
+      bgcolor
+    end
+
     def describe_node(uuid)
+      bgcolor = determine_fillcolor @opts[:pips][uuid] if @opts[:pips]
+
       rsc = ArvadosBase::resource_class_for_uuid uuid.to_s
       if rsc
         href = "/#{rsc.to_s.underscore.pluralize rsc}/#{uuid}"
-
+      
         #"\"#{uuid}\" [label=\"#{rsc}\\n#{uuid}\",href=\"#{href}\"];\n"
         if rsc == Collection
           if @pdata[uuid] 
             #puts @pdata[uuid]
             if @pdata[uuid][:name]
-              return "\"#{uuid}\" [label=\"#{@pdata[uuid][:name]}\",href=\"#{href}\",shape=oval];\n"
+              return "\"#{uuid}\" [label=\"#{@pdata[uuid][:name]}\",href=\"#{href}\",shape=oval,#{bgcolor}];\n"
             else
               files = nil
               if @pdata[uuid].respond_to? :files
@@ -54,19 +69,21 @@ module ProvenanceHelper
                 if i < files.length
                   label += "\\n&vellip;"
                 end
-                return "\"#{uuid}\" [label=\"#{label}\",href=\"#{href}\",shape=oval];\n"
+                return "\"#{uuid}\" [label=\"#{label}\",href=\"#{href}\",shape=oval,#{bgcolor}];\n"
               end
             end  
           end
-          return "\"#{uuid}\" [label=\"#{rsc}\",href=\"#{href}\"];\n"
+          return "\"#{uuid}\" [label=\"#{rsc}\",href=\"#{href}\",#{bgcolor}];\n"
         end
       end
-      return ""
+      "\"#{uuid}\" [#{bgcolor}];\n"
     end
 
     def job_uuid(job)
-      if @opts[:combine_jobs]
+      if @opts[:combine_jobs] == :script_only
         uuid = "#{job[:script]}"
+      elsif @opts[:combine_jobs] == :script_and_version
+        uuid = "#{job[:script]}_#{job[:script_version]}"
       else
         uuid = "#{job[:uuid]}"
       end
@@ -185,6 +202,7 @@ module ProvenanceHelper
             gr += script_param_edges(job, "", job[:script_parameters])
 
             if @opts[:script_version_nodes]
+              gr += describe_node(job[:script_version])
               gr += edge(job_uuid(job), job[:script_version], {:label => "script_version"})
             end
           end
@@ -206,18 +224,27 @@ module ProvenanceHelper
       gr
     end
 
-    def add_jobs_href
+    def describe_jobs
       gr = ""
       @jobs.each do |k, v|
         gr += "\"#{k}\" [href=\"/jobs?"
-        script = ""
+        
+        n = 0
         v.each do |u|
           gr += "uuid%5b%5d=#{u[:uuid]}&"
-          script = u[:script]
+          n |= @opts[:pips][u[:uuid].intern] if @opts[:pips] and @opts[:pips][u[:uuid].intern]
         end
+
         gr += "\",label=\""
-        gr += if @opts[:combine_jobs] then "#{script}" else "#{script}\\n#{v[0][:finished_at]}" end
-        gr += "\"];\n"
+        
+        if @opts[:combine_jobs] == :script_only
+          gr += uuid = "#{v[0][:script]}"
+        elsif @opts[:combine_jobs] == :script_and_version
+          gr += uuid = "#{v[0][:script]}"
+        else
+          gr += uuid = "#{v[0][:script]}\\n#{v[0][:finished_at]}"
+        end
+        gr += "\",#{determine_fillcolor n}];\n"
       end
       gr
     end
@@ -254,7 +281,7 @@ edge [fontsize=8];
       gr += g.generate_provenance_edges(k)
     end
 
-    gr += g.add_jobs_href
+    gr += g.describe_jobs
 
     gr += "}"
     svg = ""