rbbt-util 5.44.1 → 6.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rbbt +67 -90
  3. data/etc/app.d/base.rb +2 -2
  4. data/etc/app.d/semaphores.rb +3 -3
  5. data/lib/rbbt/annotations/annotated_array.rb +207 -207
  6. data/lib/rbbt/annotations/refactor.rb +27 -0
  7. data/lib/rbbt/annotations/util.rb +282 -282
  8. data/lib/rbbt/annotations.rb +343 -320
  9. data/lib/rbbt/association/database.rb +200 -225
  10. data/lib/rbbt/association/index.rb +294 -291
  11. data/lib/rbbt/association/item.rb +227 -227
  12. data/lib/rbbt/association/open.rb +35 -34
  13. data/lib/rbbt/association/util.rb +0 -169
  14. data/lib/rbbt/association.rb +2 -4
  15. data/lib/rbbt/entity/identifiers.rb +119 -118
  16. data/lib/rbbt/entity/refactor.rb +12 -0
  17. data/lib/rbbt/entity.rb +319 -315
  18. data/lib/rbbt/hpc/batch.rb +72 -53
  19. data/lib/rbbt/hpc/lsf.rb +2 -2
  20. data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
  21. data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
  22. data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
  23. data/lib/rbbt/hpc/orchestrate.rb +19 -13
  24. data/lib/rbbt/hpc/slurm.rb +18 -18
  25. data/lib/rbbt/knowledge_base/entity.rb +13 -5
  26. data/lib/rbbt/knowledge_base/query.rb +2 -2
  27. data/lib/rbbt/knowledge_base/registry.rb +32 -31
  28. data/lib/rbbt/knowledge_base/traverse.rb +1 -1
  29. data/lib/rbbt/knowledge_base.rb +1 -1
  30. data/lib/rbbt/monitor.rb +36 -25
  31. data/lib/rbbt/persist/refactor.rb +166 -0
  32. data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
  33. data/lib/rbbt/persist/tsv.rb +187 -185
  34. data/lib/rbbt/persist.rb +556 -551
  35. data/lib/rbbt/refactor.rb +20 -0
  36. data/lib/rbbt/resource/path/refactor.rb +178 -0
  37. data/lib/rbbt/resource/path.rb +317 -497
  38. data/lib/rbbt/resource/util.rb +0 -48
  39. data/lib/rbbt/resource.rb +3 -390
  40. data/lib/rbbt/tsv/accessor.rb +2 -838
  41. data/lib/rbbt/tsv/attach.rb +303 -299
  42. data/lib/rbbt/tsv/change_id.rb +244 -245
  43. data/lib/rbbt/tsv/csv.rb +87 -85
  44. data/lib/rbbt/tsv/dumper.rb +2 -100
  45. data/lib/rbbt/tsv/excel.rb +26 -24
  46. data/lib/rbbt/tsv/field_index.rb +4 -1
  47. data/lib/rbbt/tsv/filter.rb +3 -2
  48. data/lib/rbbt/tsv/index.rb +2 -284
  49. data/lib/rbbt/tsv/manipulate.rb +750 -747
  50. data/lib/rbbt/tsv/marshal.rb +3 -3
  51. data/lib/rbbt/tsv/matrix.rb +2 -2
  52. data/lib/rbbt/tsv/parallel/through.rb +2 -1
  53. data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
  54. data/lib/rbbt/tsv/parser.rb +678 -678
  55. data/lib/rbbt/tsv/refactor.rb +195 -0
  56. data/lib/rbbt/tsv/stream.rb +253 -251
  57. data/lib/rbbt/tsv/util.rb +420 -420
  58. data/lib/rbbt/tsv.rb +210 -208
  59. data/lib/rbbt/util/R/eval.rb +4 -4
  60. data/lib/rbbt/util/R/plot.rb +62 -166
  61. data/lib/rbbt/util/R.rb +21 -18
  62. data/lib/rbbt/util/cmd.rb +2 -318
  63. data/lib/rbbt/util/color.rb +269 -269
  64. data/lib/rbbt/util/colorize.rb +89 -89
  65. data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
  66. data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
  67. data/lib/rbbt/util/concurrency/processes.rb +389 -386
  68. data/lib/rbbt/util/config.rb +169 -167
  69. data/lib/rbbt/util/iruby.rb +20 -0
  70. data/lib/rbbt/util/log/progress/report.rb +241 -241
  71. data/lib/rbbt/util/log/progress/util.rb +99 -99
  72. data/lib/rbbt/util/log/progress.rb +102 -102
  73. data/lib/rbbt/util/log/refactor.rb +49 -0
  74. data/lib/rbbt/util/log.rb +486 -532
  75. data/lib/rbbt/util/migrate.rb +1 -1
  76. data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
  77. data/lib/rbbt/util/misc/development.rb +12 -11
  78. data/lib/rbbt/util/misc/exceptions.rb +117 -112
  79. data/lib/rbbt/util/misc/format.rb +2 -230
  80. data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
  81. data/lib/rbbt/util/misc/inspect.rb +2 -476
  82. data/lib/rbbt/util/misc/lock.rb +109 -106
  83. data/lib/rbbt/util/misc/omics.rb +9 -1
  84. data/lib/rbbt/util/misc/pipes.rb +765 -793
  85. data/lib/rbbt/util/misc/refactor.rb +20 -0
  86. data/lib/rbbt/util/misc/ssw.rb +27 -17
  87. data/lib/rbbt/util/misc/system.rb +0 -15
  88. data/lib/rbbt/util/misc.rb +39 -20
  89. data/lib/rbbt/util/named_array/refactor.rb +4 -0
  90. data/lib/rbbt/util/named_array.rb +3 -220
  91. data/lib/rbbt/util/open/refactor.rb +7 -0
  92. data/lib/rbbt/util/open.rb +3 -857
  93. data/lib/rbbt/util/procpath.rb +6 -6
  94. data/lib/rbbt/util/python/paths.rb +27 -0
  95. data/lib/rbbt/util/python/run.rb +115 -0
  96. data/lib/rbbt/util/python/script.rb +110 -0
  97. data/lib/rbbt/util/python/util.rb +3 -3
  98. data/lib/rbbt/util/python.rb +22 -81
  99. data/lib/rbbt/util/semaphore.rb +152 -148
  100. data/lib/rbbt/util/simpleopt.rb +9 -8
  101. data/lib/rbbt/util/ssh/refactor.rb +19 -0
  102. data/lib/rbbt/util/ssh.rb +122 -118
  103. data/lib/rbbt/util/tar.rb +117 -115
  104. data/lib/rbbt/util/tmpfile.rb +69 -67
  105. data/lib/rbbt/util/version.rb +2 -0
  106. data/lib/rbbt/workflow/refactor/entity.rb +11 -0
  107. data/lib/rbbt/workflow/refactor/export.rb +66 -0
  108. data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
  109. data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
  110. data/lib/rbbt/workflow/refactor/task_info.rb +65 -0
  111. data/lib/rbbt/workflow/refactor.rb +153 -0
  112. data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
  113. data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
  114. data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
  115. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
  116. data/lib/rbbt/workflow/remote_workflow.rb +6 -1
  117. data/lib/rbbt/workflow/step/run.rb +766 -766
  118. data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
  119. data/lib/rbbt/workflow/step.rb +2 -362
  120. data/lib/rbbt/workflow/task.rb +118 -118
  121. data/lib/rbbt/workflow/usage.rb +289 -287
  122. data/lib/rbbt/workflow/util/archive.rb +6 -5
  123. data/lib/rbbt/workflow/util/data.rb +1 -1
  124. data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
  125. data/lib/rbbt/workflow/util/trace.rb +79 -44
  126. data/lib/rbbt/workflow.rb +4 -882
  127. data/lib/rbbt-util.rb +21 -13
  128. data/lib/rbbt.rb +16 -3
  129. data/python/rbbt/__init__.py +19 -1
  130. data/share/Rlib/plot.R +37 -37
  131. data/share/Rlib/svg.R +22 -5
  132. data/share/install/software/lib/install_helpers +1 -1
  133. data/share/rbbt_commands/hpc/list +2 -3
  134. data/share/rbbt_commands/hpc/orchestrate +4 -4
  135. data/share/rbbt_commands/hpc/tail +2 -0
  136. data/share/rbbt_commands/hpc/task +10 -7
  137. data/share/rbbt_commands/lsf/list +2 -3
  138. data/share/rbbt_commands/lsf/orchestrate +4 -4
  139. data/share/rbbt_commands/lsf/tail +2 -0
  140. data/share/rbbt_commands/lsf/task +10 -7
  141. data/share/rbbt_commands/migrate +1 -1
  142. data/share/rbbt_commands/pbs/list +2 -3
  143. data/share/rbbt_commands/pbs/orchestrate +4 -4
  144. data/share/rbbt_commands/pbs/tail +2 -0
  145. data/share/rbbt_commands/pbs/task +10 -7
  146. data/share/rbbt_commands/resource/produce +8 -1
  147. data/share/rbbt_commands/slurm/list +2 -3
  148. data/share/rbbt_commands/slurm/orchestrate +4 -4
  149. data/share/rbbt_commands/slurm/tail +2 -0
  150. data/share/rbbt_commands/slurm/task +10 -7
  151. data/share/rbbt_commands/system/clean +5 -5
  152. data/share/rbbt_commands/system/status +5 -5
  153. data/share/rbbt_commands/tsv/get +2 -3
  154. data/share/rbbt_commands/tsv/info +10 -13
  155. data/share/rbbt_commands/tsv/keys +18 -14
  156. data/share/rbbt_commands/tsv/slice +2 -2
  157. data/share/rbbt_commands/tsv/transpose +6 -2
  158. data/share/rbbt_commands/workflow/info +20 -24
  159. data/share/rbbt_commands/workflow/list +1 -1
  160. data/share/rbbt_commands/workflow/prov +20 -13
  161. data/share/rbbt_commands/workflow/server +11 -1
  162. data/share/rbbt_commands/workflow/task +76 -71
  163. data/share/rbbt_commands/workflow/write_info +26 -9
  164. data/share/software/opt/ssw/ssw.c +861 -0
  165. data/share/software/opt/ssw/ssw.h +130 -0
  166. data/share/workflow_config.ru +3 -3
  167. metadata +40 -2
@@ -66,7 +66,7 @@ puts resource[path].find(search_path)
66
66
  target += "/" unless target.end_with? '/'
67
67
  end
68
68
 
69
- next if source_path == target
69
+ next if source_path == target && ! (options[:source] || options[:target])
70
70
 
71
71
  if options[:target]
72
72
  CMD.cmd("ssh #{options[:target]} mkdir -p '#{File.dirname(target)}'")
@@ -1,246 +1,248 @@
1
- module AbortedStream
2
- attr_accessor :exception
3
- def self.setup(obj, exception = nil)
4
- obj.extend AbortedStream
5
- obj.exception = exception
6
- end
7
- end
8
-
9
- module ConcurrentStream
10
- attr_accessor :threads, :pids, :callback, :abort_callback, :filename, :joined, :aborted, :autojoin, :lockfile, :no_fail, :pair, :thread, :stream_exception, :log, :std_err
11
-
12
- def self.setup(stream, options = {}, &block)
13
-
14
- threads, pids, callback, abort_callback, filename, autojoin, lockfile, no_fail, pair = Misc.process_options options, :threads, :pids, :callback, :abort_callback, :filename, :autojoin, :lockfile, :no_fail, :pair
15
- stream.extend ConcurrentStream unless ConcurrentStream === stream
16
-
17
- stream.threads ||= []
18
- stream.pids ||= []
19
- stream.threads.concat(Array === threads ? threads : [threads]) unless threads.nil?
20
- stream.pids.concat(Array === pids ? pids : [pids]) unless pids.nil? or pids.empty?
21
- stream.autojoin = autojoin unless autojoin.nil?
22
- stream.no_fail = no_fail unless no_fail.nil?
23
- stream.std_err = ""
24
-
25
- stream.pair = pair unless pair.nil?
26
-
27
- callback = block if block_given?
28
- if callback
29
- if stream.callback
30
- old_callback = stream.callback
31
- stream.callback = Proc.new do
32
- old_callback.call
33
- callback.call
34
- end
35
- else
36
- stream.callback = callback
37
- end
38
- end
39
-
40
- if abort_callback
41
- if stream.abort_callback
42
- old_abort_callback = stream.abort_callback
43
- stream.abort_callback = Proc.new do
44
- old_abort_callback.call
45
- abort_callback.call
46
- end
47
- else
48
- stream.abort_callback = abort_callback
49
- end
50
- end
51
-
52
- stream.filename = filename unless filename.nil?
53
-
54
- stream.lockfile = lockfile unless lockfile.nil?
55
-
56
- stream.aborted = false
57
-
58
- stream
59
- end
60
-
61
- def annotate(stream)
62
- ConcurrentStream.setup(stream, :threads => threads, :pids => pids, :callback => callback, :abort_callback => abort_callback, :filename => filename, :autojoin => autojoin, :lockfile => lockfile)
63
- stream
64
- end
65
-
66
- def clear
67
- threads, pids, callback, abort_callback, joined = nil
68
- end
69
-
70
- def joined?
71
- @joined
72
- end
73
-
74
- def aborted?
75
- @aborted
76
- end
77
-
78
- def join_threads
79
- if @threads and @threads.any?
80
- @threads.each do |t|
81
- next if t == Thread.current
82
- begin
83
- t.join
84
- if Process::Status === t.value
85
- if ! (t.value.success? || no_fail)
86
-
87
- if log
88
- msg = "Error joining #{self.filename || self.inspect}. Last log line: #{log}"
89
- else
90
- msg = "Error joining #{self.filename || self.inspect}"
91
- end
92
-
93
- raise ConcurrentStreamProcessFailed.new t.pid, msg, self
94
- end
95
- end
96
- rescue Exception
97
- if no_fail
98
- Log.low "Not failing on exception joining thread in ConcurrenStream: #{filename}"
99
- else
100
- Log.low "Exception joining thread in ConcurrenStream: #{filename}"
101
- stream_raise_exception $!
102
- end
103
- end
104
- end
105
- end
106
- @threads = []
107
- end
108
-
109
- def join_pids
110
- if @pids and @pids.any?
111
- @pids.each do |pid|
112
- begin
113
- Process.waitpid(pid, Process::WUNTRACED)
114
- stream_raise_exception ConcurrentStreamProcessFailed.new(pid, "Error in waitpid", self) unless $?.success? or no_fail
115
- rescue Errno::ECHILD
116
- end
117
- end
118
- @pids = []
119
- end
120
- end
121
-
122
- def join_callback
123
- if @callback and not joined?
124
- begin
125
- @callback.call
126
- ensure
127
- @callback = nil
128
- end
129
- end
130
- end
131
-
132
- def join
133
- begin
134
- join_threads
135
- join_pids
136
- join_callback
137
- close unless closed?
138
- ensure
139
- @joined = true
140
- lockfile.unlock if lockfile and lockfile.locked?
141
- raise stream_exception if stream_exception
142
- end
143
- end
144
-
145
- def abort_threads(exception = nil)
146
- return unless @threads and @threads.any?
147
- name = Thread.current.inspect
148
- name = filename if filename
149
- Log.low "Aborting threads (#{name}) #{@threads.collect{|t| t.inspect } * ", "}"
150
-
151
- @threads.each do |t|
152
- next if t == Thread.current
153
- Log.debug "Aborting thread (#{name}) #{t.inspect} with exception: #{exception}"
154
- t.raise((exception.nil? ? Aborted.new : exception))
155
- end
156
-
157
- @threads.each do |t|
158
- next if t == Thread.current
159
- if t.alive?
160
- sleep 1
161
- Log.low "Kill thread (#{name}) #{t.inspect}"
162
- t.kill
163
- end
164
- begin
165
- t.join unless t == Thread.current
166
- rescue Aborted
167
- rescue Exception
168
- Log.debug "Thread (#{name}) exception: #{$!.message}"
169
- end
170
- end
171
- end
172
-
173
- def abort_pids
174
- @pids.each do |pid|
175
- begin
176
- Log.low "Killing PID #{pid} in ConcurrentStream #{filename}"
177
- Process.kill :INT, pid
178
- rescue Errno::ESRCH
179
- end
180
- end if @pids
181
- @pids = []
182
- end
183
-
184
- def abort(exception = nil)
185
- if @aborted
186
- Log.medium "Already aborted stream #{Misc.fingerprint self} [#{@aborted}]"
187
- return
188
- else
189
- Log.medium "Aborting stream #{Misc.fingerprint self} [#{@aborted}]"
190
- end
191
- AbortedStream.setup(self, exception)
192
- @aborted = true
193
- begin
194
- close unless closed?
195
-
196
- @abort_callback.call exception if @abort_callback
197
-
198
- abort_threads(exception)
199
- abort_pids
200
-
201
- @callback = nil
202
- @abort_callback = nil
203
-
204
- @pair.abort exception if @pair
205
- ensure
206
- if lockfile and lockfile.locked?
207
- lockfile.unlock
208
- end
209
- end
210
- end
211
-
212
- def close(*args)
213
- if autojoin
214
- begin
215
- super(*args)
216
- rescue
217
- Log.exception $!
218
- self.abort
219
- self.join
220
- stream_raise_exception $!
221
- ensure
222
- self.join if self.closed? or self.eof?
223
- end
224
- else
225
- super(*args)
226
- end
227
- end
228
-
229
- def add_callback(&block)
230
- old_callback = callback
231
- @callback = Proc.new do
232
- old_callback.call if old_callback
233
- block.call
234
- end
235
- end
236
-
237
- def stream_raise_exception(exception)
238
- threads.each do |thread|
239
- thread.raise exception
240
- end
241
- self.stream_exception = exception
242
-
243
- self.abort
244
- end
245
-
246
- end
1
+ require_relative '../../refactor'
2
+ Rbbt.require_instead 'scout/concurrent_stream'
3
+ #module AbortedStream
4
+ # attr_accessor :exception
5
+ # def self.setup(obj, exception = nil)
6
+ # obj.extend AbortedStream
7
+ # obj.exception = exception
8
+ # end
9
+ #end
10
+ #
11
+ #module ConcurrentStream
12
+ # attr_accessor :threads, :pids, :callback, :abort_callback, :filename, :joined, :aborted, :autojoin, :lockfile, :no_fail, :pair, :thread, :stream_exception, :log, :std_err
13
+ #
14
+ # def self.setup(stream, options = {}, &block)
15
+ #
16
+ # threads, pids, callback, abort_callback, filename, autojoin, lockfile, no_fail, pair = Misc.process_options options, :threads, :pids, :callback, :abort_callback, :filename, :autojoin, :lockfile, :no_fail, :pair
17
+ # stream.extend ConcurrentStream unless ConcurrentStream === stream
18
+ #
19
+ # stream.threads ||= []
20
+ # stream.pids ||= []
21
+ # stream.threads.concat(Array === threads ? threads : [threads]) unless threads.nil?
22
+ # stream.pids.concat(Array === pids ? pids : [pids]) unless pids.nil? or pids.empty?
23
+ # stream.autojoin = autojoin unless autojoin.nil?
24
+ # stream.no_fail = no_fail unless no_fail.nil?
25
+ # stream.std_err = ""
26
+ #
27
+ # stream.pair = pair unless pair.nil?
28
+ #
29
+ # callback = block if block_given?
30
+ # if callback
31
+ # if stream.callback
32
+ # old_callback = stream.callback
33
+ # stream.callback = Proc.new do
34
+ # old_callback.call
35
+ # callback.call
36
+ # end
37
+ # else
38
+ # stream.callback = callback
39
+ # end
40
+ # end
41
+ #
42
+ # if abort_callback
43
+ # if stream.abort_callback
44
+ # old_abort_callback = stream.abort_callback
45
+ # stream.abort_callback = Proc.new do
46
+ # old_abort_callback.call
47
+ # abort_callback.call
48
+ # end
49
+ # else
50
+ # stream.abort_callback = abort_callback
51
+ # end
52
+ # end
53
+ #
54
+ # stream.filename = filename unless filename.nil?
55
+ #
56
+ # stream.lockfile = lockfile unless lockfile.nil?
57
+ #
58
+ # stream.aborted = false
59
+ #
60
+ # stream
61
+ # end
62
+ #
63
+ # def annotate(stream)
64
+ # ConcurrentStream.setup(stream, :threads => threads, :pids => pids, :callback => callback, :abort_callback => abort_callback, :filename => filename, :autojoin => autojoin, :lockfile => lockfile)
65
+ # stream
66
+ # end
67
+ #
68
+ # def clear
69
+ # threads, pids, callback, abort_callback, joined = nil
70
+ # end
71
+ #
72
+ # def joined?
73
+ # @joined
74
+ # end
75
+ #
76
+ # def aborted?
77
+ # @aborted
78
+ # end
79
+ #
80
+ # def join_threads
81
+ # if @threads and @threads.any?
82
+ # @threads.each do |t|
83
+ # next if t == Thread.current
84
+ # begin
85
+ # t.join
86
+ # if Process::Status === t.value
87
+ # if ! (t.value.success? || no_fail)
88
+ #
89
+ # if log
90
+ # msg = "Error joining #{self.filename || self.inspect}. Last log line: #{log}"
91
+ # else
92
+ # msg = "Error joining #{self.filename || self.inspect}"
93
+ # end
94
+ #
95
+ # raise ConcurrentStreamProcessFailed.new t.pid, msg, self
96
+ # end
97
+ # end
98
+ # rescue Exception
99
+ # if no_fail
100
+ # Log.low "Not failing on exception joining thread in ConcurrenStream: #{filename}"
101
+ # else
102
+ # Log.low "Exception joining thread in ConcurrenStream: #{filename}"
103
+ # stream_raise_exception $!
104
+ # end
105
+ # end
106
+ # end
107
+ # end
108
+ # @threads = []
109
+ # end
110
+ #
111
+ # def join_pids
112
+ # if @pids and @pids.any?
113
+ # @pids.each do |pid|
114
+ # begin
115
+ # Process.waitpid(pid, Process::WUNTRACED)
116
+ # stream_raise_exception ConcurrentStreamProcessFailed.new(pid, "Error in waitpid", self) unless $?.success? or no_fail
117
+ # rescue Errno::ECHILD
118
+ # end
119
+ # end
120
+ # @pids = []
121
+ # end
122
+ # end
123
+ #
124
+ # def join_callback
125
+ # if @callback and not joined?
126
+ # begin
127
+ # @callback.call
128
+ # ensure
129
+ # @callback = nil
130
+ # end
131
+ # end
132
+ # end
133
+ #
134
+ # def join
135
+ # begin
136
+ # join_threads
137
+ # join_pids
138
+ # join_callback
139
+ # close unless closed?
140
+ # ensure
141
+ # @joined = true
142
+ # lockfile.unlock if lockfile and lockfile.locked?
143
+ # raise stream_exception if stream_exception
144
+ # end
145
+ # end
146
+ #
147
+ # def abort_threads(exception = nil)
148
+ # return unless @threads and @threads.any?
149
+ # name = Thread.current.inspect
150
+ # name = filename if filename
151
+ # Log.low "Aborting threads (#{name}) #{@threads.collect{|t| t.inspect } * ", "}"
152
+ #
153
+ # @threads.each do |t|
154
+ # next if t == Thread.current
155
+ # Log.debug "Aborting thread (#{name}) #{t.inspect} with exception: #{exception}"
156
+ # t.raise((exception.nil? ? Aborted.new : exception))
157
+ # end
158
+ #
159
+ # @threads.each do |t|
160
+ # next if t == Thread.current
161
+ # if t.alive?
162
+ # sleep 1
163
+ # Log.low "Kill thread (#{name}) #{t.inspect}"
164
+ # t.kill
165
+ # end
166
+ # begin
167
+ # t.join unless t == Thread.current
168
+ # rescue Aborted
169
+ # rescue Exception
170
+ # Log.debug "Thread (#{name}) exception: #{$!.message}"
171
+ # end
172
+ # end
173
+ # end
174
+ #
175
+ # def abort_pids
176
+ # @pids.each do |pid|
177
+ # begin
178
+ # Log.low "Killing PID #{pid} in ConcurrentStream #{filename}"
179
+ # Process.kill :INT, pid
180
+ # rescue Errno::ESRCH
181
+ # end
182
+ # end if @pids
183
+ # @pids = []
184
+ # end
185
+ #
186
+ # def abort(exception = nil)
187
+ # if @aborted
188
+ # Log.medium "Already aborted stream #{Misc.fingerprint self} [#{@aborted}]"
189
+ # return
190
+ # else
191
+ # Log.medium "Aborting stream #{Misc.fingerprint self} [#{@aborted}]"
192
+ # end
193
+ # AbortedStream.setup(self, exception)
194
+ # @aborted = true
195
+ # begin
196
+ # close unless closed?
197
+ #
198
+ # @abort_callback.call exception if @abort_callback
199
+ #
200
+ # abort_threads(exception)
201
+ # abort_pids
202
+ #
203
+ # @callback = nil
204
+ # @abort_callback = nil
205
+ #
206
+ # @pair.abort exception if @pair
207
+ # ensure
208
+ # if lockfile and lockfile.locked?
209
+ # lockfile.unlock
210
+ # end
211
+ # end
212
+ # end
213
+ #
214
+ # def close(*args)
215
+ # if autojoin
216
+ # begin
217
+ # super(*args)
218
+ # rescue
219
+ # Log.exception $!
220
+ # self.abort
221
+ # self.join
222
+ # stream_raise_exception $!
223
+ # ensure
224
+ # self.join if self.closed? or self.eof?
225
+ # end
226
+ # else
227
+ # super(*args)
228
+ # end
229
+ # end
230
+ #
231
+ # def add_callback(&block)
232
+ # old_callback = callback
233
+ # @callback = Proc.new do
234
+ # old_callback.call if old_callback
235
+ # block.call
236
+ # end
237
+ # end
238
+ #
239
+ # def stream_raise_exception(exception)
240
+ # threads.each do |thread|
241
+ # thread.raise exception
242
+ # end
243
+ # self.stream_exception = exception
244
+ #
245
+ # self.abort
246
+ # end
247
+ #
248
+ #end
@@ -193,15 +193,15 @@ module Misc
193
193
  insist(3, &block)
194
194
  end
195
195
 
196
- def self.chunk(array, num)
197
- total = array.length
198
- current = 0
199
- while current < total
200
- last = current + num - 1
201
- yield array[current..last]
202
- current = last + 1
203
- end
204
- end
196
+ #def self.chunk(array, num)
197
+ # total = array.length
198
+ # current = 0
199
+ # while current < total
200
+ # last = current + num - 1
201
+ # yield array[current..last]
202
+ # current = last + 1
203
+ # end
204
+ #end
205
205
 
206
206
  # Divides the array into +num+ chunks of the same size by placing one
207
207
  # element in each chunk iteratively.
@@ -335,13 +335,14 @@ module Misc
335
335
  end
336
336
 
337
337
 
338
+ cpus = 1 if cpus <= 0
338
339
  options = Misc.add_defaults options, :respawn => true, :cpus => cpus
339
- options = Misc.add_defaults options, :bar => "Bootstrap in #{ options[:cpus] } cpus: #{ Misc.fingerprint Annotated.purge(elems) }"
340
+ options = Misc.add_defaults options, :bar => "Bootstrap in #{ options[:cpus] } cpus: #{ Misc.fingerprint Annotation.purge(elems) }"
340
341
  respawn = options[:respawn] and options[:cpus] and options[:cpus].to_i > 1
341
342
 
342
343
  index = (0..elems.length-1).to_a.collect{|v| v.to_s }
343
344
 
344
- TSV.traverse index, options do |pos|
345
+ TSV.traverse index, **options do |pos|
345
346
  if num == :current
346
347
  $BOOTSTRAPPED_CURRENT ||= n
347
348
  $BOOTSTRAPPED_CURRENT += 0