From b50bbef5f429465fe71781be7edebbb8c4479d50 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 24 Mar 2014 01:59:08 -0400 Subject: [PATCH] Indicate which outputs are marked "persistent" on pipeline provenance graphs. --- .../pipeline_instances_controller.rb | 6 +++ .../app/helpers/provenance_helper.rb | 50 +++++++++++-------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb index c2a398c9b2..423147508d 100644 --- a/apps/workbench/app/controllers/pipeline_instances_controller.rb +++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb @@ -15,6 +15,12 @@ class PipelineInstancesController < ApplicationController p.components.each do |k, v| j = v[:job] || next + # The graph is interested in whether the component is + # indicated as persistent, more than whether the job + # satisfying it (which could have been reused, or someone + # else's) is. + j[:output_is_persistent] = v[:output_is_persistent] + uuid = j[:uuid].intern provenance[uuid] = j pips[uuid] = 0 unless pips[uuid] != nil diff --git a/apps/workbench/app/helpers/provenance_helper.rb b/apps/workbench/app/helpers/provenance_helper.rb index 66754d20b2..828fbfe308 100644 --- a/apps/workbench/app/helpers/provenance_helper.rb +++ b/apps/workbench/app/helpers/provenance_helper.rb @@ -6,6 +6,7 @@ module ProvenanceHelper @opts = opts @visited = {} @jobs = {} + @node_extra = {} end def self.collection_uuid(uuid) @@ -41,7 +42,7 @@ module ProvenanceHelper def describe_node(uuid) uuid = uuid.to_sym - bgcolor = determine_fillcolor @opts[:pips][uuid] if @opts[:pips] + bgcolor = determine_fillcolor @opts[:pips].andand[uuid] rsc = ArvadosBase::resource_class_for_uuid uuid.to_s if rsc @@ -57,7 +58,7 @@ module ProvenanceHelper #puts "empty!" return "\"#{uuid}\" [label=\"(empty collection)\"];\n" end - puts "#{uuid.class} #{@pdata[uuid]}" + #puts "#{uuid.class} #{@pdata[uuid]}" if @pdata[uuid] #puts @pdata[uuid] if @pdata[uuid][:name] @@ -82,7 +83,10 @@ module ProvenanceHelper label += "\\n⋮" end #puts "#{uuid} #{label} #{files}" - return "\"#{uuid}\" [label=\"#{label}\",href=\"#{href}\",shape=oval,#{bgcolor}];\n" + extra_s = @node_extra[uuid].andand.map { |k,v| + "#{k}=\"#{v}\"" + }.andand.join "," + return "\"#{uuid}\" [label=\"#{label}\",href=\"#{href}\",shape=oval,#{bgcolor},#{extra_s}];\n" end end end @@ -189,27 +193,31 @@ module ProvenanceHelper @visited[uuid] = true end - #puts "visiting #{uuid}" + #puts "visiting #{uuid.inspect}" - if m + if m # uuid is a collection - gr += describe_node(uuid) - - if m == :"d41d8cd98f00b204e9800998ecf8427e+0" - # empty collection, don't follow any further - return gr - end - - @pdata.each do |k, job| - if job[:output] == uuid.to_s - gr += edge(uuid, job_uuid(job), {:label => "output"}) - gr += generate_provenance_edges(job[:uuid]) - end - if job[:log] == uuid.to_s - gr += edge(uuid, job_uuid(job), {:label => "log"}) - gr += generate_provenance_edges(job[:uuid]) + if uuid != :"d41d8cd98f00b204e9800998ecf8427e+0" + # not the empty collection + + @pdata.each do |k, job| + if job[:output] == uuid.to_s + extra = { label: 'output' } + if job[:output_is_persistent] + extra[:label] += ' (persistent)' + @node_extra[uuid] ||= {} + @node_extra[uuid][:penwidth] = 4 + end + gr += edge(uuid, job_uuid(job), extra) + gr += generate_provenance_edges(job[:uuid]) + end + if job[:log] == uuid.to_s + gr += edge(uuid, job_uuid(job), {:label => "log"}) + gr += generate_provenance_edges(job[:uuid]) + end end end + gr += describe_node(uuid) else # uuid is something else rsc = ArvadosBase::resource_class_for_uuid uuid.to_s @@ -313,7 +321,7 @@ edge [fontsize=10]; gr += "}" svg = "" - puts gr + #puts gr require 'open3' -- 2.30.2