[ARVADOS] created: 93c92875aaebe5b06f8dbfe2822b59a772895c08

Git user git at public.curoverse.com
Mon Apr 24 15:30:50 EDT 2017


        at  93c92875aaebe5b06f8dbfe2822b59a772895c08 (commit)


commit 93c92875aaebe5b06f8dbfe2822b59a772895c08
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Mon Apr 24 16:30:00 2017 -0300

    10111: Added provenance graph for container requests.

diff --git a/apps/workbench/app/controllers/container_requests_controller.rb b/apps/workbench/app/controllers/container_requests_controller.rb
index b286a94..817f882 100644
--- a/apps/workbench/app/controllers/container_requests_controller.rb
+++ b/apps/workbench/app/controllers/container_requests_controller.rb
@@ -4,14 +4,32 @@ class ContainerRequestsController < ApplicationController
     'show' == ctrl.action_name
   }
 
+  def generate_provenance(cr)
+    return if params['tab_pane'] != "Provenance"
+
+    nodes = {}
+    nodes[cr[:uuid]] = cr
+    @svg = ProvenanceHelper::create_provenance_graph nodes,
+                                                     "provenance_svg",
+                                                     {
+                                                       :request => request,
+                                                       :direction => :top_down,
+                                                     }
+  end
+
   def show_pane_list
-    panes = %w(Status Log Advanced)
+    panes = %w(Status Log Provenance Advanced)
     if @object.andand.state == 'Uncommitted'
-      panes = %w(Inputs) + panes - %w(Log)
+      panes = %w(Inputs) + panes - %w(Log Provenance)
     end
     panes
   end
 
+  def show
+    generate_provenance(@object)
+    super
+  end
+
   def cancel
     @object.update_attributes! priority: 0
     if params[:return_to]
diff --git a/apps/workbench/app/helpers/provenance_helper.rb b/apps/workbench/app/helpers/provenance_helper.rb
index a4723a3..31d0203 100644
--- a/apps/workbench/app/helpers/provenance_helper.rb
+++ b/apps/workbench/app/helpers/provenance_helper.rb
@@ -104,6 +104,53 @@ module ProvenanceHelper
       gr
     end
 
+    def cr_edges cr
+      uuid = cr[:uuid]
+      gr = ""
+
+      ProvenanceHelper::find_collections cr[:mounts], 'mounts' do |col_hash, col_uuid, key|
+        if col_uuid
+          gr += describe_node(col_uuid)
+          gr += edge(col_uuid, uuid, {:label => key})
+        else
+          gr += describe_node(col_hash)
+          gr += edge(col_hash, uuid, {:label => key})
+        end
+      end
+
+      [
+        [true, :requesting_container_uuid, 'requesting_container'],
+        [true, :container_image, 'container_image'],
+        [false, :output_uuid, 'output'],
+        [false, :log_uuid, 'log']
+      ].each do |is_input, attr, label|
+        if cr[attr]
+          if attr == :container_image && cr[:container_uuid]
+            # Extract the container_image's UUID from the CR's container
+            cont = Container.find(cr[:container_uuid])
+            gr += describe_node(cont[:container_image], {label: cr[attr]})
+            # If container_image, then is_input is true
+            edge_from = cont[:container_image]
+            edge_to = uuid
+          else
+            # Default case
+            gr += describe_node(cr[attr])
+
+            if is_input
+              edge_from = cr[attr]
+              edge_to = uuid
+            else
+              edge_from = uuid
+              edge_to = cr[attr]
+            end
+          end
+          gr += edge(edge_from, edge_to, {label: label})
+        end
+      end
+
+      gr
+    end
+
     def job_edges job, edge_opts={}
       uuid = job_uuid(job)
       gr = ""
@@ -184,6 +231,13 @@ module ProvenanceHelper
         if rsc == Job
           job = @pdata[uuid]
           gr += job_edges job if job
+        elsif rsc == ContainerRequest
+          cr = @pdata[uuid]
+          gr += cr_edges cr if cr
+          gr += describe_node(uuid, {href: {controller: 'container_requests',
+                                            id: uuid},
+                                     label: @pdata[uuid][:name],
+                                     shape: 'oval'})
         end
       end
 
diff --git a/apps/workbench/app/views/container_requests/_show_provenance.html.erb b/apps/workbench/app/views/container_requests/_show_provenance.html.erb
new file mode 100644
index 0000000..253af56
--- /dev/null
+++ b/apps/workbench/app/views/container_requests/_show_provenance.html.erb
@@ -0,0 +1,4 @@
+<%= render partial: 'application/svg_div', locals: {
+      divId: "provenance_graph", 
+      svgId: "provenance_svg", 
+      svg: @svg } %>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list