From e130e62a0d042ca653dadc0a2274627360328c4a Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Sun, 17 Mar 2013 17:48:25 -0700 Subject: [PATCH] add Jobs#resource_limits attribute. refs #1417 --- app/controllers/orvos/v1/jobs_controller.rb | 3 +++ app/models/job.rb | 1 + .../20130318002138_add_resource_limits_to_jobs.rb | 5 +++++ db/schema.rb | 3 ++- script/dispatch_jobs.rb | 12 +++++++++++- 5 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20130318002138_add_resource_limits_to_jobs.rb diff --git a/app/controllers/orvos/v1/jobs_controller.rb b/app/controllers/orvos/v1/jobs_controller.rb index 33425eb5d5..96e22ff49e 100644 --- a/app/controllers/orvos/v1/jobs_controller.rb +++ b/app/controllers/orvos/v1/jobs_controller.rb @@ -1,2 +1,5 @@ class Orvos::V1::JobsController < ApplicationController + accept_attribute_as_json :command_parameters, Hash + accept_attribute_as_json :resource_limits, Hash + accept_attribute_as_json :tasks_summary, Hash end diff --git a/app/models/job.rb b/app/models/job.rb index d0173ee4dc..e0a096aa61 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -3,6 +3,7 @@ class Job < OrvosModel include KindAndEtag include CommonApiTemplate serialize :command_parameters, Hash + serialize :resource_limits, Hash serialize :tasks_summary, Hash before_create :ensure_unique_submit_id diff --git a/db/migrate/20130318002138_add_resource_limits_to_jobs.rb b/db/migrate/20130318002138_add_resource_limits_to_jobs.rb new file mode 100644 index 0000000000..f7bd04be6d --- /dev/null +++ b/db/migrate/20130318002138_add_resource_limits_to_jobs.rb @@ -0,0 +1,5 @@ +class AddResourceLimitsToJobs < ActiveRecord::Migration + def change + add_column :jobs, :resource_limits, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index c5720ea54c..cab044df8c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130315213205) do +ActiveRecord::Schema.define(:version => 20130318002138) do create_table "api_client_authorizations", :force => true do |t| t.string "api_token", :null => false @@ -131,6 +131,7 @@ ActiveRecord::Schema.define(:version => 20130315213205) do t.string "is_locked_by" t.string "log" t.text "tasks_summary" + t.text "resource_limits" end add_index "jobs", ["command"], :name => "index_jobs_on_command" diff --git a/script/dispatch_jobs.rb b/script/dispatch_jobs.rb index 0eea8d57cc..e39ef31131 100755 --- a/script/dispatch_jobs.rb +++ b/script/dispatch_jobs.rb @@ -48,7 +48,8 @@ class Dispatcher def refresh_todo @todo = Job. - where('started_at is ? and is_locked_by is ?', nil, nil). + where('started_at is ? and is_locked_by is ? and cancelled_at is ?', + nil, nil, nil). order('priority desc, created_at') end @@ -86,6 +87,15 @@ class Dispatcher cmd_args << "#{k}=#{v}" end cmd_args << "revision=#{job.command_version}" + + begin + cmd_args << "stepspernode=#{job.resource_limits['max_tasks_per_node'].to_i}" + rescue + # OK if limit is not specified. OK to ignore if not integer. + end + + $stderr.puts "dispatch: #{cmd_args.join ' '}" + begin i, o, e, t = Open3.popen3(*cmd_args) rescue -- 2.30.2