Module: PBS
- Extended by:
- SchedulerJob
- Defined in:
- lib/scout/workflow/deployment/scheduler/pbs.rb
Instance Attribute Summary
Attributes included from SchedulerJob
Class Method Summary collapse
- .batch_system_variables ⇒ Object
- .header(options = {}) ⇒ Object
- .job_status(job = nil) ⇒ Object
- .run_template(batch_dir, dry_run) ⇒ Object
- .system ⇒ Object
Methods included from SchedulerJob
batch_dir_for_id, batch_options, cleanup_environment, coda, exec_cmd, execute, follow_job, hold_dependencies, job_queued, job_template, jobs, load_conda, load_modules, meta_data, prepare_environment, prepare_submision, run_job, scout_job_exec_cmd, sync_environment, wait_for_job
Class Method Details
.batch_system_variables ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/scout/workflow/deployment/scheduler/pbs.rb', line 11 def self.batch_system_variables "let TOTAL_PROCESORS=\"$(cat /proc/cpuinfo|grep ^processor |wc -l)\"\nlet MAX_MEMORY_DEFAULT=\"$(grep MemTotal /proc/meminfo|grep -o \"[[:digit:]]*\") / ( (1024 * $TOTAL_PROCESORS) / $PBS_CPUS_PER_TASK )\"\nMAX_MEMORY=\"$MAX_MEMORY_DEFAULT\"\n[ ! -z $PBS_MEM_PER_CPU ] && let MAX_MEMORY=\"$PBS_MEM_PER_CPU * $PBS_CPUS_PER_TASK\" \n[ ! -z $PBS_MEM_PER_NODE ] && MAX_MEMORY=\"$PBS_MEM_PER_NODE\"\nexport MAX_MEMORY_DEFAULT\nexport MAX_MEMORY\nexport BATCH_JOB_ID=$PBS_JOBID\nexport BATCH_SYSTEM=\#{system}\n\ncd ${PBS_O_WORKDIR}\n EOF\nend\n" |
.header(options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/scout/workflow/deployment/scheduler/pbs.rb', line 27 def self.header( = {}) = .dup workdir = IndiferentHash. , :workdir batch_dir = IndiferentHash. , :batch_dir batch_name = IndiferentHash. , :batch_name queue = IndiferentHash. , :queue account = IndiferentHash. , :account time = IndiferentHash. , :time nodes = IndiferentHash. , :nodes # PBS place = IndiferentHash. , :place, :place => 'scatter' system = IndiferentHash. , :partition filesystems = IndiferentHash. , :filesystems filesystems = "home" if filesystems.nil? filesystems = filesystems * "," if Array === filesystems # NOT USED partition = IndiferentHash. , :partition task_cpus = IndiferentHash. , :task_cpus exclusive = IndiferentHash. , :exclusive highmem = IndiferentHash. , :highmem licenses = IndiferentHash. , :licenses constraint = IndiferentHash. , :constraint gres = IndiferentHash. , :gres constraint = [constraint, "highmem"].compact * "&" if highmem mem = IndiferentHash. , :mem mem_per_cpu = IndiferentHash. , :mem_per_cpu fout = File.join(batch_dir, 'std.out') ferr = File.join(batch_dir, 'std.err') time = Misc.format_seconds Misc.timespan(time) unless time.include? ":" qsub_params = { "-l filesystems=" => filesystems, "-l system=" => system, "-l select=" => nodes, "-l place=" => place, "-l walltime=" => time, "-q " => queue, "-A " => account, "-o " => fout, "-e " => ferr, "-k doe" => true, # "cpus-per-task" => task_cpus, # "nodes" => nodes, # "time" => time, # "constraint" => constraint, # "exclusive" => exclusive, # "licenses" => licenses, # "gres" => gres, # "mem" => mem, # "mem-per-cpu" => mem_per_cpu, } header ="#!/bin/bash\n EOF\n\n qsub_params.each do |name,value|\n next if value.nil? || value == \"\"\n if TrueClass === value\n header << \"#PBS \#{name}\" << \"\\n\"\n elsif Array === value\n value.each do |v|\n header << \"#PBS \#{name}\\\"\#{v}\\\"\" << \"\\n\"\n end\n else\n header << \"#PBS \#{name}\\\"\#{value}\\\"\" << \"\\n\"\n end\n end\n\n header\nend\n" |
.job_status(job = nil) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/scout/workflow/deployment/scheduler/pbs.rb', line 163 def self.job_status(job = nil) if job.nil? CMD.cmd("qstat").read else begin CMD.cmd("qstat #{job}").read rescue "" end end end |
.run_template(batch_dir, dry_run) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/scout/workflow/deployment/scheduler/pbs.rb', line 109 def self.run_template(batch_dir, dry_run) fout = File.join(batch_dir, 'std.out') ferr = File.join(batch_dir, 'std.err') fjob = File.join(batch_dir, 'job.id') fdep = File.join(batch_dir, 'dependencies.list') fcfdep = File.join(batch_dir, 'canfail_dependencies.list') fexit = File.join(batch_dir, 'exit.status') fsync = File.join(batch_dir, 'sync.log') fcmd = File.join(batch_dir, 'command.batch') return if Open.exists?(fexit) Log.info "Issuing PBS file: #{fcmd}" Log.debug Open.read(fcmd) if File.exist?(fjob) job = Open.read(fjob).to_i else dependencies = Open.read(fdep).split("\n") if File.exist? fdep canfail_dependencies = Open.read(fcfdep).split("\n") if File.exist? fcfdep normal_dep_str = dependencies && dependencies.any? ? "afterok:" + dependencies * ":" : nil canfail_dep_str = canfail_dependencies && canfail_dependencies.any? ? "afterany:" + canfail_dependencies * ":" : nil if normal_dep_str.nil? && canfail_dep_str.nil? dep_str = "" else dep_str = '-W depend=' + [normal_dep_str, canfail_dep_str].compact * "," end cmd = "qsub #{dep_str} '#{fcmd}'" if File.exist?(fout) return elsif dry_run STDERR.puts Log.color(:magenta, "To execute run: ") + Log.color(:blue, "squb '#{fcmd}'") STDERR.puts Log.color(:magenta, "To monitor progress run (needs local rbbt): ") + Log.color(:blue, "rbbt pbs tail '#{batch_dir}'") raise DryRun, batch_dir else Open.rm fsync Open.rm fexit Open.rm fout Open.rm ferr job = CMD.cmd(cmd).read.scan(/\d+/).first.to_i Log.debug "SBATCH job id: #{job}" Open.write(fjob, job.to_s) job end end end |
.system ⇒ Object
7 8 9 |
# File 'lib/scout/workflow/deployment/scheduler/pbs.rb', line 7 def self.system "PBS" end |