rbbt-util 5.39.0 → 5.40.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/hpc/batch.rb +13 -3
- data/lib/rbbt/hpc/lsf.rb +1 -1
- data/lib/rbbt/hpc/orchestrate/rules.rb +8 -1
- data/lib/rbbt/hpc/orchestrate.rb +21 -17
- data/lib/rbbt/hpc/pbs.rb +179 -0
- data/lib/rbbt/hpc/slurm.rb +1 -1
- data/lib/rbbt/hpc.rb +1 -0
- data/lib/rbbt/resource/util.rb +1 -1
- data/lib/rbbt/util/R/plot.rb +85 -0
- data/lib/rbbt/util/misc/development.rb +1 -1
- data/lib/rbbt/util/python/step.rb +41 -0
- data/lib/rbbt/util/python/util.rb +1 -1
- data/python/rbbt.py +8 -1
- data/share/Rlib/util.R +12 -0
- data/share/rbbt_commands/hpc/list +2 -0
- data/share/rbbt_commands/hpc/orchestrate +1 -1
- data/share/rbbt_commands/hpc/task +8 -7
- data/share/rbbt_commands/lsf/list +2 -0
- data/share/rbbt_commands/lsf/orchestrate +1 -1
- data/share/rbbt_commands/lsf/task +8 -7
- data/share/rbbt_commands/pbs/clean +212 -0
- data/share/rbbt_commands/pbs/list +362 -0
- data/share/rbbt_commands/pbs/orchestrate +92 -0
- data/share/rbbt_commands/pbs/tail +63 -0
- data/share/rbbt_commands/pbs/task +79 -0
- data/share/rbbt_commands/slurm/list +2 -0
- data/share/rbbt_commands/slurm/orchestrate +1 -1
- data/share/rbbt_commands/slurm/task +8 -7
- data/test/rbbt/hpc/test_pbs.rb +43 -0
- metadata +12 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f88968adb433164ce6c0180298f95bc1560c4260b7095660f8179bc0cafe1b1a
|
4
|
+
data.tar.gz: 92ab9d09861bb5569f70b13f1cc444158f87141c0024e5c3c623f06c1387745e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f64d85276194d276312b128dad1a62caf3b1500317429f4be288f4b1d617c105e07552c8fd8d0ea79660fa4b9ff7430a26329b5abfae7656abc6d432931ecf5
|
7
|
+
data.tar.gz: c228bea1369c1ec574d98cc33dadd1845ddb9f65f69e0e334935ef2f25ddfa0ecf2cf0a040e097d32d3472df2a7d5b2509541914170b1f59c33610fa39d0fd96
|
data/lib/rbbt/hpc/batch.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module HPC
|
2
|
-
class
|
2
|
+
class BATCH_DRY_RUN < Exception;
|
3
3
|
attr_accessor :directory
|
4
4
|
def initialize(directory)
|
5
5
|
@directory = directory
|
@@ -12,24 +12,32 @@ module HPC
|
|
12
12
|
HPC::SLURM
|
13
13
|
when 'lsf'
|
14
14
|
HPC::LSF
|
15
|
+
when 'pbs'
|
16
|
+
HPC::PBS
|
15
17
|
when 'auto'
|
16
18
|
case $previous_commands.last
|
17
19
|
when 'slurm'
|
18
20
|
HPC::SLURM
|
19
21
|
when 'lsf'
|
20
22
|
HPC::LSF
|
23
|
+
when 'pbs'
|
24
|
+
HPC::PBS
|
21
25
|
else
|
22
26
|
case Rbbt::Config.get(:batch_system, :batch, :batch_system, :hpc, :HPC, :BATCH).to_s.downcase
|
23
27
|
when 'slurm'
|
24
28
|
HPC::SLURM
|
25
29
|
when 'lsf'
|
26
30
|
HPC::LSF
|
31
|
+
when 'pbd'
|
32
|
+
HPC::PBS
|
27
33
|
else
|
28
34
|
case ENV["BATCH_SYSTEM"].to_s.downcase
|
29
35
|
when 'slurm'
|
30
36
|
HPC::SLURM
|
31
37
|
when 'lsf'
|
32
38
|
HPC::LSF
|
39
|
+
when 'pbs'
|
40
|
+
HPC::PBS
|
33
41
|
end
|
34
42
|
end
|
35
43
|
end
|
@@ -564,8 +572,8 @@ env > #{batch_options[:fenv]}
|
|
564
572
|
def run_job(job, options = {})
|
565
573
|
system = self.to_s.split("::").last
|
566
574
|
|
567
|
-
batch_base_dir, clean_batch_job, remove_batch_dir, procpath, tail, batch_dependencies, dry_run = Misc.process_options options,
|
568
|
-
:batch_base_dir, :clean_batch_job, :remove_batch_dir, :batch_procpath, :tail, :batch_dependencies, :dry_run,
|
575
|
+
batch_base_dir, clean_batch_job, remove_batch_dir, procpath, tail, batch_dependencies, dry_run, orchestration_rules_file = Misc.process_options options,
|
576
|
+
:batch_base_dir, :clean_batch_job, :remove_batch_dir, :batch_procpath, :tail, :batch_dependencies, :dry_run, :orchestration_rules,
|
569
577
|
:batch_base_dir => File.expand_path(File.join('~/rbbt-batch'))
|
570
578
|
|
571
579
|
if (batch_job = job.info[:batch_job]) && job_queued(batch_job)
|
@@ -586,6 +594,8 @@ env > #{batch_options[:fenv]}
|
|
586
594
|
workflow = job.original_workflow ||job.workflow
|
587
595
|
task_name = job.original_task_name || job.task_name
|
588
596
|
|
597
|
+
options = options.merge(HPC::Orchestration.job_rules(HPC::Orchestration.orchestration_rules(orchestration_rules_file), job)) if orchestration_rules_file
|
598
|
+
|
589
599
|
workflows_to_load = job.rec_dependencies.select{|d| Step === d}.collect{|d| d.workflow }.compact.collect(&:to_s) - [workflow.to_s]
|
590
600
|
|
591
601
|
TmpFile.with_file(nil, remove_batch_dir, :tmpdir => batch_base_dir, :prefix => "#{system}_rbbt_job-#{workflow.to_s}-#{task_name}-") do |batch_dir|
|
data/lib/rbbt/hpc/lsf.rb
CHANGED
@@ -99,7 +99,7 @@ export BATCH_SYSTEM=#{batch_system}
|
|
99
99
|
elsif dry_run
|
100
100
|
STDERR.puts Log.color(:magenta, "To execute run: ") + Log.color(:blue, cmd)
|
101
101
|
STDERR.puts Log.color(:magenta, "To monitor progress run (needs local rbbt): ") + Log.color(:blue, "rbbt lsf tail '#{batch_dir}'")
|
102
|
-
raise HPC::
|
102
|
+
raise HPC::BATCH_DRY_RUN, batch_dir
|
103
103
|
else
|
104
104
|
Open.rm fsync
|
105
105
|
Open.rm fexit
|
@@ -65,6 +65,13 @@ module HPC
|
|
65
65
|
merge_rules(rules[workflow][task], workflow_rules)
|
66
66
|
end
|
67
67
|
|
68
|
-
|
68
|
+
def self.job_rules(rules, job)
|
69
|
+
return {} if job.done? or job.error?
|
70
|
+
job_rules = task_specific_rules(rules, job.workflow.to_s, job.task_name.to_s)
|
71
|
+
job.dependencies.each do |dep|
|
72
|
+
job_rules = accumulate_rules(job_rules, job_rules(rules, dep))
|
73
|
+
end
|
74
|
+
job_rules
|
75
|
+
end
|
69
76
|
end
|
70
77
|
end
|
data/lib/rbbt/hpc/orchestrate.rb
CHANGED
@@ -22,6 +22,25 @@ module HPC
|
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.orchestration_rules(orchestration_rules_file = nil)
|
26
|
+
rules = {}
|
27
|
+
if orchestration_rules_file
|
28
|
+
if Open.exists?(orchestration_rules_file)
|
29
|
+
rules = Misc.load_yaml(orchestration_rules_file)
|
30
|
+
elsif Rbbt.etc.batch[orchestration_rules_file].exists?
|
31
|
+
rules = Misc.load_yaml(Rbbt.etc.batch[orchestration_rules_file])
|
32
|
+
elsif Rbbt.etc.batch[orchestration_rules_file + '.yaml'].exists?
|
33
|
+
rules = Misc.load_yaml(Rbbt.etc.batch[orchestration_rules_file + '.yaml'])
|
34
|
+
else
|
35
|
+
raise "Orchestration rules file not found: #{orchestration_rules_file}"
|
36
|
+
end
|
37
|
+
elsif Rbbt.etc.batch["default.yaml"].exists?
|
38
|
+
rules = Misc.load_yaml(Rbbt.etc.batch["default.yaml"])
|
39
|
+
end
|
40
|
+
|
41
|
+
IndiferentHash.setup(rules)
|
42
|
+
end
|
43
|
+
|
25
44
|
def orchestrate_job(job, options)
|
26
45
|
options.delete "recursive_clean"
|
27
46
|
options.delete "clean_task"
|
@@ -33,26 +52,11 @@ module HPC
|
|
33
52
|
options.delete "load_inputs"
|
34
53
|
options.delete "provenance"
|
35
54
|
|
55
|
+
|
36
56
|
Log.high "Prepare for exec"
|
37
57
|
prepare_for_execution(job)
|
38
58
|
|
39
|
-
|
40
|
-
if Open.exists?(orchestration_rules_file)
|
41
|
-
rules = Misc.load_yaml(orchestration_rules_file)
|
42
|
-
elsif Rbbt.etc.slurm(orchestration_rules_file).exists?
|
43
|
-
rules = Misc.load_yaml(Rbbt.etc.slurm(orchestration_rules_file))
|
44
|
-
elsif Rbbt.etc.slurm(orchestration_rules_file + '.yaml').exists?
|
45
|
-
rules = Misc.load_yaml(Rbbt.etc.slurm(orchestration_rules_file + '.yaml'))
|
46
|
-
else
|
47
|
-
raise "Orchestration rules file not found: #{options[:orchestration_rules]}"
|
48
|
-
end
|
49
|
-
elsif Rbbt.etc.slurm["default.yaml"].exists?
|
50
|
-
rules = Misc.load_yaml(Rbbt.etc.slurm["default.yaml"])
|
51
|
-
else
|
52
|
-
rules = {}
|
53
|
-
end
|
54
|
-
|
55
|
-
IndiferentHash.setup(rules)
|
59
|
+
rules = HPC::Orchestration.orchestration_rules(options[:orchestration_rules])
|
56
60
|
|
57
61
|
batches = HPC::Orchestration.job_batches(rules, job)
|
58
62
|
Log.high "Compute #{batches.length} batches"
|
data/lib/rbbt/hpc/pbs.rb
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
require 'rbbt/hpc/batch'
|
2
|
+
require 'rbbt/hpc/orchestrate'
|
3
|
+
|
4
|
+
module HPC
|
5
|
+
module PBS
|
6
|
+
extend HPC::TemplateGeneration
|
7
|
+
extend HPC::Orchestration
|
8
|
+
|
9
|
+
def self.batch_system
|
10
|
+
"PBS"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.batch_system_variables
|
14
|
+
<<-EOF
|
15
|
+
let TOTAL_PROCESORS="$(cat /proc/cpuinfo|grep ^processor |wc -l)"
|
16
|
+
let MAX_MEMORY_DEFAULT="$(grep MemTotal /proc/meminfo|grep -o "[[:digit:]]*") / ( (1024 * $TOTAL_PROCESORS) / $PBS_CPUS_PER_TASK )"
|
17
|
+
MAX_MEMORY="$MAX_MEMORY_DEFAULT"
|
18
|
+
[ ! -z $PBS_MEM_PER_CPU ] && let MAX_MEMORY="$PBS_MEM_PER_CPU * $PBS_CPUS_PER_TASK"
|
19
|
+
[ ! -z $PBS_MEM_PER_NODE ] && MAX_MEMORY="$PBS_MEM_PER_NODE"
|
20
|
+
export MAX_MEMORY_DEFAULT
|
21
|
+
export MAX_MEMORY
|
22
|
+
export BATCH_JOB_ID=$PBS_JOBID
|
23
|
+
export BATCH_SYSTEM=#{batch_system}
|
24
|
+
|
25
|
+
cd ${PBS_O_WORKDIR}
|
26
|
+
EOF
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.header(options = {})
|
30
|
+
options = options.dup
|
31
|
+
|
32
|
+
workdir = Misc.process_options options, :workdir
|
33
|
+
batch_dir = Misc.process_options options, :batch_dir
|
34
|
+
batch_name = Misc.process_options options, :batch_name
|
35
|
+
|
36
|
+
queue = Misc.process_options options, :queue
|
37
|
+
account = Misc.process_options options, :account
|
38
|
+
time = Misc.process_options options, :time
|
39
|
+
nodes = Misc.process_options options, :nodes
|
40
|
+
|
41
|
+
# PBS
|
42
|
+
place = Misc.process_options options, :place, :place => 'scatter'
|
43
|
+
system = Misc.process_options options, :partition
|
44
|
+
filesystems = Misc.process_options options, :filesystems
|
45
|
+
|
46
|
+
filesystems = "home" if filesystems.nil?
|
47
|
+
|
48
|
+
filesystems = filesystems * "," if Array === filesystems
|
49
|
+
|
50
|
+
# NOT USED
|
51
|
+
partition = Misc.process_options options, :partition
|
52
|
+
task_cpus = Misc.process_options options, :task_cpus
|
53
|
+
exclusive = Misc.process_options options, :exclusive
|
54
|
+
highmem = Misc.process_options options, :highmem
|
55
|
+
licenses = Misc.process_options options, :licenses
|
56
|
+
constraint = Misc.process_options options, :constraint
|
57
|
+
gres = Misc.process_options options, :gres
|
58
|
+
|
59
|
+
constraint = [constraint, "highmem"].compact * "&" if highmem
|
60
|
+
|
61
|
+
mem = Misc.process_options options, :mem
|
62
|
+
mem_per_cpu = Misc.process_options options, :mem_per_cpu
|
63
|
+
|
64
|
+
fout = File.join(batch_dir, 'std.out')
|
65
|
+
ferr = File.join(batch_dir, 'std.err')
|
66
|
+
|
67
|
+
time = Misc.format_seconds Misc.timespan(time) unless time.include? ":"
|
68
|
+
|
69
|
+
qsub_params = { "-l filesystems=" => filesystems,
|
70
|
+
"-l system=" => system,
|
71
|
+
"-l select=" => nodes,
|
72
|
+
"-l place=" => place,
|
73
|
+
"-l walltime=" => time,
|
74
|
+
"-q " => queue,
|
75
|
+
"-A " => account,
|
76
|
+
"-o " => fout,
|
77
|
+
"-e " => ferr,
|
78
|
+
"-k doe" => true,
|
79
|
+
# "cpus-per-task" => task_cpus,
|
80
|
+
# "nodes" => nodes,
|
81
|
+
# "time" => time,
|
82
|
+
# "constraint" => constraint,
|
83
|
+
# "exclusive" => exclusive,
|
84
|
+
# "licenses" => licenses,
|
85
|
+
# "gres" => gres,
|
86
|
+
# "mem" => mem,
|
87
|
+
# "mem-per-cpu" => mem_per_cpu,
|
88
|
+
}
|
89
|
+
|
90
|
+
|
91
|
+
header =<<-EOF
|
92
|
+
#!/bin/bash
|
93
|
+
EOF
|
94
|
+
|
95
|
+
qsub_params.each do |name,value|
|
96
|
+
next if value.nil? || value == ""
|
97
|
+
if TrueClass === value
|
98
|
+
header << "#PBS #{name}" << "\n"
|
99
|
+
elsif Array === value
|
100
|
+
value.each do |v|
|
101
|
+
header << "#PBS #{name}\"#{v}\"" << "\n"
|
102
|
+
end
|
103
|
+
else
|
104
|
+
header << "#PBS #{name}\"#{value}\"" << "\n"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
header
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.run_template(batch_dir, dry_run)
|
112
|
+
|
113
|
+
fout = File.join(batch_dir, 'std.out')
|
114
|
+
ferr = File.join(batch_dir, 'std.err')
|
115
|
+
fjob = File.join(batch_dir, 'job.id')
|
116
|
+
fdep = File.join(batch_dir, 'dependencies.list')
|
117
|
+
fcfdep = File.join(batch_dir, 'canfail_dependencies.list')
|
118
|
+
fexit = File.join(batch_dir, 'exit.status')
|
119
|
+
fsync = File.join(batch_dir, 'sync.log')
|
120
|
+
fcmd = File.join(batch_dir, 'command.batch')
|
121
|
+
|
122
|
+
return if Open.exists?(fexit)
|
123
|
+
|
124
|
+
Log.info "Issuing PBS file: #{fcmd}"
|
125
|
+
Log.debug Open.read(fcmd)
|
126
|
+
|
127
|
+
if File.exist?(fjob)
|
128
|
+
job = Open.read(fjob).to_i
|
129
|
+
else
|
130
|
+
|
131
|
+
dependencies = Open.read(fdep).split("\n") if File.exist? fdep
|
132
|
+
canfail_dependencies = Open.read(fcfdep).split("\n") if File.exist? fcfdep
|
133
|
+
|
134
|
+
normal_dep_str = dependencies && dependencies.any? ? "afterok:" + dependencies * ":" : nil
|
135
|
+
canfail_dep_str = canfail_dependencies && canfail_dependencies.any? ? "afterany:" + canfail_dependencies * ":" : nil
|
136
|
+
|
137
|
+
if normal_dep_str.nil? && canfail_dep_str.nil?
|
138
|
+
dep_str = ""
|
139
|
+
else
|
140
|
+
dep_str = '-W depend=' + [normal_dep_str, canfail_dep_str].compact * ","
|
141
|
+
end
|
142
|
+
|
143
|
+
cmd = "qsub #{dep_str} '#{fcmd}'"
|
144
|
+
|
145
|
+
if File.exist?(fout)
|
146
|
+
return
|
147
|
+
elsif dry_run
|
148
|
+
STDERR.puts Log.color(:magenta, "To execute run: ") + Log.color(:blue, "squb '#{fcmd}'")
|
149
|
+
STDERR.puts Log.color(:magenta, "To monitor progress run (needs local rbbt): ") + Log.color(:blue, "rbbt pbs tail '#{batch_dir}'")
|
150
|
+
raise HPC::BATCH_DRY_RUN, batch_dir
|
151
|
+
else
|
152
|
+
Open.rm fsync
|
153
|
+
Open.rm fexit
|
154
|
+
Open.rm fout
|
155
|
+
Open.rm ferr
|
156
|
+
|
157
|
+
job = CMD.cmd(cmd).read.scan(/\d+/).first.to_i
|
158
|
+
Log.debug "SBATCH job id: #{job}"
|
159
|
+
Open.write(fjob, job.to_s)
|
160
|
+
job
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.job_status(job = nil)
|
166
|
+
if job.nil?
|
167
|
+
CMD.cmd("qstat").read
|
168
|
+
else
|
169
|
+
begin
|
170
|
+
CMD.cmd("qstat #{job}").read
|
171
|
+
rescue
|
172
|
+
""
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
data/lib/rbbt/hpc/slurm.rb
CHANGED
@@ -130,7 +130,7 @@ export BATCH_SYSTEM=#{batch_system}
|
|
130
130
|
elsif dry_run
|
131
131
|
STDERR.puts Log.color(:magenta, "To execute run: ") + Log.color(:blue, "sbatch '#{fcmd}'")
|
132
132
|
STDERR.puts Log.color(:magenta, "To monitor progress run (needs local rbbt): ") + Log.color(:blue, "rbbt slurm tail '#{batch_dir}'")
|
133
|
-
raise HPC::
|
133
|
+
raise HPC::BATCH_DRY_RUN, batch_dir
|
134
134
|
else
|
135
135
|
Open.rm fsync
|
136
136
|
Open.rm fexit
|
data/lib/rbbt/hpc.rb
CHANGED
data/lib/rbbt/resource/util.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Path
|
2
2
|
|
3
|
-
def self.caller_lib_dir(file = nil, relative_to = ['lib', 'bin'])
|
3
|
+
def self.caller_lib_dir(file = nil, relative_to = ['lib', 'bin', 'LICENSE'])
|
4
4
|
#file = caller.reject{|l|
|
5
5
|
# l =~ /rbbt\/(?:resource\.rb|workflow\.rb)/ or
|
6
6
|
# l =~ /rbbt\/resource\/path\.rb/ or
|
data/lib/rbbt/util/R/plot.rb
CHANGED
@@ -1,6 +1,91 @@
|
|
1
1
|
module R
|
2
2
|
module SVG
|
3
3
|
|
4
|
+
def self.plot(filename, data = nil, script = nil, width = nil, height = nil, options = {}, &block)
|
5
|
+
width ||= 600
|
6
|
+
height ||= 600
|
7
|
+
values = []
|
8
|
+
|
9
|
+
script ||= ""
|
10
|
+
if block_given?
|
11
|
+
s = StringIO.new
|
12
|
+
class << s
|
13
|
+
def method_missing(name, *args)
|
14
|
+
name = name.to_s
|
15
|
+
if name[-1] == '='
|
16
|
+
arg = args.first
|
17
|
+
value = if String === arg
|
18
|
+
arg
|
19
|
+
else
|
20
|
+
R.ruby2R arg
|
21
|
+
end
|
22
|
+
add("" << name[0..-2] << "=" << value)
|
23
|
+
else
|
24
|
+
args_strs = []
|
25
|
+
args.each do |arg|
|
26
|
+
value = if String === arg
|
27
|
+
arg
|
28
|
+
else
|
29
|
+
R.ruby2R arg
|
30
|
+
end
|
31
|
+
args_strs << value
|
32
|
+
end
|
33
|
+
add("" << name << "(" << args_strs * ", " << ")")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def add(line)
|
38
|
+
self.write line << "\n"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
block.call(s)
|
42
|
+
s.rewind
|
43
|
+
script << "\n" << s.read
|
44
|
+
end
|
45
|
+
sources = [:plot, options[:source]].flatten.compact
|
46
|
+
|
47
|
+
if data
|
48
|
+
data.each do |k,v|
|
49
|
+
v = Array === v ? v : [v]
|
50
|
+
next if v == "NA" or v.nil? or v.include? "NA" or v.include? nil
|
51
|
+
values = v
|
52
|
+
break
|
53
|
+
end
|
54
|
+
|
55
|
+
values = [values] unless values.nil? or Array === values
|
56
|
+
|
57
|
+
field_classes = values.collect do |v|
|
58
|
+
case v
|
59
|
+
when FalseClass, TrueClass
|
60
|
+
"'logical'"
|
61
|
+
when Numeric
|
62
|
+
"'numeric'"
|
63
|
+
when String
|
64
|
+
if v.strip =~ /^[-+]?[\d\.]+$/
|
65
|
+
"'numeric'"
|
66
|
+
else
|
67
|
+
"'character'"
|
68
|
+
end
|
69
|
+
when Symbol
|
70
|
+
"'factor'"
|
71
|
+
else
|
72
|
+
":NA"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
options[:R_open] ||= "colClasses=c('character'," + field_classes * ", " + ')' if field_classes.any?
|
77
|
+
|
78
|
+
data.R <<-EOF, :plot, options
|
79
|
+
rbbt.svg_plot("#{ filename }", width=#{ width }, height = #{ height }, function(){ #{script} })
|
80
|
+
data = NULL
|
81
|
+
EOF
|
82
|
+
else
|
83
|
+
R.run <<-EOF, :plot, options
|
84
|
+
rbbt.svg_plot("#{ filename }", width=#{ width }, height = #{ height }, function(){ #{script} })
|
85
|
+
EOF
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
4
89
|
def self.ggplotSVG(*args)
|
5
90
|
ggplot(*args)
|
6
91
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rbbt/workflow/step'
|
2
|
+
|
3
|
+
class Step
|
4
|
+
def python_file(file, options = {})
|
5
|
+
CMD.cmd_log(:python, file, options)
|
6
|
+
end
|
7
|
+
|
8
|
+
def python_block(options = {}, &block)
|
9
|
+
RbbtPython.run options, &block
|
10
|
+
end
|
11
|
+
|
12
|
+
def python(python = nil, options = {}, &block)
|
13
|
+
begin
|
14
|
+
RbbtPython.add_path self.workflow.libdir.python.find
|
15
|
+
rescue
|
16
|
+
Log.warn "Error loading libdir python for workflow '#{Misc.fingerprint self.workflow}'"
|
17
|
+
end
|
18
|
+
case python
|
19
|
+
when Path
|
20
|
+
python_file python.find, options
|
21
|
+
when String
|
22
|
+
if Open.exists?(python)
|
23
|
+
python_file python
|
24
|
+
else
|
25
|
+
TmpFile.with_file do |dir|
|
26
|
+
pkg = "pkg#{rand(100)}"
|
27
|
+
Open.write File.join(dir, "#{pkg}/__init__.py"), code
|
28
|
+
|
29
|
+
RbbtPython.add_path dir
|
30
|
+
|
31
|
+
Misc.in_dir dir do
|
32
|
+
yield pkg
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
else
|
37
|
+
python_block(python, &block)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
data/python/rbbt.py
CHANGED
@@ -29,6 +29,7 @@ def tsv_preamble(line, comment_char="#"):
|
|
29
29
|
entries = re.sub(f"^{comment_char}:", '', line)
|
30
30
|
entries = re.sub(f"^{comment_char}:", '', line).split("#")
|
31
31
|
for entry in entries:
|
32
|
+
entry = entry.strip()
|
32
33
|
key, value = entry.split("=")
|
33
34
|
key = re.sub("^:","",key)
|
34
35
|
value = re.sub("^:","",value)
|
@@ -75,7 +76,13 @@ def tsv_pandas(filename, sep="\t", comment_char="#", index_col=0, **kwargs):
|
|
75
76
|
header = tsv_header(filename, sep=sep, comment_char="#")
|
76
77
|
|
77
78
|
if ("type" in header and header["type"] == "flat"):
|
78
|
-
|
79
|
+
if ("sep" in header):
|
80
|
+
sep=header["sep"]
|
81
|
+
|
82
|
+
tsv = pandas.read_table(filename, sep=sep, index_col=index_col, header=None, skiprows=[0,1], **kwargs)
|
83
|
+
|
84
|
+
if ("key_field" in header):
|
85
|
+
tsv.index.name = header["key_field"]
|
79
86
|
else:
|
80
87
|
if ("sep" in header):
|
81
88
|
sep=header["sep"]
|
data/share/Rlib/util.R
CHANGED
@@ -577,6 +577,16 @@ rbbt.get.modes <- function(x,bw = NULL,spar = NULL) {
|
|
577
577
|
|
578
578
|
#{{{ PLOTS
|
579
579
|
|
580
|
+
rbbt.svg_plot <- function(filename, p, width=500, height=500, ...){
|
581
|
+
svg(filename=filename, width=width, height=height, ...);
|
582
|
+
if (is.function(p)) {
|
583
|
+
p()
|
584
|
+
}else{
|
585
|
+
eval(parse(text=p));
|
586
|
+
}
|
587
|
+
dev.off()
|
588
|
+
}
|
589
|
+
|
580
590
|
rbbt.png_plot <- function(filename, p, width=500, height=500, ...){
|
581
591
|
png(filename=filename, width=width, height=height, type='cairo', ...);
|
582
592
|
if (is.function(p)) {
|
@@ -751,6 +761,8 @@ rbbt.plot.venn <- function(data, a=NULL, category=NULL, fill=NULL, ...) {
|
|
751
761
|
fill=rbbt.plot.set_colors(dim(data)[2], "Set3")
|
752
762
|
}
|
753
763
|
|
764
|
+
fill=fill[0:dim(data)[2]]
|
765
|
+
|
754
766
|
group.matches <- function(data, fields) {
|
755
767
|
sub = data
|
756
768
|
for (i in 1:length(fields)) {
|
@@ -253,6 +253,8 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
|
|
253
253
|
text = CMD.cmd('grep "^#SBATCH" ', :in => Open.read(fcmd)).read.strip
|
254
254
|
when 'lsf'
|
255
255
|
text = CMD.cmd('grep "^#BSUB" ', :in => Open.read(fcmd)).read.strip
|
256
|
+
when 'pbs'
|
257
|
+
text = CMD.cmd('grep "^#PBS" ', :in => Open.read(fcmd)).read.strip
|
256
258
|
else
|
257
259
|
text = ""
|
258
260
|
end
|
@@ -32,16 +32,17 @@ $slurm_options = SOPT.get <<EOF
|
|
32
32
|
-p--partition* Partition
|
33
33
|
-t--task_cpus* Tasks
|
34
34
|
-tm--time* Time
|
35
|
-
-m--mem*
|
36
|
-
--gres*
|
37
|
-
-mcpu--mem_per_cpu*
|
38
|
-
-lin--licenses*
|
39
|
-
-cons--constraint*
|
35
|
+
-m--mem* minimum memory
|
36
|
+
--gres* Generic resources
|
37
|
+
-mcpu--mem_per_cpu* minimum memory per CPU
|
38
|
+
-lin--licenses* licenses
|
39
|
+
-cons--constraint* constraint
|
40
40
|
-W--workflows* Additional workflows
|
41
41
|
-rmb--remove_batch_dir Remove the batch working directory (command, STDIN, exit status, ...)
|
42
42
|
-bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
|
43
43
|
-lmod--lua_modules* Lua Modules to load
|
44
44
|
-co--conda* Conda environment to use
|
45
|
+
-OR--orchestration_rules* Orchestration rules
|
45
46
|
EOF
|
46
47
|
|
47
48
|
batch_system = $slurm_options.delete :batch_system
|
@@ -58,9 +59,9 @@ class Step
|
|
58
59
|
self.load
|
59
60
|
else
|
60
61
|
begin
|
61
|
-
Log.debug "Issuing
|
62
|
+
Log.debug "Issuing BATCH job for #{self.path}"
|
62
63
|
HPC::BATCH_MODULE.run_job(self, $slurm_options)
|
63
|
-
rescue HPC::
|
64
|
+
rescue HPC::BATCH_DRY_RUN
|
64
65
|
end
|
65
66
|
end
|
66
67
|
end
|
@@ -253,6 +253,8 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
|
|
253
253
|
text = CMD.cmd('grep "^#SBATCH" ', :in => Open.read(fcmd)).read.strip
|
254
254
|
when 'lsf'
|
255
255
|
text = CMD.cmd('grep "^#BSUB" ', :in => Open.read(fcmd)).read.strip
|
256
|
+
when 'pbs'
|
257
|
+
text = CMD.cmd('grep "^#PBS" ', :in => Open.read(fcmd)).read.strip
|
256
258
|
else
|
257
259
|
text = ""
|
258
260
|
end
|
@@ -32,16 +32,17 @@ $slurm_options = SOPT.get <<EOF
|
|
32
32
|
-p--partition* Partition
|
33
33
|
-t--task_cpus* Tasks
|
34
34
|
-tm--time* Time
|
35
|
-
-m--mem*
|
36
|
-
--gres*
|
37
|
-
-mcpu--mem_per_cpu*
|
38
|
-
-lin--licenses*
|
39
|
-
-cons--constraint*
|
35
|
+
-m--mem* minimum memory
|
36
|
+
--gres* Generic resources
|
37
|
+
-mcpu--mem_per_cpu* minimum memory per CPU
|
38
|
+
-lin--licenses* licenses
|
39
|
+
-cons--constraint* constraint
|
40
40
|
-W--workflows* Additional workflows
|
41
41
|
-rmb--remove_batch_dir Remove the batch working directory (command, STDIN, exit status, ...)
|
42
42
|
-bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
|
43
43
|
-lmod--lua_modules* Lua Modules to load
|
44
44
|
-co--conda* Conda environment to use
|
45
|
+
-OR--orchestration_rules* Orchestration rules
|
45
46
|
EOF
|
46
47
|
|
47
48
|
batch_system = $slurm_options.delete :batch_system
|
@@ -58,9 +59,9 @@ class Step
|
|
58
59
|
self.load
|
59
60
|
else
|
60
61
|
begin
|
61
|
-
Log.debug "Issuing
|
62
|
+
Log.debug "Issuing BATCH job for #{self.path}"
|
62
63
|
HPC::BATCH_MODULE.run_job(self, $slurm_options)
|
63
|
-
rescue HPC::
|
64
|
+
rescue HPC::BATCH_DRY_RUN
|
64
65
|
end
|
65
66
|
end
|
66
67
|
end
|