scout-gear 2.0.0 → 5.2.0

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 (104) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +65 -2
  3. data/Rakefile +2 -0
  4. data/VERSION +1 -1
  5. data/bin/scout +233 -24
  6. data/lib/scout/cmd.rb +344 -0
  7. data/lib/scout/concurrent_stream.rb +259 -0
  8. data/lib/scout/exceptions.rb +15 -8
  9. data/lib/scout/indiferent_hash/options.rb +8 -26
  10. data/lib/scout/log/color.rb +2 -2
  11. data/lib/scout/log/fingerprint.rb +11 -1
  12. data/lib/scout/log/progress/report.rb +0 -1
  13. data/lib/scout/log/progress/util.rb +1 -1
  14. data/lib/scout/log/progress.rb +4 -4
  15. data/lib/scout/log.rb +10 -2
  16. data/lib/scout/meta_extension.rb +19 -3
  17. data/lib/scout/misc/digest.rb +56 -0
  18. data/lib/scout/misc/filesystem.rb +26 -0
  19. data/lib/scout/misc/format.rb +17 -6
  20. data/lib/scout/misc/insist.rb +56 -0
  21. data/lib/scout/misc/monitor.rb +23 -0
  22. data/lib/scout/misc.rb +5 -11
  23. data/lib/scout/open/lock.rb +61 -0
  24. data/lib/scout/open/remote.rb +120 -0
  25. data/lib/scout/open/stream.rb +373 -0
  26. data/lib/scout/open/util.rb +225 -0
  27. data/lib/scout/open.rb +169 -0
  28. data/lib/scout/path/find.rb +68 -21
  29. data/lib/scout/path/tmpfile.rb +8 -0
  30. data/lib/scout/path/util.rb +14 -1
  31. data/lib/scout/path.rb +6 -30
  32. data/lib/scout/persist/open.rb +17 -0
  33. data/lib/scout/persist/path.rb +15 -0
  34. data/lib/scout/persist/serialize.rb +151 -0
  35. data/lib/scout/persist.rb +54 -0
  36. data/lib/scout/resource/path.rb +20 -0
  37. data/lib/scout/resource/produce/rake.rb +69 -0
  38. data/lib/scout/resource/produce.rb +246 -0
  39. data/lib/scout/resource/scout.rb +3 -0
  40. data/lib/scout/resource/util.rb +48 -0
  41. data/lib/scout/resource.rb +39 -0
  42. data/lib/scout/simple_opt/accessor.rb +1 -1
  43. data/lib/scout/simple_opt/doc.rb +29 -23
  44. data/lib/scout/simple_opt/parse.rb +4 -3
  45. data/lib/scout/tmpfile.rb +39 -1
  46. data/lib/scout/workflow/definition.rb +78 -0
  47. data/lib/scout/workflow/documentation.rb +83 -0
  48. data/lib/scout/workflow/step/info.rb +77 -0
  49. data/lib/scout/workflow/step/load.rb +18 -0
  50. data/lib/scout/workflow/step.rb +132 -0
  51. data/lib/scout/workflow/task/inputs.rb +114 -0
  52. data/lib/scout/workflow/task.rb +155 -0
  53. data/lib/scout/workflow/usage.rb +314 -0
  54. data/lib/scout/workflow/util.rb +11 -0
  55. data/lib/scout/workflow.rb +40 -0
  56. data/lib/scout-gear.rb +4 -0
  57. data/lib/scout.rb +1 -0
  58. data/lib/workflow-scout.rb +2 -0
  59. data/scout-gear.gemspec +77 -5
  60. data/scout_commands/alias +48 -0
  61. data/scout_commands/find +83 -0
  62. data/scout_commands/glob +0 -0
  63. data/scout_commands/rbbt +23 -0
  64. data/scout_commands/workflow/info +29 -0
  65. data/scout_commands/workflow/list +27 -0
  66. data/scout_commands/workflow/task +58 -0
  67. data/scout_commands/workflow/task_old +706 -0
  68. data/test/scout/indiferent_hash/test_options.rb +11 -1
  69. data/test/scout/misc/test_digest.rb +30 -0
  70. data/test/scout/misc/test_filesystem.rb +30 -0
  71. data/test/scout/misc/test_insist.rb +13 -0
  72. data/test/scout/open/test_lock.rb +52 -0
  73. data/test/scout/open/test_remote.rb +25 -0
  74. data/test/scout/open/test_stream.rb +515 -0
  75. data/test/scout/open/test_util.rb +73 -0
  76. data/test/scout/path/test_find.rb +28 -0
  77. data/test/scout/persist/test_open.rb +37 -0
  78. data/test/scout/persist/test_path.rb +37 -0
  79. data/test/scout/persist/test_serialize.rb +114 -0
  80. data/test/scout/resource/test_path.rb +40 -0
  81. data/test/scout/resource/test_produce.rb +62 -0
  82. data/test/scout/resource/test_util.rb +27 -0
  83. data/test/scout/simple_opt/test_doc.rb +16 -0
  84. data/test/scout/test_cmd.rb +85 -0
  85. data/test/scout/test_concurrent_stream.rb +29 -0
  86. data/test/scout/test_meta_extension.rb +9 -0
  87. data/test/scout/test_misc.rb +0 -7
  88. data/test/scout/test_open.rb +146 -0
  89. data/test/scout/test_path.rb +3 -1
  90. data/test/scout/test_persist.rb +83 -0
  91. data/test/scout/test_resource.rb +26 -0
  92. data/test/scout/test_workflow.rb +87 -0
  93. data/test/scout/workflow/step/test_info.rb +30 -0
  94. data/test/scout/workflow/step/test_load.rb +65 -0
  95. data/test/scout/workflow/task/test_inputs.rb +182 -0
  96. data/test/scout/workflow/test_definition.rb +0 -0
  97. data/test/scout/workflow/test_documentation.rb +30 -0
  98. data/test/scout/workflow/test_step.rb +36 -0
  99. data/test/scout/workflow/test_task.rb +179 -0
  100. data/test/scout/workflow/test_usage.rb +35 -0
  101. data/test/scout/workflow/test_util.rb +17 -0
  102. data/test/test_helper.rb +17 -0
  103. data/test/test_scout-gear.rb +0 -0
  104. metadata +75 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7af276a76f116d6ba9dc7a995c55dbefd5d432a5df4d0b13b7335e1f8581a48c
4
- data.tar.gz: 2aae18d093c071a844ec2780fa79b5caabc0127c88938873d5e07e8eeeb21ce8
3
+ metadata.gz: c39189bc9fe8816a3c0494c78966486f28383e8e15bf38ab33fe4dcde6739f3c
4
+ data.tar.gz: 5f2753e6810a68be44589f9392de1eff2f8592dd2704b05a0ccdf866f07f6a1b
5
5
  SHA512:
6
- metadata.gz: 5d642aab0bcb89f0e0c06de0ae0fadb0295170c66faee5188bd2eb23ee4366e776ec9c3ddb675b4ab15394e45c493896a917d6e29f04bc024b08ed7829cf6263
7
- data.tar.gz: b2f370a8088d8abb4b4e7955da2c8616cf5af4b6bca88e8578442505ef1cfb9477927e5ccb6522208bdf1520a9b3fec46e53bbacfbee636a218fa1e33fd05330
6
+ metadata.gz: 820d17306f468e7b206672b717489f78eb6fbfa37c843441202ce124c54cb7b84b89062a951c14a2db65ada47faf073dbc6a1b863294388ce66a8c1f7dd36e9f
7
+ data.tar.gz: c0fe23608355128c0e709db78c5598c5ece26e885eaa8788872878b7d55e29fc50bcb8215d3b4080f9e8d89456630e2739b087ee7d8b4b57498b299df3dc89d2
data/.vimproject CHANGED
@@ -1,10 +1,24 @@
1
1
  scout-gear=/$PWD filter="*.rb *.yaml" {
2
2
  Rakefile
3
- bin=bin {
3
+ bin=bin filter="*"{
4
4
  scout
5
5
  }
6
+ scout_commands=scout_commands filter="*"{
7
+ rbbt
8
+ alias
9
+ find
10
+ glob
11
+ workflow=workflow{
12
+ task_old
13
+ task
14
+ list
15
+ info
16
+ }
17
+ }
6
18
  lib=lib {
7
19
  scout-gear.rb
20
+ workflow-scout.rb
21
+ scout.rb
8
22
  scout=scout{
9
23
  meta_extension.rb
10
24
  exceptions.rb
@@ -12,8 +26,11 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
12
26
  misc.rb
13
27
  misc=misc{
14
28
  format.rb
29
+ insist.rb
30
+ digest.rb
31
+ filesystem.rb
32
+ monitor.rb
15
33
  }
16
- tmpfile.rb
17
34
  indiferent_hash.rb
18
35
  indiferent_hash=indiferent_hash{
19
36
  case_insensitive.rb
@@ -30,6 +47,7 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
30
47
  util.rb
31
48
  }
32
49
  }
50
+ tmpfile.rb
33
51
  simple_opt.rb
34
52
  simple_opt=simple_opt{
35
53
  accessor.rb
@@ -42,6 +60,48 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
42
60
  path=path{
43
61
  find.rb
44
62
  util.rb
63
+ tmpfile.rb
64
+ }
65
+ concurrent_stream.rb
66
+ cmd.rb
67
+ open.rb
68
+ open=open{
69
+ lock.rb
70
+ stream.rb
71
+ remote.rb
72
+ util.rb
73
+ }
74
+ resource.rb
75
+ resource=resource{
76
+ produce.rb
77
+ produce=produce{
78
+ rake.rb
79
+ }
80
+ scout.rb
81
+ util.rb
82
+ path.rb
83
+ }
84
+ persist.rb
85
+ persist=persist{
86
+ serialize.rb
87
+ open.rb
88
+ path.rb
89
+ }
90
+ workflow.rb
91
+ workflow=workflow{
92
+ definition.rb
93
+ step.rb
94
+ step=step{
95
+ info.rb
96
+ load.rb
97
+ }
98
+ task.rb
99
+ task=task{
100
+ inputs.rb
101
+ }
102
+ documentation.rb
103
+ usage.rb
104
+ util.rb
45
105
  }
46
106
  }
47
107
  }
@@ -85,6 +145,8 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
85
145
  util=util{
86
146
  misc.rb
87
147
  misc=misc{
148
+ refactor.rb
149
+
88
150
  serialize.rb
89
151
  exceptions.rb
90
152
  concurrent_stream.rb
@@ -292,6 +354,7 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
292
354
 
293
355
  persist.rb
294
356
  persist=persist{
357
+ refactor.rb
295
358
  tsv.rb
296
359
  tsv=tsv{
297
360
  adapter.rb
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ ENV["BRANCH"] = 'main'
4
+
3
5
  require 'rubygems'
4
6
  require 'rake'
5
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 5.2.0
data/bin/scout CHANGED
@@ -1,28 +1,237 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative '../lib/scout-gear'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
-
7
- case
8
- when File.exist?(file = File.join(__dir__, '../modules/rbbt-util/bin/rbbt'))
9
- $LOAD_PATH.unshift(lib_dir = File.join(file, '../..', 'lib'))
10
- require_relative File.join(lib_dir,'rbbt-util')
11
- Path.add_path(:rbbt, File.expand_path(File.join(File.dirname(lib_dir), "/{TOPLEVEL}/{SUBPATH}")))
12
- Path.default_pkgdir = Rbbt
13
- load file
14
- when File.exist?(file = File.join(ENV["HOME"], 'git/scout-gear/modules/rbbt-util/bin/rbbt'))
15
- $LOAD_PATH.unshift(lib_dir = File.join(file, '../..', 'lib'))
16
- require_relative File.join(lib_dir,'rbbt-util')
17
- Path.add_path(:rbbt, File.expand_path(File.join(File.dirname(lib_dir), "/{TOPLEVEL}/{SUBPATH}")))
18
- Path.default_pkgdir = Rbbt
19
- load file
20
- when File.exist?(file = File.join(ENV["HOME"], 'git/rbbt-util/bin/rbbt'))
21
- $LOAD_PATH.unshift(lib_dir = File.join(file, '../..', 'lib'))
22
- require_relative File.join(lib_dir,'rbbt-util')
23
- Path.add_path(:rbbt, File.expand_path(File.join(File.dirname(lib_dir), "/{TOPLEVEL}/{SUBPATH}")))
24
- Path.default_pkgdir = Rbbt
25
- load file
3
+ $LOAD_PATH.unshift File.join(__dir__, '../lib')
4
+
5
+ require 'scout-gear'
6
+
7
+ class CmdStop < Exception
8
+ attr_accessor :exit_status
9
+ def initialize(exit_status = 0)
10
+ @exit_status = exit_status
11
+ end
12
+ end
13
+
14
+ # Add paths to scout repos under --dev to LOAD_PATHS
15
+ dev_dir = nil
16
+ if _i = ARGV.index("--dev")
17
+ dev_dir = ARGV[_i+1]
18
+ ARGV.delete "--dev"
19
+ ARGV.delete dev_dir
20
+ end
21
+
22
+ if dev_dir.nil?
23
+ _s = nil
24
+ ARGV.each_with_index do |s,i|
25
+ if s.match(/^--dev(?:=(.*))?/)
26
+ dev_dir = $1
27
+ _s = s
28
+ next
29
+ end
30
+ end
31
+ ARGV.delete _s if _s
32
+ end
33
+
34
+ if dev_dir
35
+ ['scout-*/lib'].each do |pattern|
36
+ Dir.glob(File.join(File.expand_path(dev_dir), pattern)).each do |f|
37
+ $LOAD_PATH.unshift f
38
+ end
39
+ end
40
+ end
41
+
42
+ Log.nocolor = true if ARGV.include? "--nocolor"
43
+
44
+ require 'scout/simple_opt'
45
+
46
+ options = SOPT.setup <<EOF
47
+ Ruby bioinformatics toolkit
48
+
49
+ $ #{$0} <command> <subcommand> ... -a --arg1 --arg2='value' --arg3 'another-value'
50
+
51
+
52
+ --log* #{Log.color :yellow, "Log level from 0 (debug) 6 (errors)"}
53
+ --dev* #{Log.color :yellow, "Find development libraries in the directory specified"}
54
+ --nocolor #{Log.color :yellow, "Disable colored output"}
55
+ --nobar #{Log.color :yellow, "Disable progress report"}
56
+ --locate_file #{Log.color :yellow, "Report the location of the script instead of executing it"}
57
+ EOF
58
+
59
+ Log.nocolor = true if options[:nocolor]
60
+
61
+ locate = options.delete :locate_file
62
+
63
+ if options[:log_file]
64
+ Log.logfile(options[:log_file])
65
+ end
66
+
67
+ if options[:log]
68
+ Log.severity = options[:log].to_i
26
69
  else
27
- raise "Cant find rbbt"
70
+ global_severity = Log.get_level(Scout.etc.log_severity.read.strip) if Scout.etc.log_severity.exists?
71
+ if ENV["SCOUT_LOG"]
72
+ Log.severity = ENV["SCOUT_LOG"].to_i
73
+ else
74
+ global_severity = Log.get_level(Scout.etc.log_severity.read.strip) if Scout.etc.log_severity.exists?
75
+ Log.severity = global_severity.to_i if global_severity
76
+ end
28
77
  end
78
+
79
+ $scout_command_dir = Scout.bin.scout
80
+ $scout_command_dir.path_maps[:scout_commands] = File.join(File.dirname(__dir__), "{PATH/bin\\/scout/scout_commands}")
81
+
82
+ SOPT.description =<<EOF
83
+ This command controls many aspects of the Scout framework, from configuration tasks to running applications.
84
+
85
+ Commands are implemented in separate files under the Scout path '#{$scout_command_dir}'.
86
+ Known locations are: #{([$scout_command_dir] + $scout_command_dir.find_all) * ", " }.
87
+ You can place your own commads at #{$scout_command_dir.find(:user)}.
88
+ EOF
89
+
90
+ if options[:profile]
91
+ require 'ruby-prof'
92
+ RubyProf.start
93
+ end
94
+
95
+
96
+ def prev_dir(prev)
97
+ scout_command_dir = $scout_command_dir
98
+
99
+ prev.each do |previous_command|
100
+ scout_command_dir = scout_command_dir[previous_command]
101
+ end
102
+
103
+ scout_command_dir
104
+ end
105
+
106
+ def commands(prev)
107
+ scout_command_dir = prev_dir(prev)
108
+
109
+ command_file_dirs = scout_command_dir.find_all
110
+ command_files = command_file_dirs.collect{|d| d.glob('*') }.flatten
111
+ command_files.collect{|p| File.basename(p) }.uniq.reject{|p| p =~ /\.desc$/}.sort
112
+ end
113
+
114
+ def scout_usage(prev = nil)
115
+ puts
116
+ puts SOPT.doc
117
+
118
+ if prev
119
+ puts
120
+ puts Log.color :magenta, "## COMMANDS"
121
+ puts
122
+ puts Log.color :magenta, "Command:"
123
+ puts
124
+ puts " #{File.basename($0)} #{prev * " "}"
125
+ puts
126
+ puts Log.color :magenta, "Subcommands:"
127
+ puts
128
+ prev_dir = prev_dir(prev)
129
+ commands(prev).each do |command|
130
+ directory = File.directory? prev_dir[command].find
131
+ if directory
132
+ puts " " << Log.color(:blue, command)
133
+ else
134
+ puts " " << command
135
+ end
136
+ end
137
+ end
138
+ puts
139
+ true
140
+ end
141
+
142
+ alias usage scout_usage
143
+
144
+ def print_error(error, backtrace = nil)
145
+ puts Log.color :magenta, "## ERROR"
146
+ puts
147
+ if backtrace
148
+ puts Log.color :red, "Backtrace: "
149
+ puts
150
+ puts Log.color_stack(backtrace.reverse) * "\n"
151
+ puts
152
+ end
153
+ puts Log.color :red, error
154
+ puts
155
+ end
156
+
157
+ def aliases
158
+ @aliases ||= Scout.etc.cmd_alias.exists? ? Scout.etc.cmd_alias.yaml : {}
159
+ end
160
+
161
+ def tokenize_cmd_params(str)
162
+ return str if Array === str
163
+ str.scan(/
164
+ (?:["']([^"']*?)["']) |
165
+ ([^"'\s]+)
166
+ /x).flatten.compact
167
+ end
168
+
169
+ def cmd_alias
170
+ while ARGV[0] && aliases.include?(ARGV[0])
171
+ ARGV.replace tokenize_cmd_params(aliases[ARGV[0]]) + ARGV[1..-1]
172
+ end
173
+ end
174
+
175
+ dir = $scout_command_dir
176
+ $previous_commands = []
177
+
178
+ cmd_alias
179
+
180
+ exit_status = 0
181
+ begin
182
+ while ARGV.any?
183
+ $command = ARGV.shift
184
+ case
185
+ when File.directory?(dir[$command].find)
186
+ $previous_commands << $command
187
+ dir = dir[$command]
188
+ when dir[$command].exists?
189
+ if locate
190
+ puts dir[$command].find
191
+ exit_status = 0
192
+ exit exit_status
193
+ else
194
+ load dir[$command].find
195
+ exit_status = 0
196
+ exit exit_status
197
+ end
198
+ when File.exist?($command)
199
+ load $command
200
+ exit_status = 0
201
+ exit exit_status
202
+ else
203
+ error = "Command '#{$command }' not understood"
204
+ scout_usage($previous_commands)
205
+ print_error(error)
206
+ exit_status = -1
207
+ exit exit_status
208
+ end
209
+ end
210
+
211
+ scout_usage($previous_commands)
212
+ exit_status = 0
213
+ exit exit_status
214
+
215
+ rescue ParameterException
216
+ puts
217
+ scout_usage
218
+ print_error($!.message, $!.backtrace)
219
+ puts
220
+ exit_status = -1
221
+ exit exit_status
222
+ rescue SystemExit,CmdStop
223
+ exit_status = $!.status
224
+ exit exit_status
225
+ rescue Exception
226
+ Log.exception $!
227
+ exit_status = -1
228
+ exit exit_status
229
+ ensure
230
+ if options[:profile]
231
+ result = RubyProf.stop
232
+ printer = RubyProf::FlatPrinter.new(result)
233
+ printer.print(STDOUT, :min_percent => 10)
234
+ end
235
+ end
236
+
237
+ exit exit_status