Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added qos option to torque and slurm #205

Merged
merged 2 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ood_core/job/adapters/slurm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
args.concat ["-A", script.accounting_id] unless script.accounting_id.nil?
args.concat ["-t", seconds_to_duration(script.wall_time)] unless script.wall_time.nil?
args.concat ['-a', script.job_array_request] unless script.job_array_request.nil?
args.concat ['--qos', script.qos] unless script.qos.nil?
# ignore nodes, don't know how to do this for slurm

# Set dependencies
Expand Down
1 change: 1 addition & 0 deletions lib/ood_core/job/adapters/torque.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
args.concat ["-W", "depend=#{depend.join(",")}"] unless depend.empty?
args.concat ["-l", "walltime=#{seconds_to_duration(script.wall_time)}"] unless script.wall_time.nil?
args.concat ['-t', script.job_array_request] unless script.job_array_request.nil?
args.concat ['-l', "qos=#{script.qos}"] unless script.qos.nil?
# Set environment variables
env = script.job_environment.to_h
args.concat ["-v", env.keys.join(",")] unless env.empty?
Expand Down
10 changes: 9 additions & 1 deletion lib/ood_core/job/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class Script
# @return [String, nil] job array request
attr_reader :job_array_request

# The qos selected for the job
# @return [String, nil] qos
attr_reader :qos

# Object detailing any native specifications that are implementation specific
# @note Should not be used at all costs.
# @return [Object, nil] native specifications
Expand Down Expand Up @@ -130,6 +134,8 @@ class Script
# @param start_time [#to_i, nil] eligible start time
# @param wall_time [#to_i, nil] max real time
# @param accounting_id [#to_s, nil] accounting id
# @param job_array_request [#to_s, nil] job array request
# @param qos [#to_s, nil] qos
# @param native [Object, nil] native specifications
# @param copy_environment [Boolean, nil] copy the environment
def initialize(content:, args: nil, submit_as_hold: nil, rerunnable: nil,
Expand All @@ -139,7 +145,7 @@ def initialize(content:, args: nil, submit_as_hold: nil, rerunnable: nil,
output_path: nil, error_path: nil, reservation_id: nil,
queue_name: nil, priority: nil, start_time: nil,
wall_time: nil, accounting_id: nil, job_array_request: nil,
native: nil, copy_environment: nil, **_)
qos: nil, native: nil, copy_environment: nil, **_)
@content = content.to_s

@submit_as_hold = submit_as_hold
Expand All @@ -163,6 +169,7 @@ def initialize(content:, args: nil, submit_as_hold: nil, rerunnable: nil,
@wall_time = wall_time && wall_time.to_i
@accounting_id = accounting_id && accounting_id.to_s
@job_array_request = job_array_request && job_array_request.to_s
@qos = qos && qos.to_s
@native = native
@copy_environment = (copy_environment.nil?) ? nil : !! copy_environment
end
Expand Down Expand Up @@ -192,6 +199,7 @@ def to_h
wall_time: wall_time,
accounting_id: accounting_id,
job_array_request: job_array_request,
qos: qos,
native: native,
copy_environment: copy_environment
}
Expand Down
6 changes: 6 additions & 0 deletions spec/job/adapters/slurm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ def build_script(opts = {})
it { expect(slurm).to have_received(:submit_string).with(content, args: ["--export", "NONE", "A", "B", "C"], env: {}) }
end

context "with :qos" do
before { adapter.submit(build_script(qos: 'high')) }

it { expect(slurm).to have_received(:submit_string).with(content, args:["--qos", "high", "--export", "NONE"], env: {})}
end

%i(after afterok afternotok afterany).each do |after|
context "and :#{after} is defined as a single job id" do
before { adapter.submit(build_script, after => "job_id") }
Expand Down
6 changes: 6 additions & 0 deletions spec/job/adapters/torque_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ def build_script(opts = {})
it { expect(pbs).to have_received(:submit).with(content, args: ["-l", "walltime=26:15:34", "-j", "oe"], env: {}, chdir: nil) }
end

context "with :qos" do
before { adapter.submit(build_script(qos: "high")) }

it { expect(pbs).to have_received(:submit).with(content, args: ["-l", "qos=high", "-j", "oe"], env: {}, chdir: nil)}
end

context "with :native" do
before { adapter.submit(build_script(native: ["A", "B", "C"])) }

Expand Down