rbbt-util 5.33.11 → 5.33.14

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
  SHA256:
3
- metadata.gz: e5c26a161d8529f19d32ace8b5565042b4baa6fef3d69580f46aadc523e8cc51
4
- data.tar.gz: 8ee1305d3a66a55273474da60e84cec3385391ad99c8c87e764fd72eaaf29285
3
+ metadata.gz: d2e19fbbde1862e9ee0c4758f0ed4fa4aaa74909454467409c298615b9d6db77
4
+ data.tar.gz: 4067a1b7bb47bb8f690f7b14a1db8222e46e0c43da4f4ba2497e4c265197d8fd
5
5
  SHA512:
6
- metadata.gz: 6b9ddf9ff821584ef21f7c30be381965ea9a8cf1cce7e9913cc11c118fa1d31211fe321d72c5d8daabcb14aac5b20df45c527fefa1d142c7a08633c3818b79dd
7
- data.tar.gz: c0ab742b23fe87fd7f52bfdfe75690a02566547a34a484912c74766cff70c83634434d5a67a9e665bfdffb28be143afdb20028356befe045e19b14bcc83a21ff
6
+ metadata.gz: 0aa8a4d7ba684aa381bb1ca9492b1b2a788bfec05f85c72e7a508000087db169fe8a7d03de2b356a927a8f15518e21c0c070facf0937a92ee361cdb27a013fa5
7
+ data.tar.gz: 4adf8ee16df7927701bff0aa342a3efef5c98c6e98ae556d6ebbda8dabba15a627f856fa6ddd3649b067d0c066bb1faa72ae2163c96512bc704d1628731aa58d
@@ -138,35 +138,37 @@ EOF
138
138
  batch_options = IndiferentHash.setup({})
139
139
 
140
140
  keys = [
141
- :batch_dir,
141
+ :queue,
142
+ :account,
143
+ :partition,
144
+ :exclusive,
145
+ :highmem,
146
+ :time,
147
+ :nodes,
148
+ :task_cpus,
149
+ :mem,
150
+ :mem_per_cpu,
151
+ :gres,
142
152
  :lua_modules,
153
+ :contraints,
154
+ :licenses,
155
+ :batch_dir,
143
156
  :batch_name,
144
157
  :contain,
158
+ :sync,
145
159
  :contain_and_sync,
146
160
  :copy_image,
147
161
  :drbbt,
148
162
  :env_cmd,
149
- :exclusive,
150
- :highmem,
151
163
  :manifest,
152
- :nodes,
153
- :queue,
154
- :singularity,
155
- :singularity_img,
156
- :singularity_opt_dir,
157
- :singularity_ruby_inline,
158
- :sync,
159
- :task_cpus,
160
- :gres,
161
- :mem,
162
- :mem_per_cpu,
163
- :licenses,
164
- :contraints,
165
- :time,
166
164
  :user_group,
167
165
  :wipe_container,
168
166
  :workdir,
169
- :purge_deps
167
+ :purge_deps,
168
+ :singularity,
169
+ :singularity_img,
170
+ :singularity_opt_dir,
171
+ :singularity_ruby_inline
170
172
  ]
171
173
 
172
174
  keys.each do |key|
@@ -224,7 +226,6 @@ EOF
224
226
  Misc.add_defaults batch_options,
225
227
  :batch_name => batch_name,
226
228
  :inputs_dir => inputs_dir,
227
- :queue => 'debug',
228
229
  :nodes => 1,
229
230
  :step_path => job.path,
230
231
  :task_cpus => 1,
@@ -21,16 +21,18 @@ export BATCH_SYSTEM=SLURM
21
21
  def self.header(options = {})
22
22
  options = options.dup
23
23
 
24
- queue = Misc.process_options options, :queue
25
- task_cpus = Misc.process_options options, :task_cpus
26
- time = Misc.process_options options, :time
27
- nodes = Misc.process_options options, :nodes
28
- workdir = Misc.process_options options, :workdir
29
- exclusive = Misc.process_options options, :exclusive
30
- highmem = Misc.process_options options, :highmem
31
- licenses = Misc.process_options options, :licenses
32
- constraint = Misc.process_options options, :constraint
33
- gres = Misc.process_options options, :gres
24
+ queue = Misc.process_options options, :queue
25
+ account = Misc.process_options options, :account
26
+ partition = Misc.process_options options, :partition
27
+ task_cpus = Misc.process_options options, :task_cpus
28
+ time = Misc.process_options options, :time
29
+ nodes = Misc.process_options options, :nodes
30
+ workdir = Misc.process_options options, :workdir
31
+ exclusive = Misc.process_options options, :exclusive
32
+ highmem = Misc.process_options options, :highmem
33
+ licenses = Misc.process_options options, :licenses
34
+ constraint = Misc.process_options options, :constraint
35
+ gres = Misc.process_options options, :gres
34
36
 
35
37
  constraint = [constraint, "highmem"].compact * "&" if highmem
36
38
 
@@ -47,6 +49,8 @@ export BATCH_SYSTEM=SLURM
47
49
 
48
50
  sbatch_params = {"job-name" => batch_name,
49
51
  "qos" => queue,
52
+ "account" => account,
53
+ "partition" => partition,
50
54
  "output" => fout,
51
55
  "error" => ferr,
52
56
  "cpus-per-task" => task_cpus,
data/lib/rbbt/resource.rb CHANGED
@@ -155,6 +155,8 @@ module Resource
155
155
  FileUtils.rm_rf final_path if File.exist? final_path
156
156
  return false
157
157
  end
158
+
159
+ final_path
158
160
  end
159
161
 
160
162
  def produce(path, force = false)
@@ -326,11 +328,15 @@ url='#{url}'
326
328
  rescue
327
329
  FileUtils.rm_rf final_path if File.exist? final_path
328
330
  raise $!
329
- end unless (remote_server && get_from_server(path, final_path))
331
+ end unless (remote_server && final_path = get_from_server(path, final_path))
330
332
  end
331
333
  end
332
334
  end
333
335
 
336
+ # After producing a file, make sure we recheck all locations, the file
337
+ # might have appeared with '.gz' extension for instance
338
+ path.instance_variable_set("@path", {})
339
+
334
340
  path
335
341
  end
336
342
 
@@ -0,0 +1,79 @@
1
+ module Misc
2
+ PUSHBULLET_KEY=begin
3
+ if ENV["PUSHBULLET_KEY"]
4
+ ENV["PUSHBULLET_KEY"]
5
+ else
6
+ config_api = File.join(ENV['HOME'], 'config/apps/pushbullet/apikey')
7
+ if File.exist? config_api
8
+ File.read(config_api).strip
9
+ else
10
+ nil
11
+ end
12
+ end
13
+ end
14
+
15
+ def self.notify(description, event='notification', key = nil)
16
+ if PUSHBULLET_KEY.nil? and key.nil?
17
+ Log.warn "Could not notify, no PUSHBULLET_KEY"
18
+ return
19
+ end
20
+
21
+ Thread.new do
22
+ application = 'rbbt'
23
+ event ||= 'notification'
24
+ key ||= PUSHBULLET_KEY
25
+ `curl -s --header "Authorization: Bearer #{key}" -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "#{event}", "body": "#{description}"}'`
26
+ end
27
+ end
28
+
29
+ def self.send_email_old(from, to, subject, message, options = {})
30
+ IndiferentHash.setup(options)
31
+ options = Misc.add_defaults options, :from_alias => nil, :to_alias => nil, :server => 'localhost', :port => 25, :user => nil, :pass => nil, :auth => :login
32
+
33
+ server, port, user, pass, from_alias, to_alias, auth = Misc.process_options options, :server, :port, :user, :pass, :from_alias, :to_alias, :auth
34
+
35
+ msg = <<-END_OF_MESSAGE
36
+ From: #{from_alias} <#{from}>
37
+ To: #{to_alias} <#{to}>
38
+ Subject: #{subject}
39
+
40
+ #{message}
41
+ END_OF_MESSAGE
42
+
43
+ Net::SMTP.start(server, port, server, user, pass, auth) do |smtp|
44
+ smtp.send_message msg, from, to
45
+ end
46
+ end
47
+
48
+ def self.send_email(from, to, subject, message, options = {})
49
+ require 'mail'
50
+
51
+ IndiferentHash.setup(options)
52
+ options = Misc.add_defaults options, :from_alias => nil, :to_alias => nil, :server => 'localhost', :port => 25, :user => nil, :pass => nil, :auth => :login, :files => []
53
+
54
+ server, port, user, pass, from_alias, to_alias, auth, files = Misc.process_options options, :server, :port, :user, :pass, :from_alias, :to_alias, :auth, :files
55
+
56
+ files = [] if files.nil?
57
+ files = [files] unless Array === files
58
+
59
+ Mail.defaults do
60
+ delivery_method :smtp, address: server, port: port, user_name: user, password: pass
61
+ end
62
+
63
+ mail = Mail.deliver do
64
+ from "#{from_alias} <#{from}>"
65
+ to "#{to_alias} <#{to}>"
66
+ subject subject
67
+
68
+ text_part do
69
+ body message
70
+ end
71
+
72
+ files.each do |file|
73
+ file = file.find if Path === file
74
+ file = file.path if Step === file
75
+ end
76
+ end
77
+ end
78
+
79
+ end
@@ -385,32 +385,6 @@ def self.add_libdir(dir=nil)
385
385
  `ps -o rss -p #{pid || $$}`.strip.split.last.to_i
386
386
  end
387
387
 
388
- PUSHBULLET_KEY=begin
389
- if ENV["PUSHBULLET_KEY"]
390
- ENV["PUSHBULLET_KEY"]
391
- else
392
- config_api = File.join(ENV['HOME'], 'config/apps/pushbullet/apikey')
393
- if File.exist? config_api
394
- File.read(config_api).strip
395
- else
396
- nil
397
- end
398
- end
399
- end
400
-
401
- def self.notify(description, event='notification', key = nil)
402
- if PUSHBULLET_KEY.nil? and key.nil?
403
- Log.warn "Could not notify, no PUSHBULLET_KEY"
404
- return
405
- end
406
-
407
- Thread.new do
408
- application = 'rbbt'
409
- event ||= 'notification'
410
- key ||= PUSHBULLET_KEY
411
- `curl -s --header "Authorization: Bearer #{key}" -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "#{event}", "body": "#{description}"}'`
412
- end
413
- end
414
388
 
415
389
  def self.unzip_in_dir(file, dir)
416
390
  raise "Target is not a directory: #{file}" if File.exist?(dir) and not File.directory?(dir)
@@ -16,25 +16,6 @@ module Misc
16
16
  end
17
17
  end
18
18
 
19
- def self.send_email(from, to, subject, message, options = {})
20
- IndiferentHash.setup(options)
21
- options = Misc.add_defaults options, :from_alias => nil, :to_alias => nil, :server => 'localhost', :port => 25, :user => nil, :pass => nil, :auth => :login
22
-
23
- server, port, user, pass, from_alias, to_alias, auth = Misc.process_options options, :server, :port, :user, :pass, :from_alias, :to_alias, :auth
24
-
25
- msg = <<-END_OF_MESSAGE
26
- From: #{from_alias} <#{from}>
27
- To: #{to_alias} <#{to}>
28
- Subject: #{subject}
29
-
30
- #{message}
31
- END_OF_MESSAGE
32
-
33
- Net::SMTP.start(server, port, server, user, pass, auth) do |smtp|
34
- smtp.send_message msg, from, to
35
- end
36
- end
37
-
38
19
  def self.env_add(var, value, sep = ":", prepend = true)
39
20
  ENV[var] ||= ""
40
21
  return if ENV[var] =~ /(#{sep}|^)#{Regexp.quote value}(#{sep}|$)/
@@ -20,6 +20,7 @@ require 'rbbt/util/misc/options'
20
20
  require 'rbbt/util/misc/system'
21
21
  require 'rbbt/util/misc/objects'
22
22
  require 'rbbt/util/misc/manipulation'
23
+ require 'rbbt/util/misc/communication'
23
24
 
24
25
  require 'to_regexp'
25
26
 
@@ -678,7 +678,14 @@ module Open
678
678
  if Open.exists? notification_file
679
679
  key = Open.read(notification_file).strip
680
680
  key = nil if key.empty?
681
- Misc.notify("Wrote " << file, nil, key)
681
+ if key.include?("@")
682
+ to = from = key
683
+ subject = "Wrote " << file
684
+ message = "Content attached"
685
+ Misc.send_email(from, to, subject, message, :files => [file])
686
+ else
687
+ Misc.notify("Wrote " << file, nil, key)
688
+ end
682
689
  Open.rm notification_file
683
690
  end
684
691
  rescue
@@ -0,0 +1,33 @@
1
+ module RbbtPython
2
+ def self.py2ruby_a(array)
3
+ PyCall::List.(array).to_a
4
+ end
5
+
6
+ class << self
7
+ alias to_a py2ruby_a
8
+ end
9
+
10
+
11
+ def self.tsv2df(tsv)
12
+ df = nil
13
+ RbbtPython.run 'pandas' do
14
+ df = pandas.DataFrame.new(tsv.values, columns: tsv.fields, index: tsv.keys)
15
+ df.columns.name = tsv.key_field
16
+ end
17
+ df
18
+ end
19
+
20
+ def self.df2tsv(tuple, options = {})
21
+ options = Misc.add_defaults options, :type => :list
22
+ tsv = TSV.setup({}, options)
23
+ tsv.key_field = tuple.columns.name
24
+ tsv.fields = py2ruby_a(tuple.columns.values)
25
+ keys = tuple.index.values
26
+ PyCall.len(tuple.index).times do |i|
27
+ k = keys[i]
28
+ tsv[k] = py2ruby_a(tuple.values[i])
29
+ end
30
+ tsv
31
+ end
32
+
33
+ end
@@ -74,7 +74,10 @@ module Workflow
74
74
  dep = Step === dep ? dep.dup : Workflow.load_step(dep)
75
75
 
76
76
  dep.original_workflow ||= dep.workflow if dep.workflow
77
- dep.original_task_name ||= dep.task_name if dep.workflow
77
+ dep.original_task_name ||= dep.task_name if dep.task_name
78
+
79
+ dep.original_task_name ||= dep.path.split("/")[-3]
80
+ dep.original_task_name ||= dep.path.split("/")[-2]
78
81
 
79
82
  dep.workflow = workflow
80
83
  dep.info[:name] = dep.name
@@ -368,7 +368,7 @@ class Step
368
368
  def run_dependencies
369
369
  dep_step = {}
370
370
 
371
- rec_dependencies = self.rec_dependencies(true)
371
+ rec_dependencies = self.rec_dependencies(true) + input_dependencies
372
372
 
373
373
  return if rec_dependencies.empty?
374
374
 
@@ -25,6 +25,8 @@ module Task
25
25
  selects << [i, task.input_options[i][:select_options]]
26
26
  end
27
27
 
28
+ next if new_inputs.empty?
29
+
28
30
  if task.workflow and task.workflow != workflow
29
31
  puts " #{Log.color :yellow, ["[#{task.workflow.to_s}]", task.name.to_s] *" "}:"
30
32
  else
@@ -25,6 +25,8 @@ $slurm_options = SOPT.get <<EOF
25
25
  -t--tail Tail the logs
26
26
  -BPP--batch_procpath* Save Procpath performance for batch job; specify only options
27
27
  -q--queue* Queue
28
+ -a--account* Account
29
+ -p--partition* Partition
28
30
  -t--task_cpus* Tasks
29
31
  -tm--time* Time
30
32
  -m--mem* SLURM minimum memory
@@ -24,6 +24,8 @@ $slurm_options = SOPT.get <<EOF
24
24
  -t--tail Tail the logs
25
25
  -BPP--batch_procpath* Save Procpath performance for batch job; specify only options
26
26
  -q--queue* Queue
27
+ -a--account* Account
28
+ -p--partition* Partition
27
29
  -t--task_cpus* Tasks
28
30
  -tm--time* Time
29
31
  -m--mem* SLURM minimum memory
@@ -25,6 +25,8 @@ $slurm_options = SOPT.get <<EOF
25
25
  -t--tail Tail the logs
26
26
  -BPP--batch_procpath* Save Procpath performance for batch job; specify only options
27
27
  -q--queue* Queue
28
+ -a--account* Account
29
+ -p--partition* Partition
28
30
  -t--task_cpus* Tasks
29
31
  -tm--time* Time
30
32
  -m--mem* SLURM minimum memory
@@ -24,6 +24,8 @@ $slurm_options = SOPT.get <<EOF
24
24
  -t--tail Tail the logs
25
25
  -BPP--batch_procpath* Save Procpath performance for batch job; specify only options
26
26
  -q--queue* Queue
27
+ -a--account* Account
28
+ -p--partition* Partition
27
29
  -t--task_cpus* Tasks
28
30
  -tm--time* Time
29
31
  -m--mem* SLURM minimum memory
@@ -25,6 +25,8 @@ $slurm_options = SOPT.get <<EOF
25
25
  -t--tail Tail the logs
26
26
  -BPP--batch_procpath* Save Procpath performance for batch job; specify only options
27
27
  -q--queue* Queue
28
+ -a--account* Account
29
+ -p--partition* Partition
28
30
  -t--task_cpus* Tasks
29
31
  -tm--time* Time
30
32
  -m--mem* SLURM minimum memory
@@ -24,6 +24,8 @@ $slurm_options = SOPT.get <<EOF
24
24
  -t--tail Tail the logs
25
25
  -BPP--batch_procpath* Save Procpath performance for batch job; specify only options
26
26
  -q--queue* Queue
27
+ -a--account* Account
28
+ -p--partition* Partition
27
29
  -t--task_cpus* Tasks
28
30
  -tm--time* Time
29
31
  -m--mem* SLURM minimum memory
@@ -0,0 +1,11 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
2
+ require 'rbbt/util/misc/communication'
3
+
4
+ class TestCommunication < Test::Unit::TestCase
5
+ def test_send_email
6
+ to = from = 'mvazque2@localhost'
7
+ subject = message = "Test"
8
+ iii Misc.send_email(to, from, subject, message)
9
+ end
10
+ end
11
+
@@ -0,0 +1,17 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
2
+ require 'rbbt/util/python'
3
+ require 'rbbt/util/python/util'
4
+
5
+ class TestPythonUtil < Test::Unit::TestCase
6
+
7
+ def test_tuple
8
+ tsv = TSV.setup([], :key_field => "Key", :fields => %w(Value1 Value2), :type => :list)
9
+ tsv["k1"] = %w(V1_1 V2_1)
10
+ tsv["k2"] = %w(V1_2 V2_2)
11
+ df = RbbtPython.tsv2df(tsv)
12
+ new_tsv = RbbtPython.df2tsv(df)
13
+ assert_equal tsv, new_tsv
14
+ end
15
+
16
+ end
17
+
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.33.11
4
+ version: 5.33.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-05 00:00:00.000000000 Z
11
+ date: 2022-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -292,6 +292,7 @@ files:
292
292
  - lib/rbbt/util/misc.rb
293
293
  - lib/rbbt/util/misc/annotated_module.rb
294
294
  - lib/rbbt/util/misc/bgzf.rb
295
+ - lib/rbbt/util/misc/communication.rb
295
296
  - lib/rbbt/util/misc/concurrent_stream.rb
296
297
  - lib/rbbt/util/misc/development.rb
297
298
  - lib/rbbt/util/misc/exceptions.rb
@@ -311,6 +312,7 @@ files:
311
312
  - lib/rbbt/util/open.rb
312
313
  - lib/rbbt/util/procpath.rb
313
314
  - lib/rbbt/util/python.rb
315
+ - lib/rbbt/util/python/util.rb
314
316
  - lib/rbbt/util/semaphore.rb
315
317
  - lib/rbbt/util/simpleDSL.rb
316
318
  - lib/rbbt/util/simpleopt.rb
@@ -531,12 +533,14 @@ files:
531
533
  - test/rbbt/util/concurrency/test_threads.rb
532
534
  - test/rbbt/util/log/test_progress.rb
533
535
  - test/rbbt/util/misc/test_bgzf.rb
536
+ - test/rbbt/util/misc/test_communication.rb
534
537
  - test/rbbt/util/misc/test_development.rb
535
538
  - test/rbbt/util/misc/test_format.rb
536
539
  - test/rbbt/util/misc/test_lock.rb
537
540
  - test/rbbt/util/misc/test_multipart_payload.rb
538
541
  - test/rbbt/util/misc/test_omics.rb
539
542
  - test/rbbt/util/misc/test_pipes.rb
543
+ - test/rbbt/util/python/test_util.rb
540
544
  - test/rbbt/util/simpleopt/test_get.rb
541
545
  - test/rbbt/util/simpleopt/test_parse.rb
542
546
  - test/rbbt/util/simpleopt/test_setup.rb
@@ -607,10 +611,12 @@ test_files:
607
611
  - test/rbbt/resource/test_path.rb
608
612
  - test/rbbt/util/test_colorize.rb
609
613
  - test/rbbt/util/test_procpath.rb
614
+ - test/rbbt/util/python/test_util.rb
610
615
  - test/rbbt/util/misc/test_development.rb
611
616
  - test/rbbt/util/misc/test_omics.rb
612
617
  - test/rbbt/util/misc/test_pipes.rb
613
618
  - test/rbbt/util/misc/test_format.rb
619
+ - test/rbbt/util/misc/test_communication.rb
614
620
  - test/rbbt/util/misc/test_lock.rb
615
621
  - test/rbbt/util/misc/test_multipart_payload.rb
616
622
  - test/rbbt/util/misc/test_bgzf.rb