Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika@curoverse.com>
[arvados.git] / apps / workbench / app / models / pipeline_instance_work_unit.rb
index 578e193c6e08315cdec182dc00703435b2838aeb..517dbc7a352a78502117c85662cc1e7318739eb8 100644 (file)
@@ -1,9 +1,15 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 class PipelineInstanceWorkUnit < ProxyWorkUnit
   def children
+    return @my_children if @my_children
+
     items = []
 
     jobs = {}
-    results = Job.where(uuid: self.proxied.job_ids.values).results
+    results = Job.where(uuid: @proxied.job_ids.values).results
     results.each do |j|
       jobs[j.uuid] = j
     end
@@ -16,45 +22,29 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
           if job[:uuid] and jobs[job[:uuid]]
             items << jobs[job[:uuid]].work_unit(name)
           else
-            items << JobWorkUnit.new(job, name)
+            items << JobWorkUnit.new(job, name, uuid)
           end
         else
-          items << ProxyWorkUnit.new(c, name)
+          items << JobWorkUnit.new(c, name, uuid)
         end
       else
-        self.unreadable_children = true
+        @unreadable_children = true
         break
       end
     end
 
-    items
+    @my_children = items
   end
 
-  def progress
-    state = get(:state)
-    if state == 'Complete'
-      return 1.0
-    end
-
-    done = 0
-    failed = 0
-    todo = 0
-    children.each do |c|
-      if c.success?.nil?
-        todo = todo+1
-      elsif c.success?
-        done = done+1
-      else
-        failed = failed+1
+  def outputs
+    items = []
+    components = get(:components)
+    components.each do |name, c|
+      if c.is_a?(Hash)
+        items << c[:output_uuid] if c[:output_uuid]
       end
     end
-
-    if done + failed + todo > 0
-      total = done + failed + todo
-      (done+failed).to_f / total
-    else
-      0.0
-    end
+    items
   end
 
   def uri
@@ -65,4 +55,8 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
   def title
     "pipeline"
   end
+
+  def template_uuid
+    get(:pipeline_template_uuid)
+  end
 end