6277: add default_empty_manifest before_validation filter and update the tests accord...
[arvados.git] / services / api / app / models / pipeline_instance.rb
index 185bf02d412e9f11d6d9f23ff37a893273126616..77a0736b000d669d298abc93ad95d12417e8a3d1 100644 (file)
@@ -8,20 +8,21 @@ class PipelineInstance < ArvadosModel
   belongs_to :pipeline_template, :foreign_key => :pipeline_template_uuid, :primary_key => :uuid
 
   before_validation :bootstrap_components
-  before_validation :update_success
+  before_validation :update_state
   before_validation :verify_status
   before_create :set_state_before_save
   before_save :set_state_before_save
 
   api_accessible :user, extend: :common do |t|
     t.add :pipeline_template_uuid
-    t.add :pipeline_template, :if => :pipeline_template
     t.add :name
     t.add :components
-    t.add :dependencies
     t.add :properties
     t.add :state
     t.add :components_summary
+    t.add :description
+    t.add :started_at
+    t.add :finished_at
   end
 
   # Supported states for a pipeline instance
@@ -36,10 +37,6 @@ class PipelineInstance < ArvadosModel
      (Complete = 'Complete'),
     ]
 
-  def dependencies
-    dependency_search(self.components).keys
-  end
-
   # if all components have input, the pipeline is Ready
   def components_look_ready?
     if !self.components || self.components.empty?
@@ -78,7 +75,7 @@ class PipelineInstance < ArvadosModel
         else
           row << 0.0
           if step['failed']
-            self.success = false
+            self.state = Failed
           end
         end
         row << (step['warehousejob']['id'] rescue nil)
@@ -109,33 +106,9 @@ class PipelineInstance < ArvadosModel
     end
   end
 
-  def update_success
+  def update_state
     if components and progress_ratio == 1.0
-      self.success = true
-    end
-  end
-
-  def dependency_search(haystack)
-    if haystack.is_a? String
-      if (re = haystack.match /^([0-9a-f]{32}(\+[^,]+)*)+/)
-        {re[1] => true}
-      else
-        {}
-      end
-    elsif haystack.is_a? Array
-      deps = {}
-      haystack.each do |value|
-        deps.merge! dependency_search(value)
-      end
-      deps
-    elsif haystack.respond_to? :keys
-      deps = {}
-      haystack.each do |key, value|
-        deps.merge! dependency_search(value)
-      end
-      deps
-    else
-      {}
+      self.state = Complete
     end
   end
 
@@ -158,9 +131,9 @@ class PipelineInstance < ArvadosModel
   end
 
   def set_state_before_save
-      if self.components_look_ready? && (!self.state || self.state == New)
-        self.state = Ready
-      end
+    if self.components_look_ready? && (!self.state || self.state == New)
+      self.state = Ready
+    end
   end
 
 end