8876: add an integration with job with components.
authorradhika <radhika@curoverse.com>
Fri, 27 May 2016 14:50:55 +0000 (10:50 -0400)
committerradhika <radhika@curoverse.com>
Fri, 27 May 2016 14:50:55 +0000 (10:50 -0400)
apps/workbench/app/models/job.rb
apps/workbench/app/models/job_task.rb
apps/workbench/app/models/job_work_unit.rb
apps/workbench/app/models/pipeline_instance.rb
apps/workbench/app/views/work_unit/_component_detail.html.erb
apps/workbench/app/views/work_unit/_show_child.html.erb
apps/workbench/test/integration/jobs_test.rb
services/api/test/fixtures/jobs.yml

index b91c6bcc9d4cb5c111a8e9aa18de4cffe4034960..73f1f63be4c7d5dcb5fa33e390d722c87b16e0b0 100644 (file)
@@ -54,7 +54,7 @@ class Job < ArvadosBase
       flat_map { |log| log.properties[:text].split("\n") rescue [] }
   end
 
-  def work_unit(label="")
+  def work_unit(label=nil)
     JobWorkUnit.new(self, label)
   end
 end
index 44d4d45e7d869a29120e89f4c451c18b78f495c8..9fb04737badb1114547c0a6a581f71e9b2bbd459 100644 (file)
@@ -1,5 +1,5 @@
 class JobTask < ArvadosBase
-  def work_unit(label="")
+  def work_unit(label=nil)
     JobTaskWorkUnit.new(self, label)
   end
 end
index 9b0604857fe0b221588c91f4059d341e3f1db364..7f1c73f694fefb57fc52f157e73b62e1ac61c1f9 100644 (file)
@@ -1,15 +1,30 @@
 class JobWorkUnit < ProxyWorkUnit
   def children
-    # Job tasks
     uuid = get(:uuid)
-    tasks = JobTask.filter([['job_uuid', '=', uuid]]).results
     items = []
-    tasks.each do |t|
-      items << t.work_unit("task #{items.size}")
-    end
 
-    # Jobs submitted by this job  --  TBD
+    # Job tasks - for now do not include job tasks
+    # tasks = JobTask.filter([['job_uuid', '=', uuid]]).results
+    # tasks.each do |t|
+    #   items << t.work_unit("task #{items.size}")
+    # end
+
+    # Jobs components
+    components = get(:components)
+    uuids = components.andand.collect {|_, v| v}
+    return items if (!uuids or uuids.empty?)
 
+    rcs = {}
+    uuids.each do |u|
+      r = ArvadosBase::resource_class_for_uuid(u)
+      rcs[r] = [] unless rcs[r]
+      rcs[r] << u
+    end
+    rcs.each do |rc, ids|
+      rc.where(uuid: ids).each do |obj|
+        items << obj.work_unit(components.key(obj.uuid))
+      end
+    end
     items
   end
 
index f54b9f0c0084b257fae3d6d5e6b4a5f427068066..b51f07c40b36e0324b09e14c81dbf632dbcd7a68 100644 (file)
@@ -132,7 +132,7 @@ class PipelineInstance < ArvadosBase
     end
   end
 
-  def work_unit label
+  def work_unit(label=nil)
     PipelineInstanceWorkUnit.new(self, label || self.name)
   end
 
index 0d2f8007705f497773b78bd99daf820c348db403..eeb78f9511732412cb2a5f86553302b3d91fa396 100644 (file)
@@ -82,7 +82,7 @@
           </div>
         </div>
 
-        <% unless current_obj.parameters.nil? %>
+        <% if current_obj.parameters and !current_obj.parameters.empty? %>
         <div class="row">
           <div class="col-md-6">
             <p>script_parameters:</p>
index a38d9007927675dfa79e12b03fe7891b58846aa4..a93895ba8285a1b9ec524cd924d7b7b5f9c51b38 100644 (file)
@@ -84,7 +84,7 @@
             </div>
           <% end %>
 
-          <% if current_obj.state_label.in? ["Queued", "Running"] and @object.work_unit(@object.name).can_cancel? and @object.editable? %>
+          <% if current_obj.state_label.in? ["Queued", "Running"] and @object.work_unit.can_cancel? and @object.editable? %>
             <%# column offset 11 %>
             <div class="col-md-1 pipeline-instance-spacing">
               <%= form_tag "#{current_obj.uri}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
index 350e732fce489b3a8c999febb45e39293ea69c78..de04aa8c735494bf1853f56ef273f459ee836b26 100644 (file)
@@ -126,4 +126,46 @@ class JobsTest < ActionDispatch::IntegrationTest
       end
     end
   end
+
+  test 'view job with components' do
+    job = api_fixture('jobs')['running_job_with_components']
+    component1 = api_fixture('jobs')['completed_job_in_publicly_accessible_project']
+    component2 = api_fixture('pipeline_instances')['running_pipeline_with_complete_job']
+    component2_child1 = api_fixture('jobs')['previous_job_run']
+    component2_child2 = api_fixture('jobs')['running']
+
+    visit page_with_token("active", "/jobs/#{job['uuid']}")
+    assert page.has_text? job['script_version']
+    assert page.has_no_text? 'script_parameters'
+
+    click_link('component1')
+    within('#collapse1') do
+      assert(has_text? component1['uuid'])
+      assert(has_text? component1['script_version'])
+      assert(has_text? 'script_parameters')
+    end
+    click_link('component1')
+
+    click_link('component2')
+    within('#collapse2') do
+      assert(has_text? component2['uuid'])
+      assert(has_text? component2['script_version'])
+      assert(has_no_text? 'script_parameters')
+      assert(has_link? 'previous')
+      assert(has_link? 'running')
+
+      click_link('previous')
+      within('#collapse3') do
+        assert(has_text? component2_child1['uuid'])
+        assert(has_text? component2_child1['script_version'])
+      end
+      click_link('previous')
+
+      click_link('running')
+      within('#collapse4') do
+        assert(has_text? component2_child2['uuid'])
+        assert(has_text? component2_child2['script_version'])
+      end
+    end
+  end
 end
index 13fe1abba8b9bfc5903dc2ebf96a388be67226cf..d0c22d305954a2e832d3e8c4dac43725a982db26 100644 (file)
@@ -525,8 +525,8 @@ running_job_with_components:
   runtime_constraints: {}
   state: Running
   components:
-    component1: zzzzz-8i9sb-jobuuid00000001
-    component2: zzzzz-d1hrv-pipelineuuid001
+    component1: zzzzz-8i9sb-jyq01m7in1jlofj
+    component2: zzzzz-d1hrv-partdonepipelin
 
 # Test Helper trims the rest of the file