2875: add description to jobs and pipeline_instances.
[arvados.git] / services / api / app / models / job.rb
index 1ef0b797c044574a2b9eba72e1fcbd0aeba77e16..32f28e3582d509930a4bdf3339659035f6d9b5d5 100644 (file)
@@ -8,6 +8,7 @@ class Job < ArvadosModel
   serialize :tasks_summary, Hash
   before_create :ensure_unique_submit_id
   after_commit :trigger_crunch_dispatch_if_cancelled, :on => :update
+  before_validation :set_priority
   validate :ensure_script_version_is_commit
   validate :find_docker_image_locator
 
@@ -28,7 +29,6 @@ class Job < ArvadosModel
     t.add :started_at
     t.add :finished_at
     t.add :output
-    t.add :output_is_persistent
     t.add :success
     t.add :running
     t.add :is_locked_by_uuid
@@ -40,6 +40,7 @@ class Job < ArvadosModel
     t.add :repository
     t.add :supplied_script_version
     t.add :docker_image_locator
+    t.add :description
   end
 
   def assert_finished
@@ -73,6 +74,13 @@ class Job < ArvadosModel
     super + %w(output log)
   end
 
+  def set_priority
+    if self.priority.nil?
+      self.priority = 0
+    end
+    true
+  end
+
   def ensure_script_version_is_commit
     if self.is_locked_by_uuid and self.started_at
       # Apparently client has already decided to go for it. This is
@@ -118,7 +126,7 @@ class Job < ArvadosModel
       self.docker_image_locator = nil
       true
     elsif coll = Collection.for_latest_docker_image(image_search, image_tag)
-      self.docker_image_locator = coll.uuid
+      self.docker_image_locator = coll.portable_data_hash
       true
     else
       errors.add(:docker_image_locator, "not found for #{image_search}")