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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d9b73ef742e367384eeec735b980ad4ef809bf3
4
- data.tar.gz: 3a2d1e5c49ccbb386c4bbe42b57cc031c6271010
3
+ metadata.gz: 3f4308847ea6b93d07967434826c0e6653085329
4
+ data.tar.gz: 7612101d90cc312ae800df4cc6959d5dbe7fd126
5
5
  SHA512:
6
- metadata.gz: 0460b59b327c793efaddfe14f3109a4b34ff5346b48c0284ec9d55e5f66cdaf3e508472ac5e554ab13aff8af9716230c05f10dbac81b93a3aaaa977832ce08c7
7
- data.tar.gz: 01606ac902c2c9da0ee2bc24c46ca83483ce1b67d55af4ab0bc84d111d551a4ff3d2daf3907970feb6510c5f3040061a5951ba842449f8f25c5f5c6b9e9d4a0f
6
+ metadata.gz: be5ce8fc22674fee613268e576f051f4fc30bd1de0943fd4ae655442e234936da7d5a7dd7691904c8ad36ccaf3b87edbd087262946f142869a2f8cc213bddabf
7
+ data.tar.gz: 7b21c5b128e898ee61f08a89ee9d45ad9eea8f0da549682adb70e27ac9c688e3e319f81bafeef206b53940240bf4e29d7788cd1bc5a4ea5c5de652a736301e9b
data/bin/rbbt CHANGED
@@ -176,7 +176,7 @@ def print_error(error, backtrace = nil)
176
176
  if backtrace
177
177
  puts Log.color :red, "Backtrace: "
178
178
  puts
179
- puts backtrace.reverse * "\n"
179
+ puts Log.color_stack(backtrace.reverse) * "\n"
180
180
  puts
181
181
  end
182
182
  puts Log.color :red, error
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
+
@@ -1,7 +1,7 @@
1
1
  module R
2
2
  module SVG
3
3
 
4
- def self.ggplotPNG(*args)
4
+ def self.ggplotSVG(*args)
5
5
  ggplot(*args)
6
6
  end
7
7
 
@@ -809,6 +809,7 @@ module Workflow
809
809
 
810
810
  new_=[]
811
811
  dep.each{|d|
812
+ next if d.nil?
812
813
  if Hash === d
813
814
  d[:workflow] ||= wf
814
815
  d[:task] = task_name
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.123
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-16 00:00:00.000000000 Z
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