Class: SlurmManager2
Class Method Summary
collapse
Instance Method Summary
collapse
#asign_queue_id, #close_file, #create_file, #create_folder, descendants, #exec, #get_all_deps, #get_dependencies, #get_queue_system_dependencies, #get_relations_and_folders, #init_log, #initialize, #launch2queue_system, #launch_all_jobs, #launch_job_in_folder, #make_environment_file, #read_file, #rm_done_dependencies, select_manager, select_queue_manager, #sort_jobs_by_dependencies, #system_call, system_call, #write_file, #write_job
Constructor Details
This class inherits a constructor from QueueManager
Class Method Details
.available?(options) ⇒ Boolean
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/autoflow/queue_managers/slurm2_manager.rb', line 52
def self.available?(options)
available = false
shell_output = system_call("type 'sbatch'", nil, options[:remote], options[:ssh])
if !shell_output.empty?
shell_output = system_call("sbatch --version", nil, options[:remote], options[:ssh])
slurm_version = shell_output.split(' ').last.split('.').first.to_i available = true if slurm_version >= 20
end
return available
end
|
.priority ⇒ Object
63
64
65
|
# File 'lib/autoflow/queue_managers/slurm2_manager.rb', line 63
def self.priority
return 100
end
|
Instance Method Details
#get_queue_system_id(shell_output) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/autoflow/queue_managers/slurm2_manager.rb', line 43
def get_queue_system_id(shell_output)
queue_id = nil
shell_output.chomp!
shell_output =~ /Submitted batch job (\d+)/
queue_id = $1
raise("A queue id cannot be obtained. The queue manager has given this message:#{shell_output}") if queue_id.nil?
return queue_id
end
|
#parse_additional_options(string, attribs) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/autoflow/queue_managers/slurm2_manager.rb', line 4
def parse_additional_options(string, attribs)
expresions = %w[%C %T %M %N ]
values = [attribs[:cpu], attribs[:time], attribs[:mem], attribs[:node]]
new_string = string.dup
expresions.each_with_index do |exp, i|
new_string.gsub!(exp, "#{values[i]}")
end
return new_string
end
|
#submit_job(job, ar_dependencies) ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/autoflow/queue_managers/slurm2_manager.rb', line 33
def submit_job(job, ar_dependencies)
final_dep = get_all_deps(ar_dependencies)
dependencies = nil
dependencies='--dependency=afterok:'+final_dep.join(':') if !final_dep.empty?
cmd = "sbatch #{dependencies} #{job.name}.sh"
STDOUT.puts cmd if @show_submit
queue_id = get_queue_system_id(system_call(cmd, job.attrib[:exec_folder]))
return queue_id
end
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/autoflow/queue_managers/slurm2_manager.rb', line 14
def (id, job, sh_name)
if !job.attrib[:ntask]
write_file(sh_name, "#SBATCH --cpus-per-task=#{job.attrib[:cpu]}")
else
write_file(sh_name, "#SBATCH --ntasks=#{job.attrib[:cpu]}")
write_file(sh_name, "#SBATCH --nodes=#{job.attrib[:multinode]}") if job.attrib[:multinode] > 0
end
write_file(sh_name, "#SBATCH --mem=#{job.attrib[:mem]}")
write_file(sh_name, "#SBATCH --time=#{job.attrib[:time]}")
write_file(sh_name, "#SBATCH --constraint=#{job.attrib[:node]}") if !job.attrib[:node].nil?
write_file(sh_name, '#SBATCH --error=job.%J.err')
write_file(sh_name, '#SBATCH --output=job.%J.out')
write_file(sh_name, "#SBATCH --#{job.attrib[:additional_job_options][0]}=#{parse_additional_options(job.attrib[:additional_job_options][1], job.attrib)}") if !job.attrib[:additional_job_options].nil?
if job.attrib[:ntask]
write_file(sh_name, 'srun hostname -s > workers') if job.attrib[:cpu_asign] == 'list'
end
end
|