rbbt-util 5.44.1 → 6.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/bin/rbbt +67 -90
  4. data/bin/rbbt_exec.rb +2 -2
  5. data/etc/app.d/base.rb +2 -2
  6. data/etc/app.d/semaphores.rb +3 -3
  7. data/lib/rbbt/annotations/annotated_array.rb +207 -207
  8. data/lib/rbbt/annotations/refactor.rb +27 -0
  9. data/lib/rbbt/annotations/util.rb +282 -282
  10. data/lib/rbbt/annotations.rb +343 -320
  11. data/lib/rbbt/association/database.rb +200 -225
  12. data/lib/rbbt/association/index.rb +294 -291
  13. data/lib/rbbt/association/item.rb +227 -227
  14. data/lib/rbbt/association/open.rb +35 -34
  15. data/lib/rbbt/association/util.rb +0 -169
  16. data/lib/rbbt/association.rb +2 -4
  17. data/lib/rbbt/entity/identifiers.rb +119 -118
  18. data/lib/rbbt/entity/refactor.rb +12 -0
  19. data/lib/rbbt/entity.rb +319 -315
  20. data/lib/rbbt/hpc/batch.rb +72 -53
  21. data/lib/rbbt/hpc/lsf.rb +2 -2
  22. data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
  23. data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
  24. data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
  25. data/lib/rbbt/hpc/orchestrate.rb +19 -13
  26. data/lib/rbbt/hpc/slurm.rb +18 -18
  27. data/lib/rbbt/knowledge_base/entity.rb +13 -5
  28. data/lib/rbbt/knowledge_base/query.rb +2 -2
  29. data/lib/rbbt/knowledge_base/registry.rb +32 -31
  30. data/lib/rbbt/knowledge_base/traverse.rb +1 -1
  31. data/lib/rbbt/knowledge_base.rb +1 -1
  32. data/lib/rbbt/monitor.rb +36 -25
  33. data/lib/rbbt/persist/refactor.rb +166 -0
  34. data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
  35. data/lib/rbbt/persist/tsv.rb +187 -185
  36. data/lib/rbbt/persist.rb +556 -551
  37. data/lib/rbbt/refactor.rb +20 -0
  38. data/lib/rbbt/resource/path/refactor.rb +178 -0
  39. data/lib/rbbt/resource/path.rb +317 -497
  40. data/lib/rbbt/resource/util.rb +0 -48
  41. data/lib/rbbt/resource.rb +3 -390
  42. data/lib/rbbt/tsv/accessor.rb +2 -838
  43. data/lib/rbbt/tsv/attach.rb +303 -299
  44. data/lib/rbbt/tsv/change_id.rb +244 -245
  45. data/lib/rbbt/tsv/csv.rb +87 -85
  46. data/lib/rbbt/tsv/dumper.rb +2 -100
  47. data/lib/rbbt/tsv/excel.rb +26 -24
  48. data/lib/rbbt/tsv/field_index.rb +4 -1
  49. data/lib/rbbt/tsv/filter.rb +3 -2
  50. data/lib/rbbt/tsv/index.rb +2 -284
  51. data/lib/rbbt/tsv/manipulate.rb +750 -747
  52. data/lib/rbbt/tsv/marshal.rb +3 -3
  53. data/lib/rbbt/tsv/matrix.rb +2 -2
  54. data/lib/rbbt/tsv/parallel/through.rb +2 -1
  55. data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
  56. data/lib/rbbt/tsv/parser.rb +678 -678
  57. data/lib/rbbt/tsv/refactor.rb +195 -0
  58. data/lib/rbbt/tsv/stream.rb +253 -251
  59. data/lib/rbbt/tsv/util.rb +420 -420
  60. data/lib/rbbt/tsv.rb +210 -208
  61. data/lib/rbbt/util/R/eval.rb +4 -4
  62. data/lib/rbbt/util/R/plot.rb +62 -166
  63. data/lib/rbbt/util/R.rb +21 -18
  64. data/lib/rbbt/util/cmd.rb +2 -318
  65. data/lib/rbbt/util/color.rb +269 -269
  66. data/lib/rbbt/util/colorize.rb +89 -89
  67. data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
  68. data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
  69. data/lib/rbbt/util/concurrency/processes.rb +389 -386
  70. data/lib/rbbt/util/config.rb +169 -167
  71. data/lib/rbbt/util/filecache.rb +1 -1
  72. data/lib/rbbt/util/iruby.rb +20 -0
  73. data/lib/rbbt/util/log/progress/report.rb +241 -241
  74. data/lib/rbbt/util/log/progress/util.rb +99 -99
  75. data/lib/rbbt/util/log/progress.rb +102 -102
  76. data/lib/rbbt/util/log/refactor.rb +49 -0
  77. data/lib/rbbt/util/log.rb +486 -532
  78. data/lib/rbbt/util/migrate.rb +2 -2
  79. data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
  80. data/lib/rbbt/util/misc/development.rb +12 -11
  81. data/lib/rbbt/util/misc/exceptions.rb +117 -112
  82. data/lib/rbbt/util/misc/format.rb +2 -230
  83. data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
  84. data/lib/rbbt/util/misc/inspect.rb +2 -476
  85. data/lib/rbbt/util/misc/lock.rb +109 -106
  86. data/lib/rbbt/util/misc/omics.rb +9 -1
  87. data/lib/rbbt/util/misc/pipes.rb +765 -793
  88. data/lib/rbbt/util/misc/refactor.rb +20 -0
  89. data/lib/rbbt/util/misc/ssw.rb +27 -17
  90. data/lib/rbbt/util/misc/system.rb +92 -105
  91. data/lib/rbbt/util/misc.rb +39 -20
  92. data/lib/rbbt/util/named_array/refactor.rb +4 -0
  93. data/lib/rbbt/util/named_array.rb +3 -220
  94. data/lib/rbbt/util/open/refactor.rb +7 -0
  95. data/lib/rbbt/util/open.rb +3 -857
  96. data/lib/rbbt/util/procpath.rb +6 -6
  97. data/lib/rbbt/util/python/paths.rb +27 -0
  98. data/lib/rbbt/util/python/run.rb +115 -0
  99. data/lib/rbbt/util/python/script.rb +110 -0
  100. data/lib/rbbt/util/python/util.rb +3 -3
  101. data/lib/rbbt/util/python.rb +22 -81
  102. data/lib/rbbt/util/semaphore.rb +152 -148
  103. data/lib/rbbt/util/simpleopt.rb +9 -8
  104. data/lib/rbbt/util/ssh/refactor.rb +19 -0
  105. data/lib/rbbt/util/ssh.rb +122 -118
  106. data/lib/rbbt/util/tar.rb +117 -115
  107. data/lib/rbbt/util/tmpfile.rb +69 -67
  108. data/lib/rbbt/util/version.rb +2 -0
  109. data/lib/rbbt/workflow/refactor/entity.rb +11 -0
  110. data/lib/rbbt/workflow/refactor/export.rb +66 -0
  111. data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
  112. data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
  113. data/lib/rbbt/workflow/refactor/task_info.rb +66 -0
  114. data/lib/rbbt/workflow/refactor.rb +150 -0
  115. data/lib/rbbt/workflow/remote_workflow/driver/rest.rb +1 -2
  116. data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
  117. data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
  118. data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
  119. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
  120. data/lib/rbbt/workflow/remote_workflow.rb +6 -1
  121. data/lib/rbbt/workflow/step/run.rb +766 -766
  122. data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
  123. data/lib/rbbt/workflow/step.rb +2 -362
  124. data/lib/rbbt/workflow/task.rb +118 -118
  125. data/lib/rbbt/workflow/usage.rb +289 -287
  126. data/lib/rbbt/workflow/util/archive.rb +6 -5
  127. data/lib/rbbt/workflow/util/data.rb +1 -1
  128. data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
  129. data/lib/rbbt/workflow/util/trace.rb +79 -44
  130. data/lib/rbbt/workflow.rb +4 -882
  131. data/lib/rbbt-util.rb +21 -13
  132. data/lib/rbbt.rb +16 -3
  133. data/python/rbbt/__init__.py +96 -4
  134. data/python/rbbt/workflow/remote.py +104 -0
  135. data/python/rbbt/workflow.py +64 -0
  136. data/python/test.py +10 -0
  137. data/share/Rlib/plot.R +37 -37
  138. data/share/Rlib/svg.R +22 -5
  139. data/share/install/software/lib/install_helpers +1 -1
  140. data/share/rbbt_commands/hpc/list +2 -3
  141. data/share/rbbt_commands/hpc/orchestrate +4 -4
  142. data/share/rbbt_commands/hpc/tail +2 -0
  143. data/share/rbbt_commands/hpc/task +10 -7
  144. data/share/rbbt_commands/lsf/list +2 -3
  145. data/share/rbbt_commands/lsf/orchestrate +4 -4
  146. data/share/rbbt_commands/lsf/tail +2 -0
  147. data/share/rbbt_commands/lsf/task +10 -7
  148. data/share/rbbt_commands/migrate +1 -1
  149. data/share/rbbt_commands/pbs/list +2 -3
  150. data/share/rbbt_commands/pbs/orchestrate +4 -4
  151. data/share/rbbt_commands/pbs/tail +2 -0
  152. data/share/rbbt_commands/pbs/task +10 -7
  153. data/share/rbbt_commands/resource/produce +8 -1
  154. data/share/rbbt_commands/slurm/list +2 -3
  155. data/share/rbbt_commands/slurm/orchestrate +4 -4
  156. data/share/rbbt_commands/slurm/tail +2 -0
  157. data/share/rbbt_commands/slurm/task +10 -7
  158. data/share/rbbt_commands/system/clean +5 -5
  159. data/share/rbbt_commands/system/status +5 -5
  160. data/share/rbbt_commands/tsv/get +2 -3
  161. data/share/rbbt_commands/tsv/info +10 -13
  162. data/share/rbbt_commands/tsv/keys +18 -14
  163. data/share/rbbt_commands/tsv/slice +2 -2
  164. data/share/rbbt_commands/tsv/transpose +6 -2
  165. data/share/rbbt_commands/workflow/info +20 -24
  166. data/share/rbbt_commands/workflow/list +1 -1
  167. data/share/rbbt_commands/workflow/prov +20 -13
  168. data/share/rbbt_commands/workflow/retry +43 -0
  169. data/share/rbbt_commands/workflow/server +12 -2
  170. data/share/rbbt_commands/workflow/task +80 -73
  171. data/share/rbbt_commands/workflow/write_info +26 -9
  172. data/share/software/opt/ssw/ssw.c +861 -0
  173. data/share/software/opt/ssw/ssw.h +130 -0
  174. data/share/workflow_config.ru +3 -3
  175. metadata +45 -6
@@ -18,9 +18,9 @@ $slurm_options = SOPT.get <<EOF
18
18
  -si--singularity_img* Singularity image to use
19
19
  -sm--singularity_mounts* Singularity image to use
20
20
  -ug--user_group* Use alternative user group for group project directory
21
- -c--contain* Contain in directory (using Singularity)
22
- -s--sync* Contain in directory and sync jobs
23
- -e--exclusive Make exclusive use of the node
21
+ --contain* Contain in directory (using Singularity)
22
+ --sync* Contain in directory and sync jobs
23
+ --exclusive Make exclusive use of the node
24
24
  -hm--highmem Make use of highmem cores
25
25
  -wc--wipe_container* Wipe the jobs from the contain directory
26
26
  -pd--purge_deps Purge job dependencies
@@ -57,7 +57,7 @@ raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint
57
57
 
58
58
  class Step
59
59
  def join
60
- HPC::BATCH_MODULE.wait_for_job(@batch_job_dir)
60
+ HPC::BATCH_MODULE.wait_for_job(@batch_job_dir) unless done?
61
61
  end
62
62
 
63
63
  def run(no_load = true)
@@ -33,6 +33,8 @@ raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint
33
33
 
34
34
  directory = ARGV.shift
35
35
 
36
+ directory = HPC::BATCH_MODULE.jobs.first if directory.nil?
37
+
36
38
  raise ParameterException if directory.nil?
37
39
 
38
40
  if directory =~ /^[0-9]*$/
@@ -9,7 +9,7 @@ require 'time'
9
9
 
10
10
  rbbt_options = SOPT::GOT_OPTIONS
11
11
 
12
- $slurm_options = SOPT.get <<EOF
12
+ $batch_options = SOPT.get <<EOF
13
13
  -dr--dry_run Print only the template
14
14
  -cj--clean_job Clean job
15
15
  --drbbt* Use development version of rbbt
@@ -17,9 +17,9 @@ $slurm_options = SOPT.get <<EOF
17
17
  -si--singularity_img* Singularity image to use
18
18
  -sm--singularity_mounts* Singularity image to use
19
19
  -ug--user_group* Use alternative user group for group project directory
20
- -c--contain* Contain in directory (using Singularity)
21
- -s--sync* Contain in directory and sync jobs
22
- -e--exclusive Make exclusive use of the node
20
+ --contain* Contain in directory (using Singularity)
21
+ --sync* Contain in directory and sync jobs
22
+ --exclusive Make exclusive use of the node
23
23
  -hm--highmem Make use of highmem cores
24
24
  -wc--wipe_container* Wipe the jobs from the contain directory
25
25
  -pd--purge_deps Purge job dependencies
@@ -45,11 +45,14 @@ $slurm_options = SOPT.get <<EOF
45
45
  -OR--orchestration_rules* Orchestration rules
46
46
  EOF
47
47
 
48
- batch_system = $slurm_options.delete :batch_system
48
+ batch_system = $batch_options.delete :batch_system
49
49
  batch_system ||= 'auto'
50
+ $batch_options[:log] = rbbt_options[:log]
51
+ $batch_options[:config_keys] = rbbt_options[:config_keys]
50
52
 
51
53
  HPC::BATCH_MODULE = HPC.batch_system batch_system
52
54
 
55
+
53
56
  raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint batch_system}") if HPC::BATCH_MODULE.nil?
54
57
 
55
58
  class Step
@@ -60,7 +63,7 @@ class Step
60
63
  else
61
64
  begin
62
65
  Log.debug "Issuing BATCH job for #{self.path}"
63
- HPC::BATCH_MODULE.run_job(self, $slurm_options)
66
+ HPC::BATCH_MODULE.run_job(self, $batch_options)
64
67
  rescue HPC::BATCH_DRY_RUN
65
68
  end
66
69
  end
@@ -70,7 +73,7 @@ end
70
73
  module RemoteStep::SSH
71
74
 
72
75
  def _run
73
- RemoteWorkflow::SSH.run_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $slurm_options)
76
+ RemoteWorkflow::SSH.run_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $batch_options)
74
77
  end
75
78
 
76
79
  end
@@ -36,4 +36,4 @@ search_path = 'user' if search_path.nil?
36
36
 
37
37
  options[:other] = other
38
38
 
39
- Rbbt.migrate(path, search_path, options)
39
+ Rbbt.migrate(path.dup, search_path, options)
@@ -206,7 +206,6 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
206
206
  require 'rbbt/workflow'
207
207
  step_path = step_line.split(": ").last.strip
208
208
  step = Step.new step_path
209
- step.load_dependencies_from_info
210
209
  has_bar = false
211
210
  [step].reverse.each do |j|
212
211
  next if j.done?
@@ -218,6 +217,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
218
217
  prog_rep << [rep]
219
218
  end
220
219
  end
220
+ prog_rep = [Log.color(step.status, step.status)] if prog_rep.empty?
221
221
  end
222
222
  end
223
223
  workflow, task, name = step_path.split("/")[-3..-1]
@@ -321,7 +321,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
321
321
  if tail && File.exist?(File.join(dir, 'std.err'))
322
322
  if exit_status && exit_status != 0
323
323
  puts Log.color(:magenta, "First error or exception found: ")
324
- puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
324
+ puts CMD.cmd("grep -i 'error\\|exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
325
325
  elsif exit_status
326
326
  puts Log.color(:magenta, "Completed jobs: ")
327
327
  puts CMD.cmd("grep -i -w 'Completed step' #{File.join(dir, 'std.err')} | grep -v 'Retrying dep.' | tail -n #{tail.to_i}", :no_fail => true).read
@@ -337,7 +337,6 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
337
337
  require 'rbbt/workflow'
338
338
  step_path = step_line.split(": ").last.strip
339
339
  step = Step.new step_path
340
- step.load_dependencies_from_info
341
340
  has_bar = false
342
341
  (step.rec_dependencies + [step]).reverse.each do |j|
343
342
  next if j.done?
@@ -18,9 +18,9 @@ $slurm_options = SOPT.get <<EOF
18
18
  -si--singularity_img* Singularity image to use
19
19
  -sm--singularity_mounts* Singularity image to use
20
20
  -ug--user_group* Use alternative user group for group project directory
21
- -c--contain* Contain in directory (using Singularity)
22
- -s--sync* Contain in directory and sync jobs
23
- -e--exclusive Make exclusive use of the node
21
+ --contain* Contain in directory (using Singularity)
22
+ --sync* Contain in directory and sync jobs
23
+ --exclusive Make exclusive use of the node
24
24
  -hm--highmem Make use of highmem cores
25
25
  -wc--wipe_container* Wipe the jobs from the contain directory
26
26
  -pd--purge_deps Purge job dependencies
@@ -57,7 +57,7 @@ raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint
57
57
 
58
58
  class Step
59
59
  def join
60
- HPC::BATCH_MODULE.wait_for_job(@batch_job_dir)
60
+ HPC::BATCH_MODULE.wait_for_job(@batch_job_dir) unless done?
61
61
  end
62
62
 
63
63
  def run(no_load = true)
@@ -33,6 +33,8 @@ raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint
33
33
 
34
34
  directory = ARGV.shift
35
35
 
36
+ directory = HPC::BATCH_MODULE.jobs.first if directory.nil?
37
+
36
38
  raise ParameterException if directory.nil?
37
39
 
38
40
  if directory =~ /^[0-9]*$/
@@ -9,7 +9,7 @@ require 'time'
9
9
 
10
10
  rbbt_options = SOPT::GOT_OPTIONS
11
11
 
12
- $slurm_options = SOPT.get <<EOF
12
+ $batch_options = SOPT.get <<EOF
13
13
  -dr--dry_run Print only the template
14
14
  -cj--clean_job Clean job
15
15
  --drbbt* Use development version of rbbt
@@ -17,9 +17,9 @@ $slurm_options = SOPT.get <<EOF
17
17
  -si--singularity_img* Singularity image to use
18
18
  -sm--singularity_mounts* Singularity image to use
19
19
  -ug--user_group* Use alternative user group for group project directory
20
- -c--contain* Contain in directory (using Singularity)
21
- -s--sync* Contain in directory and sync jobs
22
- -e--exclusive Make exclusive use of the node
20
+ --contain* Contain in directory (using Singularity)
21
+ --sync* Contain in directory and sync jobs
22
+ --exclusive Make exclusive use of the node
23
23
  -hm--highmem Make use of highmem cores
24
24
  -wc--wipe_container* Wipe the jobs from the contain directory
25
25
  -pd--purge_deps Purge job dependencies
@@ -45,11 +45,14 @@ $slurm_options = SOPT.get <<EOF
45
45
  -OR--orchestration_rules* Orchestration rules
46
46
  EOF
47
47
 
48
- batch_system = $slurm_options.delete :batch_system
48
+ batch_system = $batch_options.delete :batch_system
49
49
  batch_system ||= 'auto'
50
+ $batch_options[:log] = rbbt_options[:log]
51
+ $batch_options[:config_keys] = rbbt_options[:config_keys]
50
52
 
51
53
  HPC::BATCH_MODULE = HPC.batch_system batch_system
52
54
 
55
+
53
56
  raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint batch_system}") if HPC::BATCH_MODULE.nil?
54
57
 
55
58
  class Step
@@ -60,7 +63,7 @@ class Step
60
63
  else
61
64
  begin
62
65
  Log.debug "Issuing BATCH job for #{self.path}"
63
- HPC::BATCH_MODULE.run_job(self, $slurm_options)
66
+ HPC::BATCH_MODULE.run_job(self, $batch_options)
64
67
  rescue HPC::BATCH_DRY_RUN
65
68
  end
66
69
  end
@@ -70,7 +73,7 @@ end
70
73
  module RemoteStep::SSH
71
74
 
72
75
  def _run
73
- RemoteWorkflow::SSH.run_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $slurm_options)
76
+ RemoteWorkflow::SSH.run_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $batch_options)
74
77
  end
75
78
 
76
79
  end
@@ -54,5 +54,12 @@ end
54
54
 
55
55
  force = options[:force]
56
56
 
57
- puts resource[path].produce(force).find
57
+ file = resource[path].produce(force)
58
+
59
+ if file
60
+ puts file.find
61
+ else
62
+ puts Log.color("Error: Could not produce #{path} (#{resource})")
63
+ exit -1
64
+ end
58
65
 
@@ -206,7 +206,6 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
206
206
  require 'rbbt/workflow'
207
207
  step_path = step_line.split(": ").last.strip
208
208
  step = Step.new step_path
209
- step.load_dependencies_from_info
210
209
  has_bar = false
211
210
  [step].reverse.each do |j|
212
211
  next if j.done?
@@ -218,6 +217,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
218
217
  prog_rep << [rep]
219
218
  end
220
219
  end
220
+ prog_rep = [Log.color(step.status, step.status)] if prog_rep.empty?
221
221
  end
222
222
  end
223
223
  workflow, task, name = step_path.split("/")[-3..-1]
@@ -321,7 +321,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
321
321
  if tail && File.exist?(File.join(dir, 'std.err'))
322
322
  if exit_status && exit_status != 0
323
323
  puts Log.color(:magenta, "First error or exception found: ")
324
- puts CMD.cmd("grep -i -w 'error\\|[a-z]*exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
324
+ puts CMD.cmd("grep -i 'error\\|exception' #{File.join(dir, 'std.err')} -A #{tail.to_i} |head -n #{tail.to_i}", :no_fail => true).read
325
325
  elsif exit_status
326
326
  puts Log.color(:magenta, "Completed jobs: ")
327
327
  puts CMD.cmd("grep -i -w 'Completed step' #{File.join(dir, 'std.err')} | grep -v 'Retrying dep.' | tail -n #{tail.to_i}", :no_fail => true).read
@@ -337,7 +337,6 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
337
337
  require 'rbbt/workflow'
338
338
  step_path = step_line.split(": ").last.strip
339
339
  step = Step.new step_path
340
- step.load_dependencies_from_info
341
340
  has_bar = false
342
341
  (step.rec_dependencies + [step]).reverse.each do |j|
343
342
  next if j.done?
@@ -18,9 +18,9 @@ $slurm_options = SOPT.get <<EOF
18
18
  -si--singularity_img* Singularity image to use
19
19
  -sm--singularity_mounts* Singularity image to use
20
20
  -ug--user_group* Use alternative user group for group project directory
21
- -c--contain* Contain in directory (using Singularity)
22
- -s--sync* Contain in directory and sync jobs
23
- -e--exclusive Make exclusive use of the node
21
+ --contain* Contain in directory (using Singularity)
22
+ --sync* Contain in directory and sync jobs
23
+ --exclusive Make exclusive use of the node
24
24
  -hm--highmem Make use of highmem cores
25
25
  -wc--wipe_container* Wipe the jobs from the contain directory
26
26
  -pd--purge_deps Purge job dependencies
@@ -57,7 +57,7 @@ raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint
57
57
 
58
58
  class Step
59
59
  def join
60
- HPC::BATCH_MODULE.wait_for_job(@batch_job_dir)
60
+ HPC::BATCH_MODULE.wait_for_job(@batch_job_dir) unless done?
61
61
  end
62
62
 
63
63
  def run(no_load = true)
@@ -33,6 +33,8 @@ raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint
33
33
 
34
34
  directory = ARGV.shift
35
35
 
36
+ directory = HPC::BATCH_MODULE.jobs.first if directory.nil?
37
+
36
38
  raise ParameterException if directory.nil?
37
39
 
38
40
  if directory =~ /^[0-9]*$/
@@ -9,7 +9,7 @@ require 'time'
9
9
 
10
10
  rbbt_options = SOPT::GOT_OPTIONS
11
11
 
12
- $slurm_options = SOPT.get <<EOF
12
+ $batch_options = SOPT.get <<EOF
13
13
  -dr--dry_run Print only the template
14
14
  -cj--clean_job Clean job
15
15
  --drbbt* Use development version of rbbt
@@ -17,9 +17,9 @@ $slurm_options = SOPT.get <<EOF
17
17
  -si--singularity_img* Singularity image to use
18
18
  -sm--singularity_mounts* Singularity image to use
19
19
  -ug--user_group* Use alternative user group for group project directory
20
- -c--contain* Contain in directory (using Singularity)
21
- -s--sync* Contain in directory and sync jobs
22
- -e--exclusive Make exclusive use of the node
20
+ --contain* Contain in directory (using Singularity)
21
+ --sync* Contain in directory and sync jobs
22
+ --exclusive Make exclusive use of the node
23
23
  -hm--highmem Make use of highmem cores
24
24
  -wc--wipe_container* Wipe the jobs from the contain directory
25
25
  -pd--purge_deps Purge job dependencies
@@ -45,11 +45,14 @@ $slurm_options = SOPT.get <<EOF
45
45
  -OR--orchestration_rules* Orchestration rules
46
46
  EOF
47
47
 
48
- batch_system = $slurm_options.delete :batch_system
48
+ batch_system = $batch_options.delete :batch_system
49
49
  batch_system ||= 'auto'
50
+ $batch_options[:log] = rbbt_options[:log]
51
+ $batch_options[:config_keys] = rbbt_options[:config_keys]
50
52
 
51
53
  HPC::BATCH_MODULE = HPC.batch_system batch_system
52
54
 
55
+
53
56
  raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint batch_system}") if HPC::BATCH_MODULE.nil?
54
57
 
55
58
  class Step
@@ -60,7 +63,7 @@ class Step
60
63
  else
61
64
  begin
62
65
  Log.debug "Issuing BATCH job for #{self.path}"
63
- HPC::BATCH_MODULE.run_job(self, $slurm_options)
66
+ HPC::BATCH_MODULE.run_job(self, $batch_options)
64
67
  rescue HPC::BATCH_DRY_RUN
65
68
  end
66
69
  end
@@ -70,7 +73,7 @@ end
70
73
  module RemoteStep::SSH
71
74
 
72
75
  def _run
73
- RemoteWorkflow::SSH.run_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $slurm_options)
76
+ RemoteWorkflow::SSH.run_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $batch_options)
74
77
  end
75
78
 
76
79
  end
@@ -22,7 +22,7 @@ Specify workflow '.' and no task to examine the jobs of the current directory (u
22
22
  -d--dirty Clean dirty jobs
23
23
  -h--help Print this help
24
24
  EOF
25
- rbbt_usage and exit 0 if options[:help]
25
+ scout_usage and exit 0 if options[:help]
26
26
 
27
27
  workflow, task = ARGV
28
28
 
@@ -98,7 +98,7 @@ TSV.traverse jobs do |file,i|
98
98
  else
99
99
  info = begin
100
100
  Open.open(i[:info_file]) do |f|
101
- Step::INFO_SERIALIZER.load(f)
101
+ Step.load_info(f)
102
102
  end
103
103
  rescue
104
104
  {:status => :noinfo}
@@ -136,9 +136,9 @@ TSV.traverse jobs do |file,i|
136
136
  end
137
137
 
138
138
  if (force && status !~ /done/) or
139
- status =~ /\b(old|dirty|nopid|error|missing|aborted|dead|sync)$/ or
140
- (status == "noinfo" and not done) or
141
- status == ""
139
+ status =~ /\b(old|dirty|nopid|error|missing|aborted|dead|sync|waiting)$/ or
140
+ (status == "noinfo" and not done) or
141
+ status == ""
142
142
 
143
143
  puts " Removing #{ file } - #{status}"
144
144
  Step.clean(file)
@@ -74,7 +74,7 @@ end
74
74
  def input_msg(file, inputs)
75
75
 
76
76
  str = ""
77
- job_inputs = Workflow.load_step(file).recursive_inputs.to_hash
77
+ job_inputs = Step.new(file).recursive_inputs.to_hash
78
78
  IndiferentHash.setup(job_inputs)
79
79
 
80
80
  inputs.each do |input|
@@ -187,9 +187,10 @@ workflows.sort.each do |workflow,tasks|
187
187
  if info_fields and info_fields.any?
188
188
  info = begin
189
189
  Open.open(i[:info_file]) do |f|
190
- Step::INFO_SERIALIZER.load(f)
190
+ Step.load_info(f)
191
191
  end
192
192
  rescue
193
+ Log.exception $!
193
194
  {:status => :noinfo}
194
195
  end
195
196
  IndiferentHash.setup(info)
@@ -198,10 +199,9 @@ workflows.sort.each do |workflow,tasks|
198
199
  else
199
200
  info = begin
200
201
  Open.open(i[:info_file]) do |f|
201
- Step::INFO_SERIALIZER.load(f)
202
+ Step.load_info(f)
202
203
  end
203
204
  rescue
204
- #Log.exception $!
205
205
  {:status => :noinfo}
206
206
  end
207
207
  IndiferentHash.setup(info)
@@ -219,7 +219,7 @@ workflows.sort.each do |workflow,tasks|
219
219
  end
220
220
  end
221
221
  str << " #{ Step.prov_status_msg status }"
222
- str << " (dirty)" if status == 'done' && Workflow.load_step(file).dirty?
222
+ str << " (dirty)" if status == 'done' && Step.new(file).dirty?
223
223
 
224
224
  if inputs and inputs.any?
225
225
  str << input_msg(file, inputs)
@@ -78,11 +78,10 @@ if TSV === tsv
78
78
  exit
79
79
  end
80
80
 
81
- parser = TSV::Parser.new tsv, :key_field => key_field, :fields => fields, :type => options[:type], :header_hash => options[:header_hash], :sep => options[:sep]
81
+ parser = TSV::Parser.new tsv, **options
82
82
  fields ||= parser.fields
83
-
84
83
  i = 0
85
- TSV.traverse(parser) do |k,v|
84
+ TSV.traverse(parser, :key_field => key_field, :fields => fields, :type => options[:type]) do |k,v|
86
85
  if key== "#{i}"
87
86
  key = k.first
88
87
  elsif key.nil?
@@ -14,10 +14,7 @@ Display summary information. Works with Tokyocabinet HDB and BDB as well.
14
14
 
15
15
  -tch--tokyocabinet File is a TC HDB
16
16
  -tcb--tokyocabinet_bd File is a TC BDB
17
- -t--type* Type of tsv (single, list, double, flat)
18
17
  -hh--header_hash* Change the character used to mark the header line (defaults to #)
19
- -k--key_field* Change the key field
20
- -f--fields* Change the fields to load
21
18
  -fp--fingerprint Fingerprint values
22
19
  -s--sep* Change the fields separator (default TAB)
23
20
  -h--help Help
@@ -32,8 +29,8 @@ file = STDIN if file == '-'
32
29
  raise ParameterException, "Please specify the tsv file as argument" if file.nil?
33
30
 
34
31
  options[:fields] = options[:fields].split(/[,\|]/) if options[:fields]
35
- options[:header_hash] = options["header_hash"]
36
- options[:sep] = options["sep"]
32
+
33
+ options.keys_to_sym!
37
34
 
38
35
  case
39
36
  when options[:tokyocabinet]
@@ -43,16 +40,16 @@ when options[:tokyocabinet_bd]
43
40
  tsv = Persist.open_tokyocabinet(file, false, nil, TokyoCabinet::BDB)
44
41
  puts tsv.summary
45
42
  else
46
- header = TSV.parse_header(Open.open(file, :nocache => true), options)
43
+ options, key_field, fields, first_line = TSV.parse_header(Open.open(file, :nocache => true), **options)
47
44
 
48
45
  puts "File: #{ file }"
49
- puts "Type: #{header.type}"
50
- puts "Namespace: #{header.namespace}"
51
- puts "Key: #{Log.color :yellow, header.key_field}"
46
+ puts "Type: #{options[:type]}"
47
+ puts "Namespace: #{options[:namespace]}"
48
+ puts "Key: #{Log.color :yellow, key_field}"
52
49
  puts "Fields: "
53
- if header.fields.nil?
50
+ if fields.nil?
54
51
  else
55
- header.fields.each_with_index do |f,i|
52
+ fields.each_with_index do |f,i|
56
53
  puts " - #{Log.color :cyan, i + 1}: " << Log.color(:yellow, f)
57
54
  end
58
55
  end
@@ -71,9 +68,9 @@ else
71
68
 
72
69
  puts "Rows: #{Log.color :blue, rows}"
73
70
  parts = []
74
- header.first_line.split(header.sep, -1).each_with_index do |p,i|
71
+ first_line.split(options[:sep] || "\t", -1).each_with_index do |p,i|
75
72
  p.strip!
76
- p = Misc.fingerprint p.split("|") if %w(double flat).include?(header.options[:type].to_s) && options[:fingerprint]
73
+ p = Misc.fingerprint p.split("|") if %w(double flat).include?(options[:type].to_s) && options[:fingerprint]
77
74
  parts << (Log.color(:cyan, "(#{i}) ") << p.strip)
78
75
  end
79
76
  puts parts * "\t"
@@ -37,22 +37,26 @@ when options[:tokyocabinet_bd]
37
37
  exit
38
38
  end
39
39
 
40
- parser = TSV::Parser.new TSV.get_stream(file), options.merge(:fields => [])
40
+ parser = TSV::Parser.new TSV.get_stream(file)
41
41
 
42
42
  options[:merge] = false if options[:merge] == "false"
43
43
 
44
- line = parser.first_line
45
- bar = Log::ProgressBar.new
46
- while line
47
- bar.tick
48
-
49
- line = Misc.fixutf8(line)
50
- line = parser.process line
51
- raise SKIP_LINE if line.empty?
52
- parts = parser.chop_line line
53
- key, values = parser.get_values parts
54
- values = parser.cast_values values if parser.cast?
55
-
44
+ parser.traverse fields: [] do |key,v|
56
45
  puts key
57
- line = parser.stream.gets
58
46
  end
47
+
48
+ #line = parser.first_line
49
+ #bar = Log::ProgressBar.new
50
+ #while line
51
+ # bar.tick
52
+ #
53
+ # line = Misc.fixutf8(line)
54
+ # line = parser.traverse line
55
+ # raise SKIP_LINE if line.empty?
56
+ # parts = parser.chop_line line
57
+ # key, values = parser.get_values parts
58
+ # values = parser.cast_values values if parser.cast?
59
+ #
60
+ # puts key
61
+ # line = parser.stream.gets
62
+ #end
@@ -35,7 +35,7 @@ file = case file
35
35
  fields = options[:fields]
36
36
  raise ParameterException, "Please specify the fields to slice" if fields.nil?
37
37
 
38
- options[:header_hash] ||= options["header_hash"]
38
+ options.keys_to_sym!
39
39
 
40
40
  case
41
41
  when options[:tokyocabinet]
@@ -45,7 +45,7 @@ when options[:tokyocabinet_bd]
45
45
  tsv = Persist.open_tokyocabinet(file, false, nil, TokyoCabinet::BDB)
46
46
  puts tsv.summary
47
47
  else
48
- stream = TSV.traverse file, options.merge(:into => :stream, :type => :list, :fields => fields.split(","), :unnamed => true) do |k,fields,names|
48
+ stream = TSV.traverse file, **options.merge(:into => :stream, :type => :list, :fields => fields.split(","), :unnamed => true) do |k,fields,names|
49
49
  [k,fields].flatten * "\t"
50
50
  end
51
51
  puts stream.read
@@ -32,9 +32,13 @@ file = case file
32
32
  raise ParameterException, "Please specify the tsv file as argument" if file.nil?
33
33
  end
34
34
 
35
- field = options[:field]
36
35
 
37
- options[:header_hash] = options["header_hash"]
36
+ options[:header_hash] ||= options.delete "header_hash"
37
+ options.delete :header_hash if options[:header_hash].nil?
38
+
39
+ field = options.delete :field
40
+
41
+ options.keys_to_sym!
38
42
 
39
43
  case
40
44
  when options[:tokyocabinet]
@@ -77,8 +77,8 @@ if options[:original]
77
77
  exit 0
78
78
  end
79
79
 
80
+ inputs = step.inputs
80
81
  dependencies = info[:dependencies]
81
- inputs = info[:inputs]
82
82
  status = info[:status]
83
83
  time = info[:time_elapsed]
84
84
  total_time = info[:total_time_elapsed]
@@ -89,6 +89,7 @@ exception = info[:exception]
89
89
  rest = info.keys - [:inputs, :dependencies, :status, :time_elapsed, :messages, :backtrace, :exception, :archived_info]
90
90
 
91
91
 
92
+ status = :noinfo if status.nil?
92
93
  puts Log.color(:magenta, "File") << ": " << step.path
93
94
  puts Log.color(:magenta, "Status") << ": " << status_msg(status) << ((step.aborted? || step.error?) && step.recoverable_error? ? " (recoverable)" : "" ) << (step.dirty? ? " (dirty)" : "")
94
95
  puts Log.color(:magenta, "Pid") << ": " << pid_msg(pid, status.to_s == "done")
@@ -96,17 +97,19 @@ puts Log.color(:magenta, "Time") << ": " << time.to_i.to_s << " sec." if time
96
97
  puts Log.color(:magenta, "Total time") << ": " << total_time.to_i.to_s << " sec." if time
97
98
  if inputs and inputs.any?
98
99
  puts Log.color(:magenta, "Inputs")
99
- inputs.each do |input,value|
100
+ inputs.to_hash.each do |input,value|
100
101
  case value
101
102
  when nil
102
- puts Misc.format_definition_list_item(" " + input.to_s, 'nil', width, 20, :blue)
103
+ puts Misc.format_definition_list_item(" " + input.to_s, 'nil', 20, width, color: :blue)
103
104
  when Array
104
- puts Misc.format_definition_list_item(" " + input.to_s, (value.length > 6 ? value[0..5]*"\n" << "\n" << "..." : value * "\n" ), width, 20, :blue)
105
+ puts Misc.format_definition_list_item(" " + input.to_s, (value.length > 6 ? value[0..5]*"\n" << "\n" << "..." : value * "\n" ), 20, width, color: :blue)
105
106
  when TrueClass, FalseClass
106
- puts Misc.format_definition_list_item(" " + input.to_s, value.to_s, width, 20, :blue)
107
+ puts Misc.format_definition_list_item(" " + input.to_s, value.to_s, 20, width, color: :blue)
108
+ when Step
109
+ puts Misc.format_definition_list_item(" " << input.to_s, value.short_path, 20, width, color: :blue)
107
110
  else
108
111
  text = value.to_s.split("\n")[0..5].compact * "\n\n"
109
- puts Misc.format_definition_list_item(" " + input.to_s, text, width, 20, :blue)
112
+ puts Misc.format_definition_list_item(" " + input.to_s, text, 20, width, color: :blue)
110
113
  end
111
114
  end
112
115
  end
@@ -150,32 +153,25 @@ if all
150
153
  end
151
154
 
152
155
  if recursive
153
- inputs = step.info[:inputs] || {}
154
- deps = step.dependencies
155
-
156
- while deps.any? do
157
- dep = deps.shift
158
- inputs = {} if inputs.nil?
159
- inputs = inputs.merge(dep.info[:inputs] || {})
160
- deps = deps.concat dep.dependencies if dep.dependencies
161
- end
156
+ inputs = step.recursive_inputs
157
+ inputs = NamedArray.setup(inputs.values, inputs.keys)
162
158
 
163
- inputs = inputs.merge step.archived_inputs
159
+ inputs = inputs.concat step.archived_inputs
164
160
  if inputs.any?
165
161
  puts Log.color(:magenta, "Recursive inputs") << ": "
166
- inputs.each do |input,value|
162
+ inputs.to_hash.each do |input,value|
167
163
  case value
168
164
  when nil
169
- puts Misc.format_definition_list_item(" " << input.to_s, 'nil', width, 20, :blue)
165
+ puts Misc.format_definition_list_item(" " + input.to_s, 'nil', 20, width, color: :blue)
170
166
  when Array
171
- puts Misc.format_definition_list_item(" " << input.to_s, (value.length > 6 ? (value[0..5])*"\n\n" << "\n\n" << "..." : value * "\n\n" ), width, 20, :blue).gsub("\n\n","\n")
167
+ puts Misc.format_definition_list_item(" " + input.to_s, (value.length > 6 ? value[0..5]*"\n" << "\n" << "..." : value * "\n" ), 20, width, color: :blue)
172
168
  when TrueClass, FalseClass
173
- puts Misc.format_definition_list_item(" " << input.to_s, value.to_s, width, 20, :blue)
169
+ puts Misc.format_definition_list_item(" " + input.to_s, value.to_s, 20, width, color: :blue)
170
+ when Step
171
+ puts Misc.format_definition_list_item(" " << input.to_s, value.short_path, 20, width, color: :blue)
174
172
  else
175
- lines = value.to_s.split("\n").collect{|l| l.length >= width - 5 ? l[0..width - 5] + " ..." : l }
176
- text = lines[0..5].compact * "\n\n"
177
- text << "\n\n...\n\n" if lines.length > 6
178
- puts Misc.format_definition_list_item(" " << input.to_s, text, width, 20, :blue).gsub("\n\n","\n")
173
+ text = value.to_s.split("\n")[0..5].compact * "\n\n"
174
+ puts Misc.format_definition_list_item(" " + input.to_s, text, 20, width, color: :blue)
179
175
  end
180
176
  end
181
177
  end