X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4d257edde88edfb9530afa0d8b0ba7c9216cfb3a..e030e175bf4093eb7cdecd9c534548ad2b9a2b05:/apps/workbench/app/helpers/provenance_helper.rb diff --git a/apps/workbench/app/helpers/provenance_helper.rb b/apps/workbench/app/helpers/provenance_helper.rb index 89d9ee6ceb..9b4d265dfa 100644 --- a/apps/workbench/app/helpers/provenance_helper.rb +++ b/apps/workbench/app/helpers/provenance_helper.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + module ProvenanceHelper class GenerateGraph @@ -37,9 +41,15 @@ module ProvenanceHelper return "\"#{uuid}\" [label=\"(empty collection)\"];\n" end - href = url_for ({:controller => Collection.to_s.tableize, - :action => :show, - :id => uuid.to_s }) + if describe_opts[:col_uuid] + href = url_for ({:controller => Collection.to_s.tableize, + :action => :show, + :id => describe_opts[:col_uuid].to_s }) + else + href = url_for ({:controller => Collection.to_s.tableize, + :action => :show, + :id => uuid.to_s }) + end return "\"#{uuid}\" [label=\"#{encode_quotes(describe_opts[:label] || (@pdata[uuid] and @pdata[uuid][:name]) || uuid)}\",shape=box,href=\"#{href}\",#{bgcolor}];\n" else @@ -133,7 +143,10 @@ module ProvenanceHelper gr += edge(uuid, job[:output], {label: "output" }) end - gr += edge(uuid, job[:log], {label: "log"}) if job[:log] and !edge_opts[:no_log] + if job[:log] and !edge_opts[:no_log] + gr += describe_node(job[:log]) + gr += edge(uuid, job[:log], {label: "log"}) + end gr end @@ -181,6 +194,58 @@ module ProvenanceHelper if rsc == Job job = @pdata[uuid] gr += job_edges job if job + elsif rsc == ContainerRequest + cr = @pdata[uuid] + if cr + gr += describe_node(cr[:uuid], {href: {controller: 'container_requests', + id: cr[:uuid]}, + label: cr[:name], + shape: 'oval'}) + # Connect child CRs + children = @opts[:cr_children_of].andand[cr[:uuid]] + if children + children.each do |child| + gr += edge(child[:uuid], cr[:uuid], {label: 'child'}) + end + end + # Output collection node + if cr[:output_uuid] and @opts[:output_collections][cr[:output_uuid]] + c = @opts[:output_collections][cr[:output_uuid]] + gr += describe_node(c[:portable_data_hash], + { + label: c[:name], + col_uuid: c[:uuid], + }) + gr += edge(cr[:uuid], + c[:portable_data_hash], + {label: 'output'}) + end + # Input collection nodes + output_pdhs = @opts[:output_collections].values.collect{|c| + c[:portable_data_hash]} + ProvenanceHelper::cr_input_pdhs(cr).each do |pdh| + if not output_pdhs.include?(pdh) + # Search for collections on the same project first + cols = @opts[:input_collections][pdh].andand.select{|c| + c[:owner_uuid] == cr[:owner_uuid]} + if not cols or cols.empty? + # Search for any collection with this PDH + cols = @opts[:input_collections][pdh] + end + if cols + names = cols.collect{|x| x[:name]}.uniq + else + names = ['(collection not found)'] + end + input_name = names.first + if names.length > 1 + input_name += " + #{names.length - 1} more" + end + gr += describe_node(pdh, {label: input_name}) + end + gr += edge(pdh, cr[:uuid], {label: 'input'}) + end + end end end @@ -218,7 +283,7 @@ module ProvenanceHelper label = "#{v[0][:script]}" - if label == "run-command" + if label == "run-command" and v[0][:script_parameters][:command].is_a? Array label = v[0][:script_parameters][:command].join(' ') end @@ -234,7 +299,7 @@ module ProvenanceHelper end def encode_quotes value - value.andand.to_s.gsub("\"", "\\\"").gsub("\n", "\\n") + value.to_s.gsub("\"", "\\\"").gsub("\n", "\\n") end end @@ -301,7 +366,9 @@ edge [fontsize=10,fontname=\"Helvetica,Arial,sans-serif\"]; svg = svg.sub(/