scout-gear 2.0.0 → 5.1.1

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