rbbt-util 5.34.26 → 5.35.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbbt/hpc/batch.rb +31 -4
  3. data/lib/rbbt/hpc/lsf.rb +5 -1
  4. data/lib/rbbt/hpc/orchestrate.old.rb +1 -1
  5. data/lib/rbbt/hpc/orchestrate.rb +11 -3
  6. data/lib/rbbt/hpc/slurm.rb +10 -2
  7. data/lib/rbbt/monitor.rb +3 -3
  8. data/lib/rbbt/persist.rb +1 -3
  9. data/lib/rbbt/resource/path.rb +1 -1
  10. data/lib/rbbt/resource.rb +1 -0
  11. data/lib/rbbt/tsv/attach/util.rb +8 -4
  12. data/lib/rbbt/util/R/model.rb +1 -1
  13. data/lib/rbbt/util/R/plot.rb +2 -0
  14. data/lib/rbbt/util/R.rb +1 -1
  15. data/lib/rbbt/util/cmd.rb +5 -3
  16. data/lib/rbbt/util/misc/concurrent_stream.rb +12 -11
  17. data/lib/rbbt/util/misc/development.rb +3 -2
  18. data/lib/rbbt/util/misc/exceptions.rb +26 -3
  19. data/lib/rbbt/util/misc/inspect.rb +1 -1
  20. data/lib/rbbt/util/misc/serialize.rb +26 -0
  21. data/lib/rbbt/util/misc.rb +2 -0
  22. data/lib/rbbt/util/simpleopt/get.rb +9 -6
  23. data/lib/rbbt/workflow/integration/ansible.rb +1 -1
  24. data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +34 -9
  25. data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +7 -2
  26. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +2 -0
  27. data/lib/rbbt/workflow/step/accessor.rb +5 -1
  28. data/lib/rbbt/workflow/step/run.rb +1 -1
  29. data/lib/rbbt/workflow/step/save_load_inputs.rb +2 -1
  30. data/lib/rbbt/workflow/step/status.rb +1 -1
  31. data/lib/rbbt/workflow.rb +3 -4
  32. data/share/install/software/lib/install_helpers +3 -2
  33. data/share/rbbt_commands/ansible +0 -1
  34. data/share/rbbt_commands/hpc/orchestrate +15 -3
  35. data/share/rbbt_commands/hpc/task +13 -2
  36. data/share/rbbt_commands/lsf/orchestrate +15 -3
  37. data/share/rbbt_commands/lsf/task +13 -2
  38. data/share/rbbt_commands/slurm/orchestrate +15 -3
  39. data/share/rbbt_commands/slurm/task +13 -2
  40. data/share/rbbt_commands/system/clean +1 -1
  41. data/share/rbbt_commands/workflow/task +3 -2
  42. data/test/rbbt/hpc/test_batch.rb +4 -4
  43. data/test/rbbt/util/misc/test_serialize.rb +24 -0
  44. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da3b496fd0fb7d9ff645cba0fb4ba3914288fb0b88bf80f43a79d02bd1ee2cfd
4
- data.tar.gz: ab120f9bb96f1b0628f1edc6dc114a43c32ed39a5c29ce5252bbf85383d24359
3
+ metadata.gz: 5efc019e19e967e30d83a08aa3ed45debe5036dac45f644ec0c7195100112e08
4
+ data.tar.gz: 1b7f34c9cb59d5936762531df4e004728071a90f4fcf3a4dce009e58071d7ffa
5
5
  SHA512:
6
- metadata.gz: 3f5b5326a834f1f972756919ea2f04c9626998be3c9ca058fd386c06787011ad021798e6091eb8eae1f7873dcceb9adcfa02de14a5269dadef4a2902d5475a9d
7
- data.tar.gz: d74344affb899a6b62a494d02e9058dc338a7be4138b9ce32331d0657bc121035b312da21f48827751dc13e1bdee4511fb6f1eeaf481d39f73e5967ff3243800
6
+ metadata.gz: e0282a5eb3e8ec139b2cfc60face60d9bbd83d3597291df4e37fe9b8c4b2bca78a5fac23eb0c2ed4948d7cc61005c0625d992faaa67e265cd12443ee509f3037
7
+ data.tar.gz: a1e058254ad80b23409bb8f4618f14949089d6fbb355228fbf7abf82919d55a4ee86f47cdb1684014079a00f65831a5ea1900e63808fe21e863de3c67e121e86
@@ -378,17 +378,17 @@ function batch_sync_contain_dir(){
378
378
  prepare_environment +=<<-EOF
379
379
  # Load singularity modules
380
380
  command -v singularity &> /dev/null || module load singularity
381
- mkdir -p "#{singularity_opt_dir}"
381
+ mkdir -p "#{File.expand_path singularity_opt_dir}"
382
382
  EOF
383
383
 
384
384
  if contain && options[:hardened]
385
385
 
386
386
  prepare_environment +=<<-EOF
387
387
  # Prepare container for singularity
388
- mkdir -p "#{contain}/.rbbt/etc/"
388
+ mkdir -p "#{contain}"/.rbbt/etc/
389
389
 
390
390
  for dir in .ruby_inline git home; do
391
- mkdir -p "#{contain}/$dir"
391
+ mkdir -p "#{contain}"/$dir
392
392
  done
393
393
 
394
394
  for tmpd in persist_locks produce_locks R_sockets sensiblewrite sensiblewrite_locks step_info_locks tsv_open_locks; do
@@ -560,6 +560,16 @@ env > #{batch_options[:fenv]}
560
560
  def run_job(job, options = {})
561
561
  system = self.to_s.split("::").last
562
562
 
563
+ if (batch_job = job.info[:batch_job]) && job_queued(batch_job)
564
+ Log.info "Job #{job.short_path} already queued in #{batch_job}"
565
+ return batch_job
566
+ end
567
+
568
+ if job.running?
569
+ Log.info "Job #{job.short_path} already running in #{job.info[:pid]}"
570
+ return job.info[:batch_job]
571
+ end
572
+
563
573
  batch_base_dir, clean_batch_job, remove_batch_dir, procpath, tail, batch_dependencies, dry_run = Misc.process_options options,
564
574
  :batch_base_dir, :clean_batch_job, :remove_batch_dir, :batch_procpath, :tail, :batch_dependencies, :dry_run,
565
575
  :batch_base_dir => File.expand_path(File.join('~/rbbt-batch'))
@@ -583,6 +593,8 @@ env > #{batch_options[:fenv]}
583
593
 
584
594
  batch_job = run_template(batch_dir, dry_run)
585
595
 
596
+ hold_dependencies(job, batch_job) unless dry_run
597
+
586
598
  return [batch_job, batch_dir] unless tail
587
599
 
588
600
  t_monitor = Thread.new do
@@ -603,6 +615,17 @@ env > #{batch_options[:fenv]}
603
615
  end
604
616
  end
605
617
 
618
+ def hold_dependencies(job, batch_job)
619
+ job.set_info :batch_job, batch_job
620
+ job.set_info :batch_system, self.batch_system
621
+ job.dependencies.each do |dep|
622
+ next unless dep.waiting?
623
+ next if (dep_batch_job = dep.info[:batch_job]) && job_queued(dep_batch_job)
624
+
625
+ hold_dependencies(dep, batch_job)
626
+ end
627
+ end
628
+
606
629
  def follow_job(batch_dir, tail = true)
607
630
  fjob = File.join(batch_dir, 'job.id')
608
631
  fout = File.join(batch_dir, 'std.out')
@@ -672,7 +695,7 @@ env > #{batch_options[:fenv]}
672
695
  terr = Misc.consume_stream(err, true, STDERR) if err
673
696
  tout = Misc.consume_stream(out, true, STDOUT) if out
674
697
 
675
- sleep 3 while job_status(job).include? job.to_s
698
+ sleep 3 while job_queued(job)
676
699
  rescue Aborted
677
700
  ensure
678
701
  begin
@@ -692,6 +715,10 @@ env > #{batch_options[:fenv]}
692
715
  end
693
716
  end
694
717
 
718
+ def job_queued(job)
719
+ job_status(job).split(/\s+/).include?(job.to_s)
720
+ end
721
+
695
722
  def wait_for_job(batch_dir, time = 1)
696
723
  fexit = File.join(batch_dir, 'exit.status')
697
724
  fjob = File.join(batch_dir, 'job.id')
data/lib/rbbt/hpc/lsf.rb CHANGED
@@ -5,6 +5,10 @@ module HPC
5
5
  extend HPC::TemplateGeneration
6
6
  extend HPC::Orchestration
7
7
 
8
+ def self.batch_system
9
+ "LSF"
10
+ end
11
+
8
12
  def self.batch_system_variables
9
13
  <<-EOF
10
14
  let TOTAL_PROCESORS="$(cat /proc/cpuinfo|grep ^processor |wc -l)"
@@ -13,7 +17,7 @@ let MAX_MEMORY_DEFAULT="$(grep MemTotal /proc/meminfo|grep -o "[[:digit:]]*") /
13
17
  export MAX_MEMORY_DEFAULT
14
18
  export MAX_MEMORY
15
19
  export BATCH_JOB_ID=$LSF_JOBID
16
- export BATCH_SYSTEM=LSF
20
+ export BATCH_SYSTEM=#{batch_system}
17
21
  EOF
18
22
  end
19
23
 
@@ -206,7 +206,7 @@ module HPC
206
206
  options.delete "detach"
207
207
  options.delete "jobname"
208
208
 
209
- rules = YAML.load(Open.read(options[:orchestration_rules])) if options[:orchestration_rules]
209
+ rules = Misc.load_yaml(options[:orchestration_rules]) if options[:orchestration_rules]
210
210
  rules ||= {}
211
211
  IndiferentHash.setup(rules)
212
212
 
@@ -36,10 +36,18 @@ module HPC
36
36
  Log.high "Prepare for exec"
37
37
  prepare_for_execution(job)
38
38
 
39
- if options[:orchestration_rules]
40
- rules = YAML.load(Open.read(options[:orchestration_rules]))
39
+ if orchestration_rules_file = options[:orchestration_rules]
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
41
49
  elsif Rbbt.etc.slurm["default.yaml"].exists?
42
- rules = YAML.load(Open.read(Rbbt.etc.slurm["default.yaml"]))
50
+ rules = Misc.load_yaml(Rbbt.etc.slurm["default.yaml"])
43
51
  else
44
52
  rules = {}
45
53
  end
@@ -6,6 +6,10 @@ module HPC
6
6
  extend HPC::TemplateGeneration
7
7
  extend HPC::Orchestration
8
8
 
9
+ def self.batch_system
10
+ "SLURM"
11
+ end
12
+
9
13
  def self.batch_system_variables
10
14
  <<-EOF
11
15
  let TOTAL_PROCESORS="$(cat /proc/cpuinfo|grep ^processor |wc -l)"
@@ -16,7 +20,7 @@ MAX_MEMORY="$MAX_MEMORY_DEFAULT"
16
20
  export MAX_MEMORY_DEFAULT
17
21
  export MAX_MEMORY
18
22
  export BATCH_JOB_ID=$SLURM_JOB_ID
19
- export BATCH_SYSTEM=SLURM
23
+ export BATCH_SYSTEM=#{batch_system}
20
24
  EOF
21
25
  end
22
26
 
@@ -145,7 +149,11 @@ export BATCH_SYSTEM=SLURM
145
149
  if job.nil?
146
150
  CMD.cmd("squeue").read
147
151
  else
148
- CMD.cmd("squeue --job #{job}").read
152
+ begin
153
+ CMD.cmd("squeue --job #{job}").read
154
+ rescue
155
+ ""
156
+ end
149
157
  end
150
158
  end
151
159
 
data/lib/rbbt/monitor.rb CHANGED
@@ -64,14 +64,14 @@ module Rbbt
64
64
  lock_info[f].merge!(file_time(f))
65
65
  if File.size(f) > 0
66
66
  info = Open.open(f) do |s|
67
- YAML.load(s)
67
+ Misc.load_yaml(s)
68
68
  end
69
69
  IndiferentHash.setup(info)
70
70
  lock_info[f][:pid] = info[:pid]
71
71
  lock_info[f][:ppid] = info[:ppid]
72
72
  end
73
73
  rescue Exception
74
- #Log.exception $!
74
+ Log.exception $!
75
75
  end
76
76
  end
77
77
  lock_info
@@ -272,7 +272,7 @@ module Rbbt
272
272
  def self.load_lock(lock)
273
273
  begin
274
274
  info = Misc.insist 3 do
275
- YAML.load(Open.read(lock))
275
+ Misc.load_yaml(lock)
276
276
  end
277
277
  info.values_at "pid", "ppid", "time"
278
278
  rescue Exception
data/lib/rbbt/persist.rb CHANGED
@@ -148,9 +148,7 @@ module Persist
148
148
  JSON.parse(stream.read)
149
149
  end
150
150
  when :yaml
151
- Open.open(path) do |stream|
152
- YAML.load(stream)
153
- end
151
+ Misc.load_yaml(path)
154
152
  when :float
155
153
  Open.read(path).to_f
156
154
  when :integer
@@ -150,7 +150,7 @@ module Path
150
150
  search_path_file = File.join(ENV['HOME'], '.rbbt/etc/search_paths')
151
151
  if File.exist?(search_path_file)
152
152
  begin
153
- YAML.load(File.open(search_path_file)).each do |where, location|
153
+ Misc.load_yaml(search_path_file).each do |where, location|
154
154
  SEARCH_PATHS[where.to_sym] = location
155
155
  end
156
156
  rescue
data/lib/rbbt/resource.rb CHANGED
@@ -90,6 +90,7 @@ module Resource
90
90
 
91
91
  lock_filename = nil # it seems like this was locked already.
92
92
 
93
+ Log.low "Downloading #{path} from #{url} file server"
93
94
  Misc.lock lock_filename do
94
95
  begin
95
96
  uri = URI(url)
@@ -105,7 +105,7 @@ module TSV
105
105
  if other.include? source_key
106
106
  v = case other.type
107
107
  when :flat
108
- other[source_key]
108
+ other[source_key]
109
109
  when :single
110
110
  [other[source_key]]
111
111
  when :double
@@ -135,8 +135,12 @@ module TSV
135
135
  if pos == :key
136
136
  source_key
137
137
  else
138
- if other.include? source_key
139
- v = other[source_key][pos]
138
+ if other.include?(source_key)
139
+ if other.type == :single
140
+ v = other[source_key]
141
+ else
142
+ v = other[source_key][pos]
143
+ end
140
144
  Array === v ? v.first : v
141
145
  else
142
146
  nil
@@ -192,7 +196,7 @@ module TSV
192
196
  end
193
197
  end
194
198
  new_values.collect!{|v| v.nil? ? [[]] : [v]} if type == :double and not other.type == :double
195
- new_values.collect!{|v| v.nil? ? nil : (other.type == :single ? v : v.first)} if not type == :double and other.type == :double
199
+ new_values.collect!{|v| v.nil? ? nil : (other.type == :single ? v : v.first)} if not type == :double and other.type == :double
196
200
  new_values.flatten! if type == :flat
197
201
  all_new_values << new_values
198
202
  end
@@ -42,7 +42,7 @@ module R
42
42
  def colClasses(tsv)
43
43
  return nil unless TSV === tsv
44
44
  "c('character', " <<
45
- (tsv.fields.collect{|f| R.ruby2R(@options[f] ? @options[f].to_s : ":NA") } * ", ") <<
45
+ (tsv.fields.collect{|f| R.ruby2R(@options[f] ? @options[f].to_s : "NA") } * ", ") <<
46
46
  ")"
47
47
  end
48
48
 
@@ -47,6 +47,8 @@ module R
47
47
  else
48
48
  "'character'"
49
49
  end
50
+ when Time
51
+ "'Date'"
50
52
  when Symbol
51
53
  "'factor'"
52
54
  else
data/lib/rbbt/util/R.rb CHANGED
@@ -131,7 +131,7 @@ source(interactive.script.file)
131
131
  "Inf"
132
132
  when nil
133
133
  "NULL"
134
- when "NA"
134
+ when ":NA"
135
135
  "NA"
136
136
  when TSV
137
137
  "matrix(#{R.ruby2R object.values},dimnames=list(#{R.ruby2R object.keys}, #{R.ruby2R object.fields}))"
data/lib/rbbt/util/cmd.rb CHANGED
@@ -112,6 +112,7 @@ module CMD
112
112
  no_wait = options.delete(:no_wait)
113
113
  xvfb = options.delete(:xvfb)
114
114
  bar = options.delete(:progress_bar)
115
+ save_stderr = options.delete(:save_stderr)
115
116
 
116
117
  dont_close_in = options.delete(:dont_close_in)
117
118
 
@@ -154,7 +155,7 @@ module CMD
154
155
  Open3.popen3(ENV, cmd)
155
156
  rescue
156
157
  Log.warn $!.message
157
- raise ProcessFailed, cmd unless no_fail
158
+ raise ProcessFailed, nil, cmd unless no_fail
158
159
  return
159
160
  end
160
161
  pid = wait_thr.pid
@@ -198,6 +199,7 @@ module CMD
198
199
  while line = serr.gets
199
200
  bar.process(line) if bar
200
201
  sout.log = line
202
+ sout.std_err << line if save_stderr
201
203
  Log.log "STDERR [#{pid}]: " + line, stderr if log
202
204
  end
203
205
  serr.close
@@ -244,9 +246,9 @@ module CMD
244
246
  status = wait_thr.value
245
247
  if not status.success? and not no_fail
246
248
  if !err.empty?
247
- raise ProcessFailed.new "Command [#{pid}] #{cmd} failed with error status #{status.exitstatus}.\n#{err}"
249
+ raise ProcessFailed.new pid, "#{cmd} failed with error status #{status.exitstatus}.\n#{err}"
248
250
  else
249
- raise ProcessFailed.new "Command [#{pid}] #{cmd} failed with error status #{status.exitstatus}"
251
+ raise ProcessFailed.new pid, "#{cmd} failed with error status #{status.exitstatus}"
250
252
  end
251
253
  else
252
254
  Log.log err, stderr if Integer === stderr and log
@@ -7,7 +7,7 @@ module AbortedStream
7
7
  end
8
8
 
9
9
  module ConcurrentStream
10
- attr_accessor :threads, :pids, :callback, :abort_callback, :filename, :joined, :aborted, :autojoin, :lockfile, :no_fail, :pair, :thread, :stream_exception, :log
10
+ attr_accessor :threads, :pids, :callback, :abort_callback, :filename, :joined, :aborted, :autojoin, :lockfile, :no_fail, :pair, :thread, :stream_exception, :log, :std_err
11
11
 
12
12
  def self.setup(stream, options = {}, &block)
13
13
 
@@ -20,6 +20,7 @@ module ConcurrentStream
20
20
  stream.pids.concat(Array === pids ? pids : [pids]) unless pids.nil? or pids.empty?
21
21
  stream.autojoin = autojoin unless autojoin.nil?
22
22
  stream.no_fail = no_fail unless no_fail.nil?
23
+ stream.std_err = ""
23
24
 
24
25
  stream.pair = pair unless pair.nil?
25
26
 
@@ -81,12 +82,16 @@ module ConcurrentStream
81
82
  begin
82
83
  t.join
83
84
  if Process::Status === t.value
84
- if log
85
- raise ProcessFailed.new "Error joining process #{t.pid} in #{self.filename || self.inspect}. Last log line: #{log}" if ! (t.value.success? || no_fail)
86
- else
87
- raise ProcessFailed.new "Error joining process #{t.pid} in #{self.filename || self.inspect}" if ! (t.value.success? || no_fail)
85
+ if ! (t.value.success? || no_fail)
86
+
87
+ if log
88
+ msg = "Error joining #{self.filename || self.inspect}. Last log line: #{log}"
89
+ else
90
+ msg = "Error joining #{self.filename || self.inspect}"
91
+ end
92
+
93
+ raise ConcurrentStreamProcessFailed.new t.pid, msg, self
88
94
  end
89
- raise ProcessFailed.new "Error joining process #{t.pid} in #{self.filename || self.inspect}. Last log line: #{log}" if ! (t.value.success? || no_fail)
90
95
  end
91
96
  rescue Exception
92
97
  if no_fail
@@ -106,11 +111,7 @@ module ConcurrentStream
106
111
  @pids.each do |pid|
107
112
  begin
108
113
  Process.waitpid(pid, Process::WUNTRACED)
109
- if log
110
- stream_raise_exception ProcessFailed.new "Error joining process #{pid} in #{self.filename || self.inspect}. Last log line: #{log}" unless $?.success? or no_fail
111
- else
112
- stream_raise_exception ProcessFailed.new "Error joining process #{pid} in #{self.filename || self.inspect}" unless $?.success? or no_fail
113
- end
114
+ stream_raise_exception ConcurrentStreamProcessFailed.new(pid, "Error in waitpid", self) unless $?.success? or no_fail
114
115
  rescue Errno::ECHILD
115
116
  end
116
117
  end
@@ -420,7 +420,8 @@ def self.add_libdir(dir=nil)
420
420
  def self.ssh_run(server, script = nil)
421
421
  Log.debug "Run ssh script in #{server}:\n#{script}"
422
422
 
423
- CMD.cmd("ssh '#{server}' 'shopt -s expand_aliases; bash -l -c \"ruby\"' ", :in => script, :log => true).read
423
+ #CMD.cmd("ssh '#{server}' 'shopt -s expand_aliases; bash -l -c \"ruby\"' ", :in => script, :log => true).read
424
+ CMD.cmd("ssh '#{server}' ruby", :in => script, :log => true).read
424
425
  end
425
426
 
426
427
  def self.ssh_connection(server, reset = false)
@@ -437,7 +438,7 @@ def self.add_libdir(dir=nil)
437
438
  end
438
439
  end
439
440
 
440
- def self.ssh_run(server, script = nil)
441
+ def self.ssh_run_alt(server, script = nil)
441
442
  Log.debug "Run ssh script in #{server}:\n#{script}"
442
443
 
443
444
  write, master, pid = ssh_connection(server)
@@ -1,16 +1,39 @@
1
1
  class RbbtException < StandardError; end
2
2
  class ParameterException < RbbtException; end
3
3
 
4
+ class MissingParameterException < ParameterException
5
+ def initialize(parameter)
6
+ super("Missing parameter '#{parameter}'")
7
+ end
8
+ end
9
+
4
10
  class FieldNotFoundError < StandardError;end
5
11
  class ClosedStream < StandardError; end
6
12
 
7
13
  class ProcessFailed < StandardError;
8
- def initialize(pid = Process.pid)
14
+ attr_accessor :pid, :msg
15
+ def initialize(pid = Process.pid, msg = nil)
9
16
  @pid = pid
10
- @msg = "Process #{@pid} failed"
11
- super(@msg)
17
+ @msg = msg
18
+ if @pid
19
+ if @msg
20
+ message = "Process #{@pid} failed - #{@msg}"
21
+ else
22
+ message = "Process #{@pid} failed"
23
+ end
24
+ else
25
+ message = "Failed to run #{@msg}"
26
+ end
27
+ super(message)
12
28
  end
29
+ end
13
30
 
31
+ class ConcurrentStreamProcessFailed < ProcessFailed
32
+ attr_accessor :concurrent_stream
33
+ def initialize(pid = Process.pid, msg = nil, concurrent_stream = nil)
34
+ super(pid, msg)
35
+ @concurrent_stream = concurrent_stream
36
+ end
14
37
  end
15
38
 
16
39
  class Aborted < StandardError; end
@@ -276,7 +276,7 @@ module Misc
276
276
 
277
277
  def self.step_file?(path)
278
278
  return true if defined?(Step) && Step === path.resource
279
- return false unless path.include?('.files/')
279
+ return false unless path =~ /\.files(?:\/|$)/
280
280
  parts = path.split("/")
281
281
  job = parts.select{|p| p =~ /\.files$/}.first
282
282
  if job
@@ -0,0 +1,26 @@
1
+ module Misc
2
+ def self.load_yaml(yaml)
3
+ case yaml
4
+ when IO, StringIO
5
+ if YAML.respond_to?(:unsafe_load)
6
+ YAML.unsafe_load(yaml)
7
+ else
8
+ YAML.load(yaml)
9
+ end
10
+ when (defined?(Path) && Path)
11
+ yaml.open do |io|
12
+ load_yaml(io)
13
+ end
14
+ when String
15
+ if Misc.is_filename?(yaml)
16
+ File.open(yaml) do |io|
17
+ load_yaml(io)
18
+ end
19
+ else
20
+ load_yaml(StringIO.new(yaml))
21
+ end
22
+ else
23
+ raise "Unkown YAML object: #{Misc.fingerprint yaml}"
24
+ end
25
+ end
26
+ end
@@ -22,6 +22,8 @@ require 'rbbt/util/misc/objects'
22
22
  require 'rbbt/util/misc/manipulation'
23
23
  require 'rbbt/util/misc/communication'
24
24
 
25
+ require 'rbbt/util/misc/serialize'
26
+
25
27
  require 'to_regexp'
26
28
 
27
29
  module MultipleResult; end
@@ -1,8 +1,11 @@
1
1
  module SOPT
2
2
  GOT_OPTIONS= IndiferentHash.setup({})
3
+ def self.current_options=(options)
4
+ @@current_options = options
5
+ end
3
6
  def self.consume(args = ARGV)
4
7
  i = 0
5
- values = {}
8
+ @@current_options ||= {}
6
9
  while i < args.length do
7
10
  current = args[i]
8
11
  break if current == "--"
@@ -25,20 +28,20 @@ module SOPT
25
28
 
26
29
  if input_types[input] == :string
27
30
  value = args.delete_at(i) if value.nil?
28
- values[input] = value
31
+ @@current_options[input] = value
29
32
  else
30
33
  if value.nil? and %w(F false FALSE no).include?(args[i])
31
34
  Log.warn "Boolean values are best specified as #{current}=[true|false], not #{ current } [true|false]. Token '#{args[i]}' following '#{current}' automatically assigned as value"
32
35
  value = args.delete_at(i)
33
36
  end
34
- values[input] = %w(F false FALSE no).include?(value)? false : true
37
+ @@current_options[input] = %w(F false FALSE no).include?(value)? false : true
35
38
  end
36
39
  end
37
40
 
38
- IndiferentHash.setup values
39
- GOT_OPTIONS.merge! values
41
+ IndiferentHash.setup @@current_options
42
+ GOT_OPTIONS.merge! @@current_options
40
43
 
41
- values
44
+ @@current_options
42
45
  end
43
46
 
44
47
  def self.get(opt_str)
@@ -48,7 +48,7 @@ module Ansible
48
48
  end
49
49
 
50
50
  def self.playbook(file, task = nil, options = {})
51
- task = 'default' if task.nil?
51
+ task = task.to_sym if String === task
52
52
 
53
53
  workflow = Workflow === file ? file : Workflow.require_workflow(file)
54
54
  task = workflow.tasks.keys.last if workflow.tasks[task].nil?
@@ -85,7 +85,9 @@ job = wf.job(task, jobname, job_inputs)
85
85
  STDOUT.write res.to_json
86
86
  EOF
87
87
 
88
- JSON.parse(Misc.ssh_run(server, script))
88
+ json = Misc.ssh_run(server, script)
89
+ Log.debug "JSON (#{ url }): #{json}"
90
+ JSON.parse(json)
89
91
  end
90
92
 
91
93
  def self.get_raw(url, params)
@@ -118,19 +120,40 @@ STDOUT.write job.path
118
120
  script += job_script(input_id, jobname)
119
121
  script +=<<-EOF
120
122
  ENV["RBBT_UPDATE"]="#{(ENV["RBBT_UPDATE"] || false).to_s}"
121
- job.produce
123
+ job.clean if job.error? and job.recoverable_error?
124
+ job.run unless job.done? || job.error?
122
125
  STDOUT.write job.path
123
126
  EOF
124
127
  Misc.ssh_run(server, script)
125
128
  end
126
129
 
127
- def self.run_slurm_job(url, input_id, jobname = nil)
130
+ def self.run_slurm_job(url, input_id, jobname = nil, slurm_options = {})
128
131
  server, path = parse_url(url)
129
132
 
130
133
  script = path_script(path)
131
134
  script += job_script(input_id, jobname)
132
135
  script +=<<-EOF
133
- job.produce
136
+ require 'rbbt/hpc'
137
+ HPC::BATCH_MODULE = HPC.batch_system "SLURM"
138
+ slurm_options = JSON.parse(%q(#{slurm_options.to_json}))
139
+ job.clean if job.error? and job.recoverable_error?
140
+ HPC::BATCH_MODULE.run_job(job, slurm_options) unless job.done? || job.error?
141
+ STDOUT.write job.path
142
+ EOF
143
+ Misc.ssh_run(server, script)
144
+ end
145
+
146
+ def self.orchestrate_slurm_job(url, input_id, jobname = nil, slurm_options = {})
147
+ server, path = parse_url(url)
148
+
149
+ script = path_script(path)
150
+ script += job_script(input_id, jobname)
151
+ script +=<<-EOF
152
+ require 'rbbt/hpc'
153
+ HPC::BATCH_MODULE = HPC.batch_system "SLURM"
154
+ slurm_options = JSON.parse(%q(#{slurm_options.to_json}))
155
+ job.clean if job.error? and job.recoverable_error?
156
+ HPC::BATCH_MODULE.orchestrate_job(job, slurm_options) unless job.done? || job.error?
134
157
  STDOUT.write job.path
135
158
  EOF
136
159
  Misc.ssh_run(server, script)
@@ -190,18 +213,20 @@ job.clean
190
213
  produce = true if migrate
191
214
 
192
215
  workflow_name = job.workflow.to_s
193
- inputs = job.inputs.to_hash
216
+ inputs = job.recursive_inputs.to_hash
217
+
194
218
  job.dependencies.each do |dep|
195
- dep.produce if options[:produce_dependencies]
196
- next unless dep.done?
219
+ dep.produce
220
+ end if options[:produce_dependencies]
197
221
 
198
- Step.migrate(dep.path, search_path, :target => server)
222
+ job.rec_dependencies.each do |dep|
223
+ Step.migrate(dep.path, search_path, :target => server) if dep.done?
199
224
  end
200
225
 
201
226
  remote_workflow = RemoteWorkflow.new("ssh://#{server}:#{job.workflow.to_s}", "#{job.workflow.to_s}")
202
227
  rjob = remote_workflow.job(job.task_name.to_s, job.clean_name, inputs)
203
228
 
204
- override_dependencies = job.dependencies.collect{|dep| [dep.workflow.to_s, dep.task_name.to_s] * "#" << "=" << Rbbt.identify(dep.path)}
229
+ override_dependencies = job.rec_dependencies.select{|dep| dep.done? }.collect{|dep| [dep.workflow.to_s, dep.task_name.to_s] * "#" << "=" << Rbbt.identify(dep.path)}
205
230
  rjob.override_dependencies = override_dependencies
206
231
 
207
232
  if options[:migrate]
@@ -50,15 +50,20 @@ class RemoteStep
50
50
  "ssh://" + @server + ":" + ["var/jobs", self.workflow.to_s, task_name.to_s, @name] * "/"
51
51
  end
52
52
  end
53
+
54
+ def _run
55
+ RemoteWorkflow::SSH.run_job(File.join(base_url, task.to_s), @input_id, @base_name)
56
+ end
53
57
 
54
58
  def produce(*args)
55
59
  input_types = {}
56
60
  init_job
57
- @remote_path = RemoteWorkflow::SSH.run_job(File.join(base_url, task.to_s), @input_id, @base_name)
61
+ @remote_path = _run
58
62
  @started = true
59
- while ! done?
63
+ while ! (done? || error?)
60
64
  sleep 1
61
65
  end
66
+ raise self.get_exception if error?
62
67
  self
63
68
  end
64
69
 
@@ -266,6 +266,8 @@ class RemoteStep < Step
266
266
  end
267
267
  end
268
268
 
269
+ raise "Error in remote step" if self.error?
270
+
269
271
  self
270
272
  end
271
273
 
@@ -143,8 +143,12 @@ class Step
143
143
 
144
144
  def init_info(force = false)
145
145
  return nil if @exec || info_file.nil? || (Open.exists?(info_file) && ! force)
146
+ batch_job = info[:batch_job] if Open.exists?(info_file)
147
+ batch_system = info[:batch_system] if Open.exists?(info_file)
146
148
  Open.lock(info_file, :lock => info_lock) do
147
149
  i = {:status => :waiting, :pid => Process.pid, :path => path, :real_inputs => real_inputs, :overriden => overriden}
150
+ i[:batch_job] = batch_job if batch_job
151
+ i[:batch_system] = batch_system if batch_system
148
152
  i[:dependencies] = dependencies.collect{|dep| [dep.task_name, dep.name, dep.path]} if dependencies
149
153
  Misc.sensiblewrite(info_file, Step.serialize_info(i), :force => true, :lock => false)
150
154
  @info_cache = IndiferentHash.setup(i)
@@ -253,7 +257,7 @@ class Step
253
257
  #Open.read(file(name)).split /\n|,\s*/
254
258
  Open.read(file(name)).split "\n"
255
259
  when :yaml
256
- YAML.load(Open.open(file(name)))
260
+ Misc.load_yaml(file(name))
257
261
  when :marshal
258
262
  Marshal.load(Open.open(file(name)))
259
263
  else
@@ -698,7 +698,7 @@ class Step
698
698
  end
699
699
 
700
700
  def grace
701
- until done? || result || error? || aborted? || streaming? || waiting?
701
+ until done? || result || error? || aborted? || streaming? || waiting? || running?
702
702
  sleep 1
703
703
  end
704
704
  self
@@ -82,7 +82,7 @@ module Workflow
82
82
  when :file, :binary
83
83
  Log.debug "Pointing #{ input } to #{file}"
84
84
  if file =~ /\.yaml/
85
- inputs[input.to_sym] = YAML.load(Open.read(file))
85
+ inputs[input.to_sym] = Misc.load_yaml(file)
86
86
  else
87
87
  if File.symlink?(file)
88
88
  link_target = File.expand_path(File.readlink(file), File.dirname(file))
@@ -201,6 +201,7 @@ class Step
201
201
 
202
202
  def self.save_inputs(inputs, input_types, dir)
203
203
  inputs.each do |name,value|
204
+ next if value.nil?
204
205
  type = input_types[name]
205
206
  type = type.to_s if type
206
207
 
@@ -15,7 +15,7 @@ class Step
15
15
  raise "DO NOT CLEAN"
16
16
  end
17
17
 
18
- if (Open.exists?(path) or Open.broken_link?(path)) or Open.exists?(pid_file) or Open.exists?(info_file) or Open.exists?(files_dir) or Open.broken_link?(files_dir)
18
+ if (Open.exists?(path) or Open.broken_link?(path)) or Open.exists?(pid_file) or Open.exists?(info_file) or Open.exists?(files_dir) or Open.broken_link?(files_dir) or Open.exists?(pid_file)
19
19
 
20
20
  @result = nil
21
21
  @pid = nil
data/lib/rbbt/workflow.rb CHANGED
@@ -520,6 +520,7 @@ module Workflow
520
520
  end
521
521
 
522
522
  def job(taskname, jobname = nil, inputs = {})
523
+ inputs, jobname = jobname, nil if Hash === jobname
523
524
  begin
524
525
  _job(taskname, jobname, inputs)
525
526
  ensure
@@ -834,8 +835,7 @@ module Workflow
834
835
  end
835
836
 
836
837
  def self.load_remote_tasks(filename)
837
- yaml_text = Open.read(filename)
838
- remote_workflow_tasks = YAML.load(yaml_text)
838
+ remote_workflow_tasks = Misc.load_yaml(filename)
839
839
  Workflow.process_remote_tasks(remote_workflow_tasks)
840
840
  end
841
841
 
@@ -859,8 +859,7 @@ module Workflow
859
859
  end
860
860
 
861
861
  def self.load_relay_tasks(filename)
862
- yaml_text = Open.read(filename)
863
- relay_workflow_tasks = YAML.load(yaml_text)
862
+ relay_workflow_tasks = Misc.load_yaml(filename)
864
863
  Workflow.process_relay_tasks(relay_workflow_tasks)
865
864
  end
866
865
  end
@@ -85,7 +85,7 @@ uncompress_pkg(){
85
85
  mkdir -p "$OPT_BUILD_DIR"
86
86
  cd "$OPT_BUILD_DIR"
87
87
 
88
- (tar xvfz $pkg || tar xvfJ $pkg || tar xvfj $pkg || unzip $pkg || (echo "Error decompressing" & cd & rmdir "$OPT_BUILD_DIR" & exit -1 ) ) 2> /dev/null
88
+ (tar xvfz $pkg || tar xvfJ $pkg || tar xvfj $pkg || unzip $pkg || (echo "Error decompressing" & cd & exit -1 ) ) 2> /dev/null
89
89
 
90
90
  cd "$old_pwd"
91
91
  }
@@ -178,7 +178,7 @@ clean_build(){
178
178
  }
179
179
 
180
180
  build_dir(){
181
- echo $OPT_BUILD_DIR/`ls $OPT_BUILD_DIR |head -n 1`
181
+ echo $OPT_BUILD_DIR/$(ls $OPT_BUILD_DIR |head -n 1)
182
182
  }
183
183
 
184
184
  compile(){
@@ -211,6 +211,7 @@ prepare_make(){
211
211
  local extra="$@"
212
212
 
213
213
  local old_pwd="`expand_path $(pwd)`"
214
+
214
215
  cd "`build_dir`"
215
216
 
216
217
  [ -f bootstrap ] && (./bootstrap || exit -1)
@@ -42,7 +42,6 @@ if ! Misc.filename?(playbook_file)
42
42
  playbook_file = Ansible.playbook recipe, task, options
43
43
  end
44
44
 
45
-
46
45
  if dry_run
47
46
  if Hash === playbook_file
48
47
  ppp playbook_file.to_yaml
@@ -3,10 +3,13 @@
3
3
  require 'rbbt/util/simpleopt'
4
4
  require 'rbbt/workflow'
5
5
  require 'rbbt/workflow/usage'
6
+ require 'rbbt/workflow/remote_workflow'
6
7
  require 'rbbt/hpc'
7
8
  require 'rbbt/hpc/orchestrate'
8
9
  require 'time'
9
10
 
11
+ rbbt_options = SOPT::GOT_OPTIONS
12
+
10
13
  $slurm_options = SOPT.get <<EOF
11
14
  -dr--dry_run Print only the template
12
15
  -cj--clean_job Clean job
@@ -46,6 +49,8 @@ EOF
46
49
  batch_system = $slurm_options.delete :batch_system
47
50
  batch_system ||= 'auto'
48
51
 
52
+ $slurm_options[:config_keys] = SOPT::GOT_OPTIONS[:config_keys]
53
+
49
54
  HPC::BATCH_MODULE = HPC.batch_system batch_system
50
55
 
51
56
  raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint batch_system}") if HPC::BATCH_MODULE.nil?
@@ -61,7 +66,6 @@ class Step
61
66
  else
62
67
  begin
63
68
  Log.debug "Issuing SLURM job for #{self.path}"
64
- #@batch_job_id, @batch_job_dir = HPC::BATCH_MODULE.orchestrate_job(self, SOPT::GOT_OPTIONS.merge($slurm_options))
65
69
  @batch_job_id, @batch_job_dir = HPC::BATCH_MODULE.orchestrate_job(self, $slurm_options)
66
70
  if no_load
67
71
  self
@@ -75,6 +79,14 @@ class Step
75
79
  end
76
80
  end
77
81
 
78
- ARGV.concat ['--detach']
79
- ARGV.concat ["-W", $slurm_options[:workflows]] if $slurm_options[:workflows]
82
+ module RemoteStep::SSH
83
+
84
+ def _run
85
+ RemoteWorkflow::SSH.orchestrate_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $slurm_options)
86
+ end
87
+
88
+ end
89
+
90
+ SOPT.current_options = rbbt_options
91
+
80
92
  load Rbbt.share.rbbt_commands.workflow.task.find
@@ -3,9 +3,12 @@
3
3
  require 'rbbt/util/simpleopt'
4
4
  require 'rbbt/workflow'
5
5
  require 'rbbt/workflow/usage'
6
+ require 'rbbt/workflow/remote_workflow'
6
7
  require 'rbbt/hpc'
7
8
  require 'time'
8
9
 
10
+ rbbt_options = SOPT::GOT_OPTIONS
11
+
9
12
  $slurm_options = SOPT.get <<EOF
10
13
  -dr--dry_run Print only the template
11
14
  -cj--clean_job Clean job
@@ -56,12 +59,20 @@ class Step
56
59
  else
57
60
  begin
58
61
  Log.debug "Issuing SLURM job for #{self.path}"
59
- HPC::BATCH_MODULE.run_job(self, SOPT::GOT_OPTIONS.merge($slurm_options))
62
+ HPC::BATCH_MODULE.run_job(self, $slurm_options)
60
63
  rescue HPC::SBATCH
61
64
  end
62
65
  end
63
66
  end
64
67
  end
65
68
 
66
- ARGV.concat ["-W", $slurm_options[:workflows]] if $slurm_options[:workflows]
69
+ module RemoteStep::SSH
70
+
71
+ def _run
72
+ RemoteWorkflow::SSH.run_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $slurm_options)
73
+ end
74
+
75
+ end
76
+
77
+ SOPT.current_options = rbbt_options
67
78
  load Rbbt.share.rbbt_commands.workflow.task.find
@@ -3,10 +3,13 @@
3
3
  require 'rbbt/util/simpleopt'
4
4
  require 'rbbt/workflow'
5
5
  require 'rbbt/workflow/usage'
6
+ require 'rbbt/workflow/remote_workflow'
6
7
  require 'rbbt/hpc'
7
8
  require 'rbbt/hpc/orchestrate'
8
9
  require 'time'
9
10
 
11
+ rbbt_options = SOPT::GOT_OPTIONS
12
+
10
13
  $slurm_options = SOPT.get <<EOF
11
14
  -dr--dry_run Print only the template
12
15
  -cj--clean_job Clean job
@@ -46,6 +49,8 @@ EOF
46
49
  batch_system = $slurm_options.delete :batch_system
47
50
  batch_system ||= 'auto'
48
51
 
52
+ $slurm_options[:config_keys] = SOPT::GOT_OPTIONS[:config_keys]
53
+
49
54
  HPC::BATCH_MODULE = HPC.batch_system batch_system
50
55
 
51
56
  raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint batch_system}") if HPC::BATCH_MODULE.nil?
@@ -61,7 +66,6 @@ class Step
61
66
  else
62
67
  begin
63
68
  Log.debug "Issuing SLURM job for #{self.path}"
64
- #@batch_job_id, @batch_job_dir = HPC::BATCH_MODULE.orchestrate_job(self, SOPT::GOT_OPTIONS.merge($slurm_options))
65
69
  @batch_job_id, @batch_job_dir = HPC::BATCH_MODULE.orchestrate_job(self, $slurm_options)
66
70
  if no_load
67
71
  self
@@ -75,6 +79,14 @@ class Step
75
79
  end
76
80
  end
77
81
 
78
- ARGV.concat ['--detach']
79
- ARGV.concat ["-W", $slurm_options[:workflows]] if $slurm_options[:workflows]
82
+ module RemoteStep::SSH
83
+
84
+ def _run
85
+ RemoteWorkflow::SSH.orchestrate_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $slurm_options)
86
+ end
87
+
88
+ end
89
+
90
+ SOPT.current_options = rbbt_options
91
+
80
92
  load Rbbt.share.rbbt_commands.workflow.task.find
@@ -3,9 +3,12 @@
3
3
  require 'rbbt/util/simpleopt'
4
4
  require 'rbbt/workflow'
5
5
  require 'rbbt/workflow/usage'
6
+ require 'rbbt/workflow/remote_workflow'
6
7
  require 'rbbt/hpc'
7
8
  require 'time'
8
9
 
10
+ rbbt_options = SOPT::GOT_OPTIONS
11
+
9
12
  $slurm_options = SOPT.get <<EOF
10
13
  -dr--dry_run Print only the template
11
14
  -cj--clean_job Clean job
@@ -56,12 +59,20 @@ class Step
56
59
  else
57
60
  begin
58
61
  Log.debug "Issuing SLURM job for #{self.path}"
59
- HPC::BATCH_MODULE.run_job(self, SOPT::GOT_OPTIONS.merge($slurm_options))
62
+ HPC::BATCH_MODULE.run_job(self, $slurm_options)
60
63
  rescue HPC::SBATCH
61
64
  end
62
65
  end
63
66
  end
64
67
  end
65
68
 
66
- ARGV.concat ["-W", $slurm_options[:workflows]] if $slurm_options[:workflows]
69
+ module RemoteStep::SSH
70
+
71
+ def _run
72
+ RemoteWorkflow::SSH.run_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $slurm_options)
73
+ end
74
+
75
+ end
76
+
77
+ SOPT.current_options = rbbt_options
67
78
  load Rbbt.share.rbbt_commands.workflow.task.find
@@ -3,10 +3,13 @@
3
3
  require 'rbbt/util/simpleopt'
4
4
  require 'rbbt/workflow'
5
5
  require 'rbbt/workflow/usage'
6
+ require 'rbbt/workflow/remote_workflow'
6
7
  require 'rbbt/hpc'
7
8
  require 'rbbt/hpc/orchestrate'
8
9
  require 'time'
9
10
 
11
+ rbbt_options = SOPT::GOT_OPTIONS
12
+
10
13
  $slurm_options = SOPT.get <<EOF
11
14
  -dr--dry_run Print only the template
12
15
  -cj--clean_job Clean job
@@ -46,6 +49,8 @@ EOF
46
49
  batch_system = $slurm_options.delete :batch_system
47
50
  batch_system ||= 'auto'
48
51
 
52
+ $slurm_options[:config_keys] = SOPT::GOT_OPTIONS[:config_keys]
53
+
49
54
  HPC::BATCH_MODULE = HPC.batch_system batch_system
50
55
 
51
56
  raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint batch_system}") if HPC::BATCH_MODULE.nil?
@@ -61,7 +66,6 @@ class Step
61
66
  else
62
67
  begin
63
68
  Log.debug "Issuing SLURM job for #{self.path}"
64
- #@batch_job_id, @batch_job_dir = HPC::BATCH_MODULE.orchestrate_job(self, SOPT::GOT_OPTIONS.merge($slurm_options))
65
69
  @batch_job_id, @batch_job_dir = HPC::BATCH_MODULE.orchestrate_job(self, $slurm_options)
66
70
  if no_load
67
71
  self
@@ -75,6 +79,14 @@ class Step
75
79
  end
76
80
  end
77
81
 
78
- ARGV.concat ['--detach']
79
- ARGV.concat ["-W", $slurm_options[:workflows]] if $slurm_options[:workflows]
82
+ module RemoteStep::SSH
83
+
84
+ def _run
85
+ RemoteWorkflow::SSH.orchestrate_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $slurm_options)
86
+ end
87
+
88
+ end
89
+
90
+ SOPT.current_options = rbbt_options
91
+
80
92
  load Rbbt.share.rbbt_commands.workflow.task.find
@@ -3,9 +3,12 @@
3
3
  require 'rbbt/util/simpleopt'
4
4
  require 'rbbt/workflow'
5
5
  require 'rbbt/workflow/usage'
6
+ require 'rbbt/workflow/remote_workflow'
6
7
  require 'rbbt/hpc'
7
8
  require 'time'
8
9
 
10
+ rbbt_options = SOPT::GOT_OPTIONS
11
+
9
12
  $slurm_options = SOPT.get <<EOF
10
13
  -dr--dry_run Print only the template
11
14
  -cj--clean_job Clean job
@@ -56,12 +59,20 @@ class Step
56
59
  else
57
60
  begin
58
61
  Log.debug "Issuing SLURM job for #{self.path}"
59
- HPC::BATCH_MODULE.run_job(self, SOPT::GOT_OPTIONS.merge($slurm_options))
62
+ HPC::BATCH_MODULE.run_job(self, $slurm_options)
60
63
  rescue HPC::SBATCH
61
64
  end
62
65
  end
63
66
  end
64
67
  end
65
68
 
66
- ARGV.concat ["-W", $slurm_options[:workflows]] if $slurm_options[:workflows]
69
+ module RemoteStep::SSH
70
+
71
+ def _run
72
+ RemoteWorkflow::SSH.run_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $slurm_options)
73
+ end
74
+
75
+ end
76
+
77
+ SOPT.current_options = rbbt_options
67
78
  load Rbbt.share.rbbt_commands.workflow.task.find
@@ -46,7 +46,7 @@ if locks.any?
46
46
  puts
47
47
  puts Log.color(:magenta, "Locks:")
48
48
  locks.each do |file,info|
49
- if force or (info[:pid] and not Misc.pid_exists? info[:pid])
49
+ if force or (info[:pid] && ! Misc.pid_exists?(info[:pid]))
50
50
  puts " Removing #{ file }"
51
51
  File.unlink file
52
52
  end
@@ -547,7 +547,8 @@ if job_file = options.delete(:job_file)
547
547
  end
548
548
 
549
549
  case res
550
- when (defined?(WorkflowRemoteClient) and WorkflowRemoteClient::RemoteStep)
550
+ #when (defined?(WorkflowRemoteClient) and WorkflowRemoteClient::RemoteStep)
551
+ when (defined?(RemoteStep) and RemoteStep)
551
552
  res = job.result
552
553
  if res.respond_to? :gets
553
554
  begin
@@ -598,7 +599,7 @@ when Step
598
599
  elsif detach
599
600
  exit! 0
600
601
  else
601
- res.join if res.running?
602
+ res.join if res.running?
602
603
  if %w(float integer string boolean).include?(res.result_type.to_s)
603
604
  out.puts res.load
604
605
  else
@@ -6,7 +6,7 @@ Workflow.require_workflow "Sample"
6
6
  Workflow.require_workflow "HTS"
7
7
  class TestSLURM < Test::Unit::TestCase
8
8
 
9
- def _test_batch_options
9
+ def test_batch_options
10
10
  job = Sample.job(:mutect2, "small", :reference => "hg38")
11
11
 
12
12
  TmpFile.with_file do |batch_dir|
@@ -17,7 +17,7 @@ class TestSLURM < Test::Unit::TestCase
17
17
  end
18
18
  end
19
19
 
20
- def _test_template
20
+ def test_template
21
21
  job = Sample.job(:mutect2, "small", :reference => "hg38")
22
22
 
23
23
  TmpFile.with_file do |batch_dir|
@@ -28,7 +28,7 @@ class TestSLURM < Test::Unit::TestCase
28
28
  end
29
29
  end
30
30
 
31
- def _test_template_singularity
31
+ def test_template_singularity
32
32
  job = Sample.job(:mutect2, "small", :reference => "hg38")
33
33
 
34
34
  TmpFile.with_file do |batch_dir|
@@ -39,7 +39,7 @@ class TestSLURM < Test::Unit::TestCase
39
39
  end
40
40
  end
41
41
 
42
- def _test_template_contain
42
+ def test_template_contain
43
43
  job = Sample.job(:mutect2, "small", :reference => "hg38")
44
44
 
45
45
  TmpFile.with_file do |batch_dir|
@@ -0,0 +1,24 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
2
+ require 'rbbt/util/misc/serialize'
3
+
4
+ class TestClass < Test::Unit::TestCase
5
+ def test_load_yaml
6
+ yaml_txt=<<-EOF
7
+ ---
8
+ a: b
9
+ EOF
10
+ yaml_sio = StringIO.new yaml_txt
11
+
12
+ assert_equal "b", Misc.load_yaml(yaml_txt)["a"]
13
+ assert_equal "b", Misc.load_yaml(yaml_sio)["a"]
14
+
15
+ TmpFile.with_file yaml_txt do |yaml_file|
16
+ assert_equal "b", Misc.load_yaml(yaml_file)["a"]
17
+ Open.open(yaml_file) do |yaml_io|
18
+ assert_equal "b", Misc.load_yaml(yaml_io)["a"]
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+
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.34.26
4
+ version: 5.35.1
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-12-14 00:00:00.000000000 Z
11
+ date: 2023-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -323,6 +323,7 @@ files:
323
323
  - lib/rbbt/util/misc/omics.rb
324
324
  - lib/rbbt/util/misc/options.rb
325
325
  - lib/rbbt/util/misc/pipes.rb
326
+ - lib/rbbt/util/misc/serialize.rb
326
327
  - lib/rbbt/util/misc/system.rb
327
328
  - lib/rbbt/util/named_array.rb
328
329
  - lib/rbbt/util/open.rb
@@ -559,6 +560,7 @@ files:
559
560
  - test/rbbt/util/misc/test_multipart_payload.rb
560
561
  - test/rbbt/util/misc/test_omics.rb
561
562
  - test/rbbt/util/misc/test_pipes.rb
563
+ - test/rbbt/util/misc/test_serialize.rb
562
564
  - test/rbbt/util/python/test_util.rb
563
565
  - test/rbbt/util/simpleopt/test_get.rb
564
566
  - test/rbbt/util/simpleopt/test_parse.rb
@@ -634,6 +636,7 @@ test_files:
634
636
  - test/rbbt/util/misc/test_development.rb
635
637
  - test/rbbt/util/misc/test_omics.rb
636
638
  - test/rbbt/util/misc/test_pipes.rb
639
+ - test/rbbt/util/misc/test_serialize.rb
637
640
  - test/rbbt/util/misc/test_format.rb
638
641
  - test/rbbt/util/misc/test_communication.rb
639
642
  - test/rbbt/util/misc/test_lock.rb