projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tweak table styles and add Total row
[arvados.git]
/
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 8278d37f3ec022525bdfc42b0f2103bdf080e078..66754d20b2f209248270d7ca73cedb0b5e758554 100644
(file)
--- a/
apps/workbench/app/helpers/provenance_helper.rb
+++ b/
apps/workbench/app/helpers/provenance_helper.rb
@@
-7,13
+7,15
@@
module ProvenanceHelper
@visited = {}
@jobs = {}
end
@visited = {}
@jobs = {}
end
-
+
def self.collection_uuid(uuid)
m = CollectionsHelper.match(uuid)
if m
def self.collection_uuid(uuid)
m = CollectionsHelper.match(uuid)
if m
- #if m[2]
- return m[1]
- #else
+ if m[2]
+ return m[1]+m[2]
+ else
+ return m[1]
+ end
# Collection.where(uuid: ['contains', m[1]]).each do |u|
# puts "fixup #{uuid} to #{u.uuid}"
# return u.uuid
# Collection.where(uuid: ['contains', m[1]]).each do |u|
# puts "fixup #{uuid} to #{u.uuid}"
# return u.uuid
@@
-24,17
+26,28
@@
module ProvenanceHelper
end
end
end
end
+ def url_for u
+ p = { :host => @opts[:request].host,
+ :port => @opts[:request].port,
+ :protocol => @opts[:request].protocol }
+ p.merge! u
+ Rails.application.routes.url_helpers.url_for (p)
+ end
+
def determine_fillcolor(n)
fillcolor = %w(aaaaaa aaffaa aaaaff aaaaaa ffaaaa)[n || 0] || 'aaaaaa'
"style=filled,fillcolor=\"##{fillcolor}\""
end
def describe_node(uuid)
def determine_fillcolor(n)
fillcolor = %w(aaaaaa aaffaa aaaaff aaaaaa ffaaaa)[n || 0] || 'aaaaaa'
"style=filled,fillcolor=\"##{fillcolor}\""
end
def describe_node(uuid)
+ uuid = uuid.to_sym
bgcolor = determine_fillcolor @opts[:pips][uuid] if @opts[:pips]
rsc = ArvadosBase::resource_class_for_uuid uuid.to_s
if rsc
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}"
+ href = url_for ({:controller => rsc.to_s.tableize,
+ :action => :show,
+ :id => uuid.to_s })
#"\"#{uuid}\" [label=\"#{rsc}\\n#{uuid}\",href=\"#{href}\"];\n"
if rsc == Collection
#"\"#{uuid}\" [label=\"#{rsc}\\n#{uuid}\",href=\"#{href}\"];\n"
if rsc == Collection
@@
-44,11
+57,12
@@
module ProvenanceHelper
#puts "empty!"
return "\"#{uuid}\" [label=\"(empty collection)\"];\n"
end
#puts "empty!"
return "\"#{uuid}\" [label=\"(empty collection)\"];\n"
end
+ puts "#{uuid.class} #{@pdata[uuid]}"
if @pdata[uuid]
#puts @pdata[uuid]
if @pdata[uuid][:name]
return "\"#{uuid}\" [label=\"#{@pdata[uuid][:name]}\",href=\"#{href}\",shape=oval,#{bgcolor}];\n"
if @pdata[uuid]
#puts @pdata[uuid]
if @pdata[uuid][:name]
return "\"#{uuid}\" [label=\"#{@pdata[uuid][:name]}\",href=\"#{href}\",shape=oval,#{bgcolor}];\n"
- else
+ else
files = nil
if @pdata[uuid].respond_to? :files
files = @pdata[uuid].files
files = nil
if @pdata[uuid].respond_to? :files
files = @pdata[uuid].files
@@
-67,12
+81,13
@@
module ProvenanceHelper
if i < files.length
label += "\\n⋮"
end
if i < files.length
label += "\\n⋮"
end
+ #puts "#{uuid} #{label} #{files}"
return "\"#{uuid}\" [label=\"#{label}\",href=\"#{href}\",shape=oval,#{bgcolor}];\n"
end
end
end
return "\"#{uuid}\" [label=\"#{label}\",href=\"#{href}\",shape=oval,#{bgcolor}];\n"
end
end
end
- return "\"#{uuid}\" [label=\"#{rsc}\",href=\"#{href}\",#{bgcolor}];\n"
end
end
+ return "\"#{uuid}\" [label=\"#{rsc}\",href=\"#{href}\",#{bgcolor}];\n"
end
"\"#{uuid}\" [#{bgcolor}];\n"
end
end
"\"#{uuid}\" [#{bgcolor}];\n"
end
@@
-99,7
+114,7
@@
module ProvenanceHelper
gr = "\"#{head}\" -> \"#{tail}\""
end
if extra.length > 0
gr = "\"#{head}\" -> \"#{tail}\""
end
if extra.length > 0
- gr += "["
+ gr += "
["
extra.each do |k, v|
gr += "#{k}=\"#{v}\","
end
extra.each do |k, v|
gr += "#{k}=\"#{v}\","
end
@@
-209,6
+224,8
@@
module ProvenanceHelper
gr += edge(job_uuid(job), job[:script_version], {:label => "script_version"})
end
end
gr += edge(job_uuid(job), job[:script_version], {:label => "script_version"})
end
end
+ elsif rsc == Link
+ # do nothing
else
gr += describe_node(uuid)
end
else
gr += describe_node(uuid)
end
@@
-216,8
+233,12
@@
module ProvenanceHelper
@pdata.each do |k, link|
if link[:head_uuid] == uuid.to_s and link[:link_class] == "provenance"
@pdata.each do |k, link|
if link[:head_uuid] == uuid.to_s and link[:link_class] == "provenance"
+ href = url_for ({:controller => Link.to_s.tableize,
+ :action => :show,
+ :id => link[:uuid] })
+
gr += describe_node(link[:tail_uuid])
gr += describe_node(link[:tail_uuid])
- gr += edge(link[:head_uuid], link[:tail_uuid], {:label => link[:name], :href =>
"/links/#{link[:uuid]}"
})
+ gr += edge(link[:head_uuid], link[:tail_uuid], {:label => link[:name], :href =>
href
})
gr += generate_provenance_edges(link[:tail_uuid])
end
end
gr += generate_provenance_edges(link[:tail_uuid])
end
end
@@
-230,7
+251,10
@@
module ProvenanceHelper
def describe_jobs
gr = ""
@jobs.each do |k, v|
def describe_jobs
gr = ""
@jobs.each do |k, v|
- gr += "\"#{k}\" [href=\"/jobs?"
+ href = url_for ({:controller => Job.to_s.tableize,
+ :action => :index })
+
+ gr += "\"#{k}\" [href=\"#{href}?"
n = 0
v.each do |u|
n = 0
v.each do |u|
@@
-241,11
+265,11
@@
module ProvenanceHelper
gr += "\",label=\""
if @opts[:combine_jobs] == :script_only
gr += "\",label=\""
if @opts[:combine_jobs] == :script_only
- gr +=
uuid =
"#{v[0][:script]}"
+ gr += "#{v[0][:script]}"
elsif @opts[:combine_jobs] == :script_and_version
elsif @opts[:combine_jobs] == :script_and_version
- gr +=
uuid = "#{v[0][:script]}"
+ gr +=
"#{v[0][:script]}" # Just show the name but the nodes will be distinct
else
else
- gr +=
uuid =
"#{v[0][:script]}\\n#{v[0][:finished_at]}"
+ gr += "#{v[0][:script]}\\n#{v[0][:finished_at]}"
end
gr += "\",#{determine_fillcolor n}];\n"
end
end
gr += "\",#{determine_fillcolor n}];\n"
end
@@
-289,8
+313,8
@@
edge [fontsize=10];
gr += "}"
svg = ""
gr += "}"
svg = ""
-
#
puts gr
-
+ puts gr
+
require 'open3'
Open3.popen2("dot", "-Tsvg") do |stdin, stdout, wait_thr|
require 'open3'
Open3.popen2("dot", "-Tsvg") do |stdin, stdout, wait_thr|