scout-gear 2.0.0 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.vimproject +59 -2
- data/VERSION +1 -1
- data/bin/scout +231 -24
- data/lib/scout/cmd.rb +344 -0
- data/lib/scout/concurrent_stream.rb +259 -0
- data/lib/scout/exceptions.rb +15 -8
- data/lib/scout/indiferent_hash/options.rb +8 -26
- data/lib/scout/log/color.rb +2 -2
- data/lib/scout/log/fingerprint.rb +11 -1
- data/lib/scout/log/progress/report.rb +0 -1
- data/lib/scout/log/progress/util.rb +1 -1
- data/lib/scout/log/progress.rb +4 -4
- data/lib/scout/log.rb +10 -2
- data/lib/scout/meta_extension.rb +15 -1
- data/lib/scout/misc/digest.rb +56 -0
- data/lib/scout/misc/filesystem.rb +26 -0
- data/lib/scout/misc/format.rb +1 -2
- data/lib/scout/misc/insist.rb +56 -0
- data/lib/scout/misc.rb +4 -11
- data/lib/scout/open/lock.rb +61 -0
- data/lib/scout/open/remote.rb +120 -0
- data/lib/scout/open/stream.rb +372 -0
- data/lib/scout/open/util.rb +225 -0
- data/lib/scout/open.rb +169 -0
- data/lib/scout/path/find.rb +67 -21
- data/lib/scout/path/tmpfile.rb +8 -0
- data/lib/scout/path/util.rb +14 -1
- data/lib/scout/path.rb +6 -30
- data/lib/scout/persist/open.rb +17 -0
- data/lib/scout/persist/path.rb +15 -0
- data/lib/scout/persist/serialize.rb +140 -0
- data/lib/scout/persist.rb +54 -0
- data/lib/scout/resource/path.rb +15 -0
- data/lib/scout/resource/produce/rake.rb +69 -0
- data/lib/scout/resource/produce.rb +246 -0
- data/lib/scout/resource/scout.rb +3 -0
- data/lib/scout/resource.rb +37 -0
- data/lib/scout/simple_opt/accessor.rb +1 -1
- data/lib/scout/simple_opt/doc.rb +4 -22
- data/lib/scout/simple_opt/parse.rb +4 -3
- data/lib/scout/tmpfile.rb +39 -1
- data/lib/scout/workflow/definition.rb +72 -0
- data/lib/scout/workflow/documentation.rb +77 -0
- data/lib/scout/workflow/step/info.rb +77 -0
- data/lib/scout/workflow/step.rb +96 -0
- data/lib/scout/workflow/task/inputs.rb +112 -0
- data/lib/scout/workflow/task.rb +141 -0
- data/lib/scout/workflow/usage.rb +294 -0
- data/lib/scout/workflow/util.rb +11 -0
- data/lib/scout/workflow.rb +39 -0
- data/lib/scout-gear.rb +4 -0
- data/lib/scout.rb +1 -0
- data/lib/workflow-scout.rb +2 -0
- data/scout-gear.gemspec +66 -5
- data/scout_commands/alias +48 -0
- data/scout_commands/find +83 -0
- data/scout_commands/glob +0 -0
- data/scout_commands/rbbt +23 -0
- data/scout_commands/workflow/task +707 -0
- data/test/scout/indiferent_hash/test_options.rb +11 -1
- data/test/scout/misc/test_digest.rb +30 -0
- data/test/scout/misc/test_filesystem.rb +30 -0
- data/test/scout/misc/test_insist.rb +13 -0
- data/test/scout/open/test_lock.rb +52 -0
- data/test/scout/open/test_remote.rb +25 -0
- data/test/scout/open/test_stream.rb +515 -0
- data/test/scout/open/test_util.rb +73 -0
- data/test/scout/path/test_find.rb +28 -0
- data/test/scout/persist/test_open.rb +37 -0
- data/test/scout/persist/test_path.rb +37 -0
- data/test/scout/persist/test_serialize.rb +114 -0
- data/test/scout/resource/test_path.rb +40 -0
- data/test/scout/resource/test_produce.rb +62 -0
- data/test/scout/test_cmd.rb +85 -0
- data/test/scout/test_concurrent_stream.rb +29 -0
- data/test/scout/test_misc.rb +0 -7
- data/test/scout/test_open.rb +146 -0
- data/test/scout/test_path.rb +3 -1
- data/test/scout/test_persist.rb +83 -0
- data/test/scout/test_resource.rb +26 -0
- data/test/scout/test_workflow.rb +87 -0
- data/test/scout/workflow/step/test_info.rb +28 -0
- data/test/scout/workflow/task/test_inputs.rb +182 -0
- data/test/scout/workflow/test_step.rb +36 -0
- data/test/scout/workflow/test_task.rb +178 -0
- data/test/scout/workflow/test_usage.rb +26 -0
- data/test/scout/workflow/test_util.rb +17 -0
- data/test/test_helper.rb +17 -0
- data/test/test_scout-gear.rb +0 -0
- metadata +64 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '070801d66b058318a5be03704b424158222038331dac4d7984fab415ca1680ee'
|
4
|
+
data.tar.gz: e58bcd314c0fa55acb722d12f8e77e69ade25f182501823db9a14691eaf3a887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
1
|
+
5.1.1
|
data/bin/scout
CHANGED
@@ -1,28 +1,235 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
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
|