rbbt-util 5.32.12 → 5.32.17

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/annotations/util.rb +1 -0
  3. data/lib/rbbt/entity.rb +6 -1
  4. data/lib/rbbt/hpc/batch.rb +3 -2
  5. data/lib/rbbt/hpc/orchestrate.rb +1 -0
  6. data/lib/rbbt/hpc/slurm.rb +2 -0
  7. data/lib/rbbt/resource/path.rb +6 -6
  8. data/lib/rbbt/tsv.rb +5 -0
  9. data/lib/rbbt/tsv/manipulate.rb +2 -0
  10. data/lib/rbbt/tsv/parallel/traverse.rb +9 -12
  11. data/lib/rbbt/util/R.rb +2 -2
  12. data/lib/rbbt/util/log.rb +15 -4
  13. data/lib/rbbt/util/log/progress/util.rb +2 -1
  14. data/lib/rbbt/util/misc/inspect.rb +1 -1
  15. data/lib/rbbt/util/misc/omics.rb +2 -2
  16. data/lib/rbbt/util/misc/system.rb +2 -2
  17. data/lib/rbbt/util/open.rb +1 -0
  18. data/lib/rbbt/util/python.rb +63 -3
  19. data/lib/rbbt/workflow.rb +54 -2
  20. data/lib/rbbt/workflow/accessor.rb +15 -242
  21. data/lib/rbbt/workflow/definition.rb +2 -1
  22. data/lib/rbbt/workflow/dependencies.rb +195 -0
  23. data/lib/rbbt/workflow/step.rb +10 -158
  24. data/lib/rbbt/workflow/step/accessor.rb +1 -311
  25. data/lib/rbbt/workflow/step/dependencies.rb +43 -3
  26. data/lib/rbbt/workflow/step/info.rb +294 -0
  27. data/lib/rbbt/workflow/step/status.rb +146 -0
  28. data/lib/rbbt/workflow/usage.rb +4 -2
  29. data/lib/rbbt/workflow/util/data.rb +35 -0
  30. data/lib/rbbt/workflow/util/orchestrator.rb +1 -1
  31. data/lib/rbbt/workflow/util/provenance.rb +40 -9
  32. data/python/rbbt.py +7 -0
  33. data/share/install/software/lib/install_helpers +1 -1
  34. data/share/rbbt_commands/hpc/orchestrate +4 -1
  35. data/share/rbbt_commands/hpc/task +2 -0
  36. data/share/rbbt_commands/lsf/orchestrate +4 -1
  37. data/share/rbbt_commands/lsf/task +2 -0
  38. data/share/rbbt_commands/slurm/orchestrate +4 -1
  39. data/share/rbbt_commands/slurm/task +2 -0
  40. data/share/rbbt_commands/system/clean +1 -0
  41. data/share/rbbt_commands/workflow/prov +1 -1
  42. data/test/rbbt/util/test_python.rb +3 -2
  43. data/test/rbbt/workflow/util/test_data.rb +48 -0
  44. metadata +9 -2
@@ -67,11 +67,13 @@ end
67
67
 
68
68
  module Workflow
69
69
 
70
- def dep_tree(name)
70
+ def dep_tree(name, seen = [])
71
71
  @dep_tree ||= {}
72
72
  @dep_tree[name] ||= begin
73
73
  dep_tree = {}
74
74
  self.task_dependencies[name.to_sym].reverse.each do |dep|
75
+ next if seen.include? dep
76
+ seen << dep
75
77
  dep = dep.first if Array === dep && dep.length == 1
76
78
  dep = dep.dependency if DependencyBlock === dep
77
79
 
@@ -87,7 +89,7 @@ module Workflow
87
89
 
88
90
  key = [workflow, task]
89
91
 
90
- dep_tree[key] = workflow.dep_tree(task)
92
+ dep_tree[key] = workflow.dep_tree(task, seen)
91
93
  end if name && self.task_dependencies[name.to_sym]
92
94
  dep_tree
93
95
  end
@@ -0,0 +1,35 @@
1
+ require 'rbbt/workflow'
2
+ require 'rbbt/workflow/examples'
3
+
4
+ module Workflow
5
+ module Data
6
+ def data(directory)
7
+ @@data_directory = directory
8
+ end
9
+
10
+ def get_datadir(clean_name)
11
+ data_dir = File.join(@@data_directory, clean_name)
12
+ raise "Data dir not found #{data_dir}" unless File.directory?(data_dir)
13
+ if Path === @@data_directory
14
+ @@data_directory.annotate data_dir
15
+ else
16
+ Path.setup(data_dir)
17
+ end
18
+ end
19
+
20
+ def data_task(name, workflow, oname, *rest, &block)
21
+ dep_task(name, workflow, oname, *rest) do |jobname, options|
22
+ data_dir = self.get_datadir(jobname)
23
+ task_info = workflow.task_info(oname)
24
+ dir_options = Workflow.load_inputs(data_dir.options, task_info[:inputs], task_info[:input_types])
25
+ data_options = block.call data_dir, dir_options, task_info
26
+ if data_options.include?(:inputs)
27
+ data_options
28
+ else
29
+ {:inputs => data_options.merge(options)}
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ end
@@ -81,7 +81,7 @@ module Workflow
81
81
  def self.candidates(workload, rules)
82
82
  if rules.empty?
83
83
  candidates = workload.select{|k,v| v.empty? }.
84
- collect{|k,v| k}.
84
+ collect{|k,v| k }.
85
85
  reject{|k| k.done? }
86
86
  else
87
87
  candidates = workload. #select{|k,v| Orchestrator.job_rules(rules, k) }.
@@ -26,7 +26,7 @@ class Step
26
26
  Log.color(color, status.to_s)
27
27
  end
28
28
 
29
- def self.prov_report_msg(status, name, path, info = nil)
29
+ def self.prov_report_msg(status, name, path, info, input = nil)
30
30
  parts = path.sub(/\{.*/,'').split "/"
31
31
 
32
32
  parts.pop
@@ -43,10 +43,19 @@ class Step
43
43
  rescue Exception
44
44
  nil
45
45
  end
46
+
47
+ if input.nil? || input.empty?
48
+ input_str = nil
49
+ else
50
+ input = input.reject{|dep,name| (input & dep.dependencies.collect{|d| [d,name]}).any? }
51
+ input = input.reject{|dep,name| (input & dep.input_dependencies.collect{|d| [d,name]}).any? }
52
+ input_str = Log.color(:magenta, "-> ") + input.collect{|dep,name| Log.color(:yellow, dep.task_name.to_s) + ":" + Log.color(:yellow, name) }.uniq * " "
53
+ end
54
+
46
55
  str = if ! (Open.remote?(path) || Open.ssh?(path)) && (Open.exists?(path) && $main_mtime && path_mtime && ($main_mtime - path_mtime) < -2)
47
- prov_status_msg(status.to_s) << " " << [workflow, task, path].compact * " " << " (#{Log.color(:red, "Mtime out of sync") })"
56
+ prov_status_msg(status.to_s) << " " << [workflow, task, path, input_str].compact * " " << " (#{Log.color(:red, "Mtime out of sync") })"
48
57
  else
49
- prov_status_msg(status.to_s) << " " << [workflow, task, path].compact * " "
58
+ prov_status_msg(status.to_s) << " " << [workflow, task, path, input_str].compact * " "
50
59
  end
51
60
 
52
61
  if $inputs and $inputs.any?
@@ -74,7 +83,7 @@ class Step
74
83
  str << "\n"
75
84
  end
76
85
 
77
- def self.prov_report(step, offset = 0, task = nil, seen = [], expand_repeats = false)
86
+ def self.prov_report(step, offset = 0, task = nil, seen = [], expand_repeats = false, input = nil)
78
87
  info = step.info || {}
79
88
  info[:task_name] = task
80
89
  path = step.path
@@ -84,14 +93,33 @@ class Step
84
93
  status = :unsync if status == :done and not Open.exist?(path)
85
94
  status = :notfound if status == :noinfo and not Open.exist?(path)
86
95
 
87
- str = " " * offset
88
- str << prov_report_msg(status, name, path, info)
89
- step.dependencies.reverse.each do |dep|
96
+
97
+ this_step_msg = prov_report_msg(status, name, path, info, input)
98
+
99
+ input_dependencies = {}
100
+ step.dependencies.each do |dep|
101
+ if dep.input_dependencies.any?
102
+ dep.input_dependencies.each do |id|
103
+ input_name = dep.recursive_inputs.fields.zip(dep.recursive_inputs).select{|f,d|
104
+ d == id || (String === d && d.start_with?(id.files_dir)) || (Array === d && d.include?(id))
105
+ }.first.first
106
+ input_dependencies[id] ||= []
107
+ input_dependencies[id] << [dep, input_name]
108
+ end
109
+ end
110
+ end
111
+
112
+ str = ""
113
+ str = " " * offset + this_step_msg if ENV["RBBT_ORIGINAL_STACK"] == 'true'
114
+
115
+ step.dependencies.dup.tap{|l|
116
+ l.reverse! if ENV["RBBT_ORIGINAL_STACK"] == 'true'
117
+ }.each do |dep|
90
118
  path = dep.path
91
119
  new = ! seen.include?(path)
92
120
  if new
93
121
  seen << path
94
- str << prov_report(dep, offset + 1, task, seen, expand_repeats)
122
+ str << prov_report(dep, offset + 1, task, seen, expand_repeats, input_dependencies[dep])
95
123
  else
96
124
  if expand_repeats
97
125
  str << Log.color(Step.status_color(dep.status), Log.uncolor(prov_report(dep, offset+1, task)))
@@ -103,10 +131,13 @@ class Step
103
131
  status = :unsync if status == :done and not Open.exist?(path)
104
132
  status = :notfound if status == :noinfo and not Open.exist?(path)
105
133
 
106
- str << Log.color(Step.status_color(status), " " * (offset + 1) + Log.uncolor(prov_report_msg(status, name, path, info)))
134
+ str << Log.color(Step.status_color(status), " " * (offset + 1) + Log.uncolor(prov_report_msg(status, name, path, info, input_dependencies[dep])))
107
135
  end
108
136
  end
109
137
  end if step.dependencies
138
+
139
+ str += (" " * offset) + this_step_msg unless ENV["RBBT_ORIGINAL_STACK"] == 'true'
140
+
110
141
  str
111
142
  end
112
143
  end
data/python/rbbt.py ADDED
@@ -0,0 +1,7 @@
1
+ import warnings
2
+ import sys
3
+ import os
4
+ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
5
+
6
+ def rbbt():
7
+ print("Rbbt")
@@ -499,7 +499,7 @@ install_jar(){
499
499
  local url="$2"
500
500
 
501
501
  [ -d "$OPT_DIR/$name/" ] || mkdir -p "$OPT_DIR/$name/"
502
- wget "$url" -O "$OPT_DIR/jars/$name.jar" || wget "$url" -O "$OPT_DIR/jars/$name.jar" --no-check-certificate || (rm "$OPT_DIR/jars/$name.jar"; exit -1)
502
+ wget "$url" -O "$OPT_DIR/$name/$name.jar" || wget "$url" -O "$OPT_DIR/$name/$name.jar" --no-check-certificate || (rm "$OPT_DIR/$name/$name.jar"; exit -1)
503
503
  link "$OPT_DIR/$name/$name.jar" "$OPT_JAR_DIR/$name.jar"
504
504
  }
505
505
 
@@ -28,12 +28,15 @@ $slurm_options = SOPT.get <<EOF
28
28
  -t--task_cpus* Tasks
29
29
  -tm--time* Time
30
30
  -m--mem* SLURM minimum memory
31
+ --gres* SLURM Generic resources
31
32
  -mcpu--mem_per_cpu* SLURM minimum memory per CPU
32
33
  -lin--licenses* SLURM licenses
33
34
  -cons--constraint* SLURM constraint
34
35
  -W--workflows* Additional workflows
35
- -OR--orchestration_rules* Orchestration rules
36
36
  -rmb--remove_batch_basedir Remove the SLURM working directory (command, STDIN, exit status, ...)
37
+ -lmod--lua_modules* Lua Modules to load
38
+ -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
39
+ -OR--orchestration_rules* Orchestration rules
37
40
  EOF
38
41
 
39
42
  batch_system = $slurm_options.delete :batch_system
@@ -27,11 +27,13 @@ $slurm_options = SOPT.get <<EOF
27
27
  -t--task_cpus* Tasks
28
28
  -tm--time* Time
29
29
  -m--mem* SLURM minimum memory
30
+ --gres* SLURM Generic resources
30
31
  -mcpu--mem_per_cpu* SLURM minimum memory per CPU
31
32
  -lin--licenses* SLURM licenses
32
33
  -cons--constraint* SLURM constraint
33
34
  -W--workflows* Additional workflows
34
35
  -rmb--remove_batch_dir Remove the batch working directory (command, STDIN, exit status, ...)
36
+ -lmod--lua_modules* Lua Modules to load
35
37
  -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
36
38
  EOF
37
39
 
@@ -28,12 +28,15 @@ $slurm_options = SOPT.get <<EOF
28
28
  -t--task_cpus* Tasks
29
29
  -tm--time* Time
30
30
  -m--mem* SLURM minimum memory
31
+ --gres* SLURM Generic resources
31
32
  -mcpu--mem_per_cpu* SLURM minimum memory per CPU
32
33
  -lin--licenses* SLURM licenses
33
34
  -cons--constraint* SLURM constraint
34
35
  -W--workflows* Additional workflows
35
- -OR--orchestration_rules* Orchestration rules
36
36
  -rmb--remove_batch_basedir Remove the SLURM working directory (command, STDIN, exit status, ...)
37
+ -lmod--lua_modules* Lua Modules to load
38
+ -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
39
+ -OR--orchestration_rules* Orchestration rules
37
40
  EOF
38
41
 
39
42
  batch_system = $slurm_options.delete :batch_system
@@ -27,11 +27,13 @@ $slurm_options = SOPT.get <<EOF
27
27
  -t--task_cpus* Tasks
28
28
  -tm--time* Time
29
29
  -m--mem* SLURM minimum memory
30
+ --gres* SLURM Generic resources
30
31
  -mcpu--mem_per_cpu* SLURM minimum memory per CPU
31
32
  -lin--licenses* SLURM licenses
32
33
  -cons--constraint* SLURM constraint
33
34
  -W--workflows* Additional workflows
34
35
  -rmb--remove_batch_dir Remove the batch working directory (command, STDIN, exit status, ...)
36
+ -lmod--lua_modules* Lua Modules to load
35
37
  -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
36
38
  EOF
37
39
 
@@ -28,12 +28,15 @@ $slurm_options = SOPT.get <<EOF
28
28
  -t--task_cpus* Tasks
29
29
  -tm--time* Time
30
30
  -m--mem* SLURM minimum memory
31
+ --gres* SLURM Generic resources
31
32
  -mcpu--mem_per_cpu* SLURM minimum memory per CPU
32
33
  -lin--licenses* SLURM licenses
33
34
  -cons--constraint* SLURM constraint
34
35
  -W--workflows* Additional workflows
35
- -OR--orchestration_rules* Orchestration rules
36
36
  -rmb--remove_batch_basedir Remove the SLURM working directory (command, STDIN, exit status, ...)
37
+ -lmod--lua_modules* Lua Modules to load
38
+ -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
39
+ -OR--orchestration_rules* Orchestration rules
37
40
  EOF
38
41
 
39
42
  batch_system = $slurm_options.delete :batch_system
@@ -27,11 +27,13 @@ $slurm_options = SOPT.get <<EOF
27
27
  -t--task_cpus* Tasks
28
28
  -tm--time* Time
29
29
  -m--mem* SLURM minimum memory
30
+ --gres* SLURM Generic resources
30
31
  -mcpu--mem_per_cpu* SLURM minimum memory per CPU
31
32
  -lin--licenses* SLURM licenses
32
33
  -cons--constraint* SLURM constraint
33
34
  -W--workflows* Additional workflows
34
35
  -rmb--remove_batch_dir Remove the batch working directory (command, STDIN, exit status, ...)
36
+ -lmod--lua_modules* Lua Modules to load
35
37
  -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
36
38
  EOF
37
39
 
@@ -34,6 +34,7 @@ force = options.delete :force
34
34
  dirty = options.delete :dirty
35
35
  time = options.delete :older
36
36
 
37
+ ENV["RBBT_DEBUG_CLEAN"] = 'false'
37
38
  ENV["RBBT_UPDATE"] = 'true' if dirty
38
39
 
39
40
  time = Misc.timespan time, 'd' if time
@@ -131,6 +131,6 @@ if options[:plot]
131
131
  end
132
132
 
133
133
  else
134
- puts Step.prov_report(step, 0, nil, [], options[:expand_repeats]).strip
134
+ puts Step.prov_report(step, 0, nil, [], options[:expand_repeats])
135
135
  end
136
136
 
@@ -2,6 +2,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helpe
2
2
  require 'rbbt/util/python'
3
3
 
4
4
  class TestPython < Test::Unit::TestCase
5
+
5
6
  def test_python
6
7
  TmpFile.with_file do |tmpdir|
7
8
  code =<<-EOF
@@ -67,7 +68,7 @@ def python_print():
67
68
 
68
69
  def test_keras
69
70
  defined = RbbtPython.run do
70
- pyimport "keras.models", as: :km
71
+ pyimport "tensorflow.keras.models", as: :km
71
72
  defined?(km.Sequential)
72
73
  end
73
74
  assert defined
@@ -75,7 +76,7 @@ def python_print():
75
76
 
76
77
  def test_keras_import
77
78
  defined = RbbtPython.run do
78
- pyfrom "keras.models", import: :Sequential
79
+ pyfrom "tensorflow.keras.models", import: :Sequential
79
80
  defined?(self::Sequential)
80
81
  end
81
82
  assert defined
@@ -0,0 +1,48 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
2
+ require 'rbbt/workflow/util/data'
3
+
4
+ module TestDataWF
5
+ extend Workflow
6
+ extend Workflow::Data
7
+
8
+ input :salutation, :string
9
+ task :salute_luis => :string do |name,salutation|
10
+ "Hi Luis: #{salutation}"
11
+ end
12
+
13
+ input :name, :string
14
+ input :salutation, :string
15
+ task :salute => :string do |name,salutation|
16
+ "Hi #{name}: #{salutation}"
17
+ end
18
+
19
+ data_task :salute_data, TestDataWF, :salute, :salutation => :placeholder do |directory,options|
20
+ options.merge({:salutation => directory.salutation.read})
21
+ end
22
+
23
+ data_task :salute_data2, TestDataWF, :salute, :salutation => :placeholder do |directory,options|
24
+ {:task => :salute_luis, :inputs => options.merge({:salutation => directory.salutation.read})}
25
+ end
26
+ end
27
+
28
+ class TestWorkflowData < Test::Unit::TestCase
29
+ def test_workflow_data
30
+ TmpFile.with_file do |tmpdir|
31
+ tmpdir = Path.setup(tmpdir.dup)
32
+
33
+ Open.write(tmpdir.TestDir.options.name, "Miguel")
34
+ Open.write(tmpdir.TestDir.salutation, "My salutations")
35
+
36
+ TestDataWF.data tmpdir
37
+
38
+ job = TestDataWF.job(:salute_data, "TestDir")
39
+ job.recursive_clean.run
40
+ assert job.run.include? "Miguel"
41
+
42
+ job = TestDataWF.job(:salute_data2, "TestDir")
43
+ job.recursive_clean.run
44
+ assert job.run.include? "Luis"
45
+ end
46
+ end
47
+ end
48
+
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.32.12
4
+ version: 5.32.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-25 00:00:00.000000000 Z
11
+ date: 2021-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -322,6 +322,7 @@ files:
322
322
  - lib/rbbt/workflow/accessor.rb
323
323
  - lib/rbbt/workflow/annotate.rb
324
324
  - lib/rbbt/workflow/definition.rb
325
+ - lib/rbbt/workflow/dependencies.rb
325
326
  - lib/rbbt/workflow/doc.rb
326
327
  - lib/rbbt/workflow/examples.rb
327
328
  - lib/rbbt/workflow/integration/ansible.rb
@@ -339,14 +340,18 @@ files:
339
340
  - lib/rbbt/workflow/step.rb
340
341
  - lib/rbbt/workflow/step/accessor.rb
341
342
  - lib/rbbt/workflow/step/dependencies.rb
343
+ - lib/rbbt/workflow/step/info.rb
342
344
  - lib/rbbt/workflow/step/prepare.rb
343
345
  - lib/rbbt/workflow/step/run.rb
346
+ - lib/rbbt/workflow/step/status.rb
344
347
  - lib/rbbt/workflow/task.rb
345
348
  - lib/rbbt/workflow/usage.rb
346
349
  - lib/rbbt/workflow/util/archive.rb
350
+ - lib/rbbt/workflow/util/data.rb
347
351
  - lib/rbbt/workflow/util/orchestrator.rb
348
352
  - lib/rbbt/workflow/util/provenance.rb
349
353
  - lib/rbbt/workflow/util/trace.rb
354
+ - python/rbbt.py
350
355
  - share/Rlib/plot.R
351
356
  - share/Rlib/svg.R
352
357
  - share/Rlib/util.R
@@ -549,6 +554,7 @@ files:
549
554
  - test/rbbt/workflow/test_step.rb
550
555
  - test/rbbt/workflow/test_task.rb
551
556
  - test/rbbt/workflow/util/test_archive.rb
557
+ - test/rbbt/workflow/util/test_data.rb
552
558
  - test/rbbt/workflow/util/test_orchestrator.rb
553
559
  - test/test_helper.rb
554
560
  homepage: http://github.com/mikisvaz/rbbt-util
@@ -579,6 +585,7 @@ test_files:
579
585
  - test/rbbt/workflow/test_remote_workflow.rb
580
586
  - test/rbbt/workflow/util/test_archive.rb
581
587
  - test/rbbt/workflow/util/test_orchestrator.rb
588
+ - test/rbbt/workflow/util/test_data.rb
582
589
  - test/rbbt/workflow/test_doc.rb
583
590
  - test/rbbt/workflow/test_schedule.rb
584
591
  - test/rbbt/workflow/test_step.rb