X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/bfa9ee952c1ae3f03fe2f9fa781a132411963030..e7973cab8f9fc9531e4d928e73928e6eab022f48:/services/api/app/models/pipeline_instance.rb diff --git a/services/api/app/models/pipeline_instance.rb b/services/api/app/models/pipeline_instance.rb index e5bd46448f..752391862a 100644 --- a/services/api/app/models/pipeline_instance.rb +++ b/services/api/app/models/pipeline_instance.rb @@ -1,5 +1,5 @@ class PipelineInstance < ArvadosModel - include AssignUuid + include HasUuid include KindAndEtag include CommonApiTemplate serialize :components, Hash @@ -8,7 +8,7 @@ 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 @@ -18,12 +18,12 @@ class PipelineInstance < ArvadosModel t.add :pipeline_template, :if => :pipeline_template t.add :name t.add :components - t.add :success - t.add :active t.add :dependencies t.add :properties t.add :state t.add :components_summary + t.add :started_at + t.add :finished_at end # Supported states for a pipeline instance @@ -80,7 +80,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) @@ -111,9 +111,9 @@ class PipelineInstance < ArvadosModel end end - def update_success + def update_state if components and progress_ratio == 1.0 - self.success = true + self.state = Complete end end @@ -144,58 +144,9 @@ class PipelineInstance < ArvadosModel def verify_status changed_attributes = self.changed - if 'state'.in? changed_attributes - case self.state - when New, Ready, Paused - self.active = nil - self.success = nil - when RunningOnServer - self.active = true - self.success = nil - when RunningOnClient - self.active = nil - self.success = nil - when Failed - self.active = false - self.success = false - self.state = Failed # before_validation will fail if false is returned in the previous line - when Complete - self.active = false - self.success = true - else - return false - end - elsif 'success'.in? changed_attributes - if self.success - self.active = false - self.state = Complete - else - self.active = false - self.state = Failed - end - elsif 'active'.in? changed_attributes - if self.active - if self.state.in? [New, Ready, Paused] - self.state = RunningOnServer - end - else - if self.state == RunningOnServer # state was RunningOnServer - self.active = nil - self.state = Paused - elsif self.components_look_ready? - self.state = Ready - else - self.state = New - end - end - elsif new_record? and self.state.nil? - # No state, active, or success given - self.state = New - end - if new_record? or 'components'.in? changed_attributes - state ||= New - if state == New and self.components_look_ready? + self.state ||= New + if (self.state == New) and self.components_look_ready? self.state = Ready end end @@ -209,12 +160,8 @@ class PipelineInstance < ArvadosModel end def set_state_before_save - if !self.state || self.state == New || self.state == Ready || self.state == Paused - if self.active - self.state = RunningOnServer - elsif 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