rbbt-util 5.21.123 → 5.21.125
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbbt +1 -1
- data/lib/rbbt/hpc.rb +122 -0
- data/lib/rbbt/util/R/plot.rb +1 -1
- data/lib/rbbt/workflow/accessor.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f4308847ea6b93d07967434826c0e6653085329
|
4
|
+
data.tar.gz: 7612101d90cc312ae800df4cc6959d5dbe7fd126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be5ce8fc22674fee613268e576f051f4fc30bd1de0943fd4ae655442e234936da7d5a7dd7691904c8ad36ccaf3b87edbd087262946f142869a2f8cc213bddabf
|
7
|
+
data.tar.gz: 7b21c5b128e898ee61f08a89ee9d45ad9eea8f0da549682adb70e27ac9c688e3e319f81bafeef206b53940240bf4e29d7788cd1bc5a4ea5c5de652a736301e9b
|
data/bin/rbbt
CHANGED
data/lib/rbbt/hpc.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'rbbt-util'
|
2
|
+
require 'rbbt/util/cmd'
|
3
|
+
|
4
|
+
module Marenostrum
|
5
|
+
SERVER='mn1'
|
6
|
+
module SLURM
|
7
|
+
TEMPLATE=<<-EOF
|
8
|
+
|
9
|
+
|
10
|
+
EOF
|
11
|
+
def self.issue(cmd, name = nil, time = nil, options = {})
|
12
|
+
name = "rbbt-job-" << rand(10000).to_s if name.nil?
|
13
|
+
time = "00:00:10" if time.nil?
|
14
|
+
workdir = "rbbt-workdir/" << name
|
15
|
+
|
16
|
+
new_options = Misc.add_defaults options, "job-name" => name, "workdir" => workdir,
|
17
|
+
"output" => "log",
|
18
|
+
"error" => "log.err",
|
19
|
+
"ntasks" => "1",
|
20
|
+
"time" => time.to_s,
|
21
|
+
"user" => ENV["USER"],
|
22
|
+
"key_file" => File.join(ENV['HOME'], '.ssh/id_rsa.pub')
|
23
|
+
|
24
|
+
options.merge!(new_options)
|
25
|
+
IndiferentHash.setup(options)
|
26
|
+
|
27
|
+
key_file, user = options.values_at :key_file, :user
|
28
|
+
|
29
|
+
template = <<-EOF
|
30
|
+
#!/bin/bash
|
31
|
+
#{options.collect do |name,value|
|
32
|
+
next if name == 'user'
|
33
|
+
next if name == 'key_file'
|
34
|
+
name = "--" << name.to_s.sub(/^--/,'')
|
35
|
+
[name, '"' << value << '"'] * "="
|
36
|
+
end.compact.collect{|str| "#SBATCH #{str}"} * "\n"
|
37
|
+
}
|
38
|
+
#{ cmd }
|
39
|
+
EOF
|
40
|
+
|
41
|
+
TmpFile.with_file do |slurm|
|
42
|
+
res = nil
|
43
|
+
begin
|
44
|
+
Open.write(slurm, template)
|
45
|
+
Log.medium("Issuing job:\n" + template)
|
46
|
+
|
47
|
+
cmd = "ssh -i #{key_file} #{ user }@#{ SERVER } mkdir -p '#{ workdir }'; scp -i #{key_file} #{ slurm } #{ user }@#{ SERVER }:'#{ workdir }/#{ name }.slurm'; ssh -i #{key_file} #{ user }@#{ SERVER } sbatch #{ workdir }/#{ name }.slurm"
|
48
|
+
Log.debug cmd
|
49
|
+
res = CMD.cmd(cmd).read
|
50
|
+
rescue
|
51
|
+
raise "Could not issue job"
|
52
|
+
end
|
53
|
+
|
54
|
+
res.scan(/\d+/).first
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.query(id, options = {})
|
59
|
+
key_file, user = options.values_at :key_file, :user
|
60
|
+
|
61
|
+
res = nil
|
62
|
+
begin
|
63
|
+
cmd = "ssh -i #{key_file} #{ user }@#{ SERVER } squeue |grep '#{id}\\|JOBID'"
|
64
|
+
Log.debug cmd
|
65
|
+
res = CMD.cmd(cmd).read
|
66
|
+
rescue
|
67
|
+
raise "Could not query job: #{ id }" << $!.message
|
68
|
+
end
|
69
|
+
|
70
|
+
res
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.done?(id, options = {})
|
74
|
+
! query(id, options).include? id
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.gather(id, file = nil, options = {})
|
78
|
+
key_file, user, workdir, output = options.values_at :key_file, :user, :workdir, :output
|
79
|
+
|
80
|
+
TmpFile.with_file do |result|
|
81
|
+
|
82
|
+
begin
|
83
|
+
cmd = "scp -i #{key_file} #{ user }@#{ SERVER }:'#{workdir}/#{output}' '#{ result }' "
|
84
|
+
Log.debug cmd
|
85
|
+
CMD.cmd(cmd)
|
86
|
+
if file.nil?
|
87
|
+
Open.read(result)
|
88
|
+
else
|
89
|
+
Misc.sensiblewrite(result, file)
|
90
|
+
end
|
91
|
+
rescue
|
92
|
+
raise "Could not gather job: #{ id }: " << $!.message
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.run(cmd, name = nil, time = nil, options = {})
|
98
|
+
sleep_time = Misc.process_options options, :sleep
|
99
|
+
|
100
|
+
id = issue(cmd, name, time, options)
|
101
|
+
|
102
|
+
if sleep_time.nil?
|
103
|
+
times = [1,2,3,5,10,30]
|
104
|
+
else
|
105
|
+
times = Array === sleep_time ? sleep_time.dup : [sleep_time]
|
106
|
+
end
|
107
|
+
|
108
|
+
while not done?(id, options)
|
109
|
+
Log.debug "Waiting on #{ id }"
|
110
|
+
sleep_time = times.shift || sleep_time
|
111
|
+
sleep sleep_time
|
112
|
+
end
|
113
|
+
|
114
|
+
gather(id, nil, options)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
Log.severity = 0 if __FILE__ == $0
|
120
|
+
iii Marenostrum::SLURM.run('ls', nil, nil, :qos => "debug", :user => 'bsc26892') if __FILE__ == $0
|
121
|
+
|
122
|
+
|
data/lib/rbbt/util/R/plot.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.21.
|
4
|
+
version: 5.21.125
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -209,6 +209,7 @@ files:
|
|
209
209
|
- lib/rbbt/entity.rb
|
210
210
|
- lib/rbbt/entity/identifiers.rb
|
211
211
|
- lib/rbbt/fix_width_table.rb
|
212
|
+
- lib/rbbt/hpc.rb
|
212
213
|
- lib/rbbt/knowledge_base.rb
|
213
214
|
- lib/rbbt/knowledge_base/enrichment.rb
|
214
215
|
- lib/rbbt/knowledge_base/entity.rb
|