Module: LSF
- Extended by:
- SchedulerJob
- Defined in:
- lib/scout/workflow/deployment/scheduler/lfs.rb
Instance Attribute Summary
Attributes included from SchedulerJob
#batch_base_dir
Class Method Summary
collapse
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
|
# File 'lib/scout/workflow/deployment/scheduler/lfs.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) / $LSB_MAX_NUM_PROCESSORS )\"\n[ ! -z $LSB_MAX_MEM_RUSAGE ] && let MAX_MEMORY=\"$LSB_MAX_MEM_RUSAGE\" || MAX_MEMORY=\"$MAX_MEMORY_DEFAULT\"\nexport MAX_MEMORY_DEFAULT\nexport MAX_MEMORY\nexport BATCH_JOB_ID=$LSF_JOBID\nexport BATCH_SYSTEM=\#{system}\n EOF\nend\n"
|
23
24
25
26
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
|
# File 'lib/scout/workflow/deployment/scheduler/lfs.rb', line 23
def self.(options = {})
options = options.dup
queue = IndiferentHash.process_options options, :queue
task_cpus = IndiferentHash.process_options options, :task_cpus
time = IndiferentHash.process_options options, :time
nodes = IndiferentHash.process_options options, :nodes
workdir = IndiferentHash.process_options options, :workdir
exclusive = IndiferentHash.process_options options, :exclusive
batch_dir = IndiferentHash.process_options options, :batch_dir
batch_name = IndiferentHash.process_options options, :batch_name
batch_name ||= File.basename(batch_dir)
fout = File.join(batch_dir, 'std.out')
ferr = File.join(batch_dir, 'std.err')
time = Misc.format_seconds Misc.timespan(time) unless time.include? ":"
time = time.split(":").values_at(0, 1) * ":"
="#!/bin/bash\n#BSUB -J \"\#{batch_name}\"\n#BSUB -cwd \"\#{workdir}\"\n#BSUB -oo \"\#{fout}\"\n#BSUB -eo \"\#{ferr}\"\n#BSUB -q \"\#{queue}\"\n#BSUB -n \"\#{task_cpus}\"\n#BSUB -W \"\#{time}\"\n EOF\n\n header << \"#BSUB -x\" << \"\\n\" if exclusive\n\n header\nend\n"
|
.job_status(job = nil) ⇒ Object
117
118
119
120
121
122
123
|
# File 'lib/scout/workflow/deployment/scheduler/lfs.rb', line 117
def self.job_status(job = nil)
if job.nil?
CMD.cmd("bjobs -w").read
else
CMD.cmd("bjobs -w #{job}").read
end
end
|
.run_template(batch_dir, dry_run) ⇒ Object
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
108
109
110
111
112
113
114
115
|
# File 'lib/scout/workflow/deployment/scheduler/lfs.rb', line 60
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)
STDERR.puts Log.color(:magenta, "Issuing LSF file: #{fcmd}")
STDERR.puts 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_list = dependencies && dependencies.any? ? dependencies.collect{|d| "post_done(#{d})"} : []
canfail_dep_list = canfail_dependencies && canfail_dependencies.any? ? canfail_dependencies.collect{|d| "done(#{d})"} : []
dep_list = normal_dep_list + canfail_dep_list
if dep_list.any?
dep_str = '-w "' + dep_list * " && " + '"'
else
dep_str = ""
end
cmd = "bsub #{dep_str} < '#{fcmd}'"
if File.exist?(fout)
return
elsif dry_run
STDERR.puts Log.color(:magenta, "To execute run: ") + Log.color(:blue, cmd)
STDERR.puts Log.color(:magenta, "To monitor progress run (needs local scout): ") + Log.color(:blue, "scout lsf 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 "BSUB job id: #{job}"
Open.write(fjob, job.to_s)
job
end
end
end
|
.system ⇒ Object
7
8
9
|
# File 'lib/scout/workflow/deployment/scheduler/lfs.rb', line 7
def self.system
"LSF"
end
|