projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixes and docs for testing crunch jobs locally
[arvados.git]
/
services
/
api
/
app
/
models
/
job.rb
diff --git
a/services/api/app/models/job.rb
b/services/api/app/models/job.rb
index a50c43c3e0bcb07273edad0279c9694b6c21ebf3..e2fc19e852062b4f42267f3ebf8806c1205b3de9 100644
(file)
--- a/
services/api/app/models/job.rb
+++ b/
services/api/app/models/job.rb
@@
-7,6
+7,7
@@
class Job < ArvadosModel
serialize :tasks_summary, Hash
before_create :ensure_unique_submit_id
before_create :ensure_script_version_is_commit
serialize :tasks_summary, Hash
before_create :ensure_unique_submit_id
before_create :ensure_script_version_is_commit
+ before_update :ensure_script_version_is_commit
has_many :commit_ancestors, :foreign_key => :descendant, :primary_key => :script_version
has_many :commit_ancestors, :foreign_key => :descendant, :primary_key => :script_version
@@
-40,9
+41,21
@@
class Job < ArvadosModel
running: false)
end
running: false)
end
+ def self.queue
+ self.where('started_at is ? and is_locked_by is ? and cancelled_at is ?',
+ nil, nil, nil).
+ order('priority desc, created_at')
+ end
+
protected
def ensure_script_version_is_commit
protected
def ensure_script_version_is_commit
+ if self.is_locked_by and self.started_at
+ # Apparently client has already decided to go for it. This is
+ # needed to run a local job using a local working directory
+ # instead of a commit-ish.
+ return true
+ end
sha1 = Commit.find_by_commit_ish(self.script_version) rescue nil
if sha1
self.script_version = sha1
sha1 = Commit.find_by_commit_ish(self.script_version) rescue nil
if sha1
self.script_version = sha1