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.
- checksums.yaml +4 -4
- data/bin/rbbt +67 -90
- data/etc/app.d/base.rb +2 -2
- data/etc/app.d/semaphores.rb +3 -3
- data/lib/rbbt/annotations/annotated_array.rb +207 -207
- data/lib/rbbt/annotations/refactor.rb +27 -0
- data/lib/rbbt/annotations/util.rb +282 -282
- data/lib/rbbt/annotations.rb +343 -320
- data/lib/rbbt/association/database.rb +200 -225
- data/lib/rbbt/association/index.rb +294 -291
- data/lib/rbbt/association/item.rb +227 -227
- data/lib/rbbt/association/open.rb +35 -34
- data/lib/rbbt/association/util.rb +0 -169
- data/lib/rbbt/association.rb +2 -4
- data/lib/rbbt/entity/identifiers.rb +119 -118
- data/lib/rbbt/entity/refactor.rb +12 -0
- data/lib/rbbt/entity.rb +319 -315
- data/lib/rbbt/hpc/batch.rb +72 -53
- data/lib/rbbt/hpc/lsf.rb +2 -2
- data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
- data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
- data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
- data/lib/rbbt/hpc/orchestrate.rb +19 -13
- data/lib/rbbt/hpc/slurm.rb +18 -18
- data/lib/rbbt/knowledge_base/entity.rb +13 -5
- data/lib/rbbt/knowledge_base/query.rb +2 -2
- data/lib/rbbt/knowledge_base/registry.rb +32 -31
- data/lib/rbbt/knowledge_base/traverse.rb +1 -1
- data/lib/rbbt/knowledge_base.rb +1 -1
- data/lib/rbbt/monitor.rb +36 -25
- data/lib/rbbt/persist/refactor.rb +166 -0
- data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
- data/lib/rbbt/persist/tsv.rb +187 -185
- data/lib/rbbt/persist.rb +556 -551
- data/lib/rbbt/refactor.rb +20 -0
- data/lib/rbbt/resource/path/refactor.rb +178 -0
- data/lib/rbbt/resource/path.rb +317 -497
- data/lib/rbbt/resource/util.rb +0 -48
- data/lib/rbbt/resource.rb +3 -390
- data/lib/rbbt/tsv/accessor.rb +2 -838
- data/lib/rbbt/tsv/attach.rb +303 -299
- data/lib/rbbt/tsv/change_id.rb +244 -245
- data/lib/rbbt/tsv/csv.rb +87 -85
- data/lib/rbbt/tsv/dumper.rb +2 -100
- data/lib/rbbt/tsv/excel.rb +26 -24
- data/lib/rbbt/tsv/field_index.rb +4 -1
- data/lib/rbbt/tsv/filter.rb +3 -2
- data/lib/rbbt/tsv/index.rb +2 -284
- data/lib/rbbt/tsv/manipulate.rb +750 -747
- data/lib/rbbt/tsv/marshal.rb +3 -3
- data/lib/rbbt/tsv/matrix.rb +2 -2
- data/lib/rbbt/tsv/parallel/through.rb +2 -1
- data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
- data/lib/rbbt/tsv/parser.rb +678 -678
- data/lib/rbbt/tsv/refactor.rb +195 -0
- data/lib/rbbt/tsv/stream.rb +253 -251
- data/lib/rbbt/tsv/util.rb +420 -420
- data/lib/rbbt/tsv.rb +210 -208
- data/lib/rbbt/util/R/eval.rb +4 -4
- data/lib/rbbt/util/R/plot.rb +62 -166
- data/lib/rbbt/util/R.rb +21 -18
- data/lib/rbbt/util/cmd.rb +2 -318
- data/lib/rbbt/util/color.rb +269 -269
- data/lib/rbbt/util/colorize.rb +89 -89
- data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
- data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
- data/lib/rbbt/util/concurrency/processes.rb +389 -386
- data/lib/rbbt/util/config.rb +169 -167
- data/lib/rbbt/util/iruby.rb +20 -0
- data/lib/rbbt/util/log/progress/report.rb +241 -241
- data/lib/rbbt/util/log/progress/util.rb +99 -99
- data/lib/rbbt/util/log/progress.rb +102 -102
- data/lib/rbbt/util/log/refactor.rb +49 -0
- data/lib/rbbt/util/log.rb +486 -532
- data/lib/rbbt/util/migrate.rb +1 -1
- data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
- data/lib/rbbt/util/misc/development.rb +12 -11
- data/lib/rbbt/util/misc/exceptions.rb +117 -112
- data/lib/rbbt/util/misc/format.rb +2 -230
- data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
- data/lib/rbbt/util/misc/inspect.rb +2 -476
- data/lib/rbbt/util/misc/lock.rb +109 -106
- data/lib/rbbt/util/misc/omics.rb +9 -1
- data/lib/rbbt/util/misc/pipes.rb +765 -793
- data/lib/rbbt/util/misc/refactor.rb +20 -0
- data/lib/rbbt/util/misc/ssw.rb +27 -17
- data/lib/rbbt/util/misc/system.rb +0 -15
- data/lib/rbbt/util/misc.rb +39 -20
- data/lib/rbbt/util/named_array/refactor.rb +4 -0
- data/lib/rbbt/util/named_array.rb +3 -220
- data/lib/rbbt/util/open/refactor.rb +7 -0
- data/lib/rbbt/util/open.rb +3 -857
- data/lib/rbbt/util/procpath.rb +6 -6
- data/lib/rbbt/util/python/paths.rb +27 -0
- data/lib/rbbt/util/python/run.rb +115 -0
- data/lib/rbbt/util/python/script.rb +110 -0
- data/lib/rbbt/util/python/util.rb +3 -3
- data/lib/rbbt/util/python.rb +22 -81
- data/lib/rbbt/util/semaphore.rb +152 -148
- data/lib/rbbt/util/simpleopt.rb +9 -8
- data/lib/rbbt/util/ssh/refactor.rb +19 -0
- data/lib/rbbt/util/ssh.rb +122 -118
- data/lib/rbbt/util/tar.rb +117 -115
- data/lib/rbbt/util/tmpfile.rb +69 -67
- data/lib/rbbt/util/version.rb +2 -0
- data/lib/rbbt/workflow/refactor/entity.rb +11 -0
- data/lib/rbbt/workflow/refactor/export.rb +66 -0
- data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
- data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
- data/lib/rbbt/workflow/refactor/task_info.rb +65 -0
- data/lib/rbbt/workflow/refactor.rb +153 -0
- data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
- data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
- data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
- data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
- data/lib/rbbt/workflow/remote_workflow.rb +6 -1
- data/lib/rbbt/workflow/step/run.rb +766 -766
- data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
- data/lib/rbbt/workflow/step.rb +2 -362
- data/lib/rbbt/workflow/task.rb +118 -118
- data/lib/rbbt/workflow/usage.rb +289 -287
- data/lib/rbbt/workflow/util/archive.rb +6 -5
- data/lib/rbbt/workflow/util/data.rb +1 -1
- data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
- data/lib/rbbt/workflow/util/trace.rb +79 -44
- data/lib/rbbt/workflow.rb +4 -882
- data/lib/rbbt-util.rb +21 -13
- data/lib/rbbt.rb +16 -3
- data/python/rbbt/__init__.py +19 -1
- data/share/Rlib/plot.R +37 -37
- data/share/Rlib/svg.R +22 -5
- data/share/install/software/lib/install_helpers +1 -1
- data/share/rbbt_commands/hpc/list +2 -3
- data/share/rbbt_commands/hpc/orchestrate +4 -4
- data/share/rbbt_commands/hpc/tail +2 -0
- data/share/rbbt_commands/hpc/task +10 -7
- data/share/rbbt_commands/lsf/list +2 -3
- data/share/rbbt_commands/lsf/orchestrate +4 -4
- data/share/rbbt_commands/lsf/tail +2 -0
- data/share/rbbt_commands/lsf/task +10 -7
- data/share/rbbt_commands/migrate +1 -1
- data/share/rbbt_commands/pbs/list +2 -3
- data/share/rbbt_commands/pbs/orchestrate +4 -4
- data/share/rbbt_commands/pbs/tail +2 -0
- data/share/rbbt_commands/pbs/task +10 -7
- data/share/rbbt_commands/resource/produce +8 -1
- data/share/rbbt_commands/slurm/list +2 -3
- data/share/rbbt_commands/slurm/orchestrate +4 -4
- data/share/rbbt_commands/slurm/tail +2 -0
- data/share/rbbt_commands/slurm/task +10 -7
- data/share/rbbt_commands/system/clean +5 -5
- data/share/rbbt_commands/system/status +5 -5
- data/share/rbbt_commands/tsv/get +2 -3
- data/share/rbbt_commands/tsv/info +10 -13
- data/share/rbbt_commands/tsv/keys +18 -14
- data/share/rbbt_commands/tsv/slice +2 -2
- data/share/rbbt_commands/tsv/transpose +6 -2
- data/share/rbbt_commands/workflow/info +20 -24
- data/share/rbbt_commands/workflow/list +1 -1
- data/share/rbbt_commands/workflow/prov +20 -13
- data/share/rbbt_commands/workflow/server +11 -1
- data/share/rbbt_commands/workflow/task +76 -71
- data/share/rbbt_commands/workflow/write_info +26 -9
- data/share/software/opt/ssw/ssw.c +861 -0
- data/share/software/opt/ssw/ssw.h +130 -0
- data/share/workflow_config.ru +3 -3
- metadata +40 -2
@@ -1,241 +1,241 @@
|
|
1
|
-
module Log
|
2
|
-
class ProgressBar
|
3
|
-
def print(io, str)
|
4
|
-
return if Log.no_bar
|
5
|
-
LOG_MUTEX.synchronize do
|
6
|
-
STDERR.print str
|
7
|
-
Log.logfile.puts str unless Log.logfile.nil?
|
8
|
-
Log::LAST.replace "progress"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
attr_accessor :history, :mean_max, :max_history
|
13
|
-
def thr_msg
|
14
|
-
if @history.nil?
|
15
|
-
@history ||= [[0, @start], [@ticks, Time.now] ]
|
16
|
-
elsif @last_ticks != @ticks
|
17
|
-
@history << [@ticks, Time.now]
|
18
|
-
max_history ||= begin
|
19
|
-
max_history = case
|
20
|
-
when @ticks > 20
|
21
|
-
count = @ticks - @last_count
|
22
|
-
count = 1 if count == 0
|
23
|
-
if @max
|
24
|
-
times = @max / count
|
25
|
-
num = times / 20
|
26
|
-
num = 2 if num < 2
|
27
|
-
else
|
28
|
-
num = 10
|
29
|
-
end
|
30
|
-
count * num
|
31
|
-
else
|
32
|
-
20
|
33
|
-
end
|
34
|
-
max_history = 30 if max_history > 30
|
35
|
-
max_history
|
36
|
-
end
|
37
|
-
@history.shift if @history.length > max_history
|
38
|
-
end
|
39
|
-
|
40
|
-
@last_ticks = @ticks
|
41
|
-
|
42
|
-
@mean_max ||= 0
|
43
|
-
if @history.length > 3
|
44
|
-
|
45
|
-
sticks, stime = @history.first
|
46
|
-
ssticks, sstime = @history[-3]
|
47
|
-
lticks, ltime = @history.last
|
48
|
-
|
49
|
-
|
50
|
-
mean = @mean = (lticks - sticks).to_f / (ltime - stime)
|
51
|
-
short_mean = (lticks - ssticks).to_f / (ltime - sstime)
|
52
|
-
|
53
|
-
@mean_max = mean if mean > @mean_max
|
54
|
-
end
|
55
|
-
|
56
|
-
if short_mean
|
57
|
-
thr = short_mean
|
58
|
-
else
|
59
|
-
thr = begin
|
60
|
-
(@ticks || 1) / (Time.now - @start)
|
61
|
-
rescue
|
62
|
-
1
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
thr = 0.0000001 if thr == 0
|
67
|
-
|
68
|
-
if mean.nil? or mean.to_i > 2
|
69
|
-
str = "#{ Log.color :blue, thr.to_i.to_s } per sec."
|
70
|
-
#str << " #{ Log.color :yellow, mean.to_i.to_s } avg. #{Log.color :yellow, @mean_max.to_i.to_s} max." if @mean_max > 0
|
71
|
-
else
|
72
|
-
if 1.0/thr < 1
|
73
|
-
str = "#{ Log.color :blue, (1.0/thr).round(2).to_s } secs each"
|
74
|
-
elsif 1.0/thr < 2
|
75
|
-
str = "#{ Log.color :blue, (1.0/thr).round(1).to_s } secs each"
|
76
|
-
else
|
77
|
-
str = "#{ Log.color :blue, (1/thr).ceil.to_s } secs each"
|
78
|
-
end
|
79
|
-
#str << " #{ Log.color :yellow, (1/mean).ceil.to_s } avg. #{Log.color :yellow, (1/@mean_max).ceil.to_s} min." if @mean_max > 0
|
80
|
-
end
|
81
|
-
|
82
|
-
str
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
def eta_msg
|
87
|
-
percent = self.percent
|
88
|
-
time = Time.now
|
89
|
-
|
90
|
-
indicator = ""
|
91
|
-
10.times{|i|
|
92
|
-
if i < percent / 10 then
|
93
|
-
indicator << Log.color(:yellow, ".")
|
94
|
-
else
|
95
|
-
indicator << " "
|
96
|
-
end
|
97
|
-
}
|
98
|
-
|
99
|
-
indicator << " #{Log.color(:blue, percent.to_s << "%")}"
|
100
|
-
|
101
|
-
used = time - @start
|
102
|
-
if @mean_max and @mean_max > 0 and @mean > 0
|
103
|
-
eta = (@max - @ticks) / @mean
|
104
|
-
else
|
105
|
-
eta = (@max - @ticks) / (@ticks/used)
|
106
|
-
end
|
107
|
-
|
108
|
-
used = Misc.format_seconds(used)
|
109
|
-
eta = [eta/3600, eta/60 % 60, eta % 60].map{|t| "%02i" % t }.join(':')
|
110
|
-
|
111
|
-
#indicator << " #{Log.color :yellow, used} used #{Log.color :yellow, eta} left - #{Log.color :yellow, ticks.to_s} of #{Log.color :yellow, @max.to_s} #{bytes ? 'bytes' : 'items'}"
|
112
|
-
indicator << " #{Log.color :yellow, eta} => #{Log.color :yellow, used} - #{Log.color :yellow, ticks.to_s} of #{Log.color :yellow, @max.to_s} #{bytes ? 'bytes' : 'items'}"
|
113
|
-
|
114
|
-
indicator
|
115
|
-
end
|
116
|
-
|
117
|
-
def report_msg
|
118
|
-
str = Log.color(:magenta, "·")
|
119
|
-
if @ticks == 0
|
120
|
-
if @max
|
121
|
-
return str << " " << Log.color(:magenta, "waiting on #{@max} #{bytes ? 'bytes' : 'items'}") << Log.color(:magenta, " · " << desc)
|
122
|
-
else
|
123
|
-
return str << " " << Log.color(:magenta, "waiting - PID: #{Process.pid}") << Log.color(:magenta, " · " << desc)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
str << " " << thr_msg
|
127
|
-
if max
|
128
|
-
str << Log.color(:blue, " -- ") << eta_msg
|
129
|
-
else
|
130
|
-
str << Log.color(:blue, " -- ") << ticks.to_s << " #{bytes ? 'bytes' : 'items'}"
|
131
|
-
end
|
132
|
-
str << Log.color(:magenta, " · " << desc)
|
133
|
-
str
|
134
|
-
end
|
135
|
-
|
136
|
-
def load(info)
|
137
|
-
info.each do |key, value|
|
138
|
-
case key.to_sym
|
139
|
-
when :start
|
140
|
-
@start = value
|
141
|
-
when :last_time
|
142
|
-
@last_time = value
|
143
|
-
when :last_count
|
144
|
-
@last_count = value
|
145
|
-
when :last_percent
|
146
|
-
@last_percent = value
|
147
|
-
when :desc
|
148
|
-
@desc = value
|
149
|
-
when :ticks
|
150
|
-
@ticks = value
|
151
|
-
when :max
|
152
|
-
@max = value
|
153
|
-
when :mean
|
154
|
-
@mean = value
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def save
|
160
|
-
info = {:start => @start, :last_time => @last_time, :last_count => @last_count, :last_percent => @last_percent, :desc => @desc, :ticks => @ticks, :max => @max, :mean => @mean}
|
161
|
-
info.delete_if{|k,v| v.nil?}
|
162
|
-
Open.write(file, info.to_yaml)
|
163
|
-
end
|
164
|
-
|
165
|
-
def report(io = STDERR)
|
166
|
-
if Log::LAST != "progress"
|
167
|
-
bars = BARS
|
168
|
-
if Log::LAST == "new_bar"
|
169
|
-
Log::LAST.replace "progress"
|
170
|
-
bar = bars.sort_by{|b| b.depth }.first
|
171
|
-
print(io, Log.color(:magenta ,bar.report_msg) << "\n")
|
172
|
-
else
|
173
|
-
length = Log::ProgressBar.cleanup_bars
|
174
|
-
print(io, Log.color(:magenta, "···Progress\n"))
|
175
|
-
bars.sort_by{|b| b.depth }.reverse.each do |bar|
|
176
|
-
if SILENCED.include? bar
|
177
|
-
print(io, Log.color(:magenta, "·\n"))
|
178
|
-
else
|
179
|
-
print(io, Log.color(:magenta ,bar.report_msg) << "\n")
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
else
|
184
|
-
bars = BARS
|
185
|
-
end
|
186
|
-
bars << self unless BARS.include? self
|
187
|
-
|
188
|
-
print(io, Log.up_lines(bars.length) << Log.color(:magenta, "···Progress\n") << Log.down_lines(bars.length+1)) if Log::ProgressBar.offset == 0
|
189
|
-
print(io, Log.up_lines(@depth) << report_msg << "\n" << Log.down_lines(@depth - 1))
|
190
|
-
@last_time = Time.now
|
191
|
-
@last_count = ticks
|
192
|
-
@last_percent = percent if max and max > 0
|
193
|
-
Log::LAST.replace "progress"
|
194
|
-
save if file
|
195
|
-
end
|
196
|
-
|
197
|
-
def done(io = STDERR)
|
198
|
-
done_msg = Log.color(:magenta, "· ") << Log.color(:green, "done")
|
199
|
-
if @start
|
200
|
-
ellapsed = (Time.now - @start).to_i
|
201
|
-
else
|
202
|
-
ellapsed = 0
|
203
|
-
end
|
204
|
-
ellapsed = [ellapsed/3600, ellapsed/60 % 60, ellapsed % 60].map{|t| "%02i" % t }.join(':')
|
205
|
-
done_msg << " " << Log.color(:blue, (@ticks).to_s) << " #{bytes ? 'bytes' : 'items'} in " << Log.color(:green, ellapsed)
|
206
|
-
@last_count = 0
|
207
|
-
@last_time = @start
|
208
|
-
done_msg << " - " << thr_msg
|
209
|
-
done_msg << Log.color(:magenta, " · " << desc)
|
210
|
-
print(io, Log.up_lines(@depth) << done_msg << Log.down_lines(@depth))
|
211
|
-
|
212
|
-
Open.rm file if file and Open.exists?(file)
|
213
|
-
|
214
|
-
@callback.call self if @callback
|
215
|
-
end
|
216
|
-
|
217
|
-
def error(io = STDERR)
|
218
|
-
done_msg = Log.color(:magenta, "· ") << Log.color(:red, "error")
|
219
|
-
if @start
|
220
|
-
ellapsed = (Time.now - @start).to_i
|
221
|
-
else
|
222
|
-
ellapsed = 0
|
223
|
-
end
|
224
|
-
ellapsed = [ellapsed/3600, ellapsed/60 % 60, ellapsed % 60].map{|t| "%02i" % t }.join(':')
|
225
|
-
done_msg << " " << Log.color(:blue, (@ticks).to_s) << " in " << Log.color(:green, ellapsed)
|
226
|
-
@last_count = 0
|
227
|
-
@last_time = @start
|
228
|
-
done_msg << " - " << thr_msg
|
229
|
-
done_msg << Log.color(:magenta, " · " << desc)
|
230
|
-
print(io, Log.up_lines(@depth) << done_msg << Log.down_lines(@depth))
|
231
|
-
|
232
|
-
Open.rm file if file and Open.exists?(file)
|
233
|
-
|
234
|
-
begin
|
235
|
-
@callback.call self
|
236
|
-
rescue
|
237
|
-
Log.debug "Callback failed for filed progress bar: #{$!.message}"
|
238
|
-
end if @callback
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
1
|
+
#module Log
|
2
|
+
# class ProgressBar
|
3
|
+
# def print(io, str)
|
4
|
+
# return if Log.no_bar
|
5
|
+
# LOG_MUTEX.synchronize do
|
6
|
+
# STDERR.print str
|
7
|
+
# Log.logfile.puts str unless Log.logfile.nil?
|
8
|
+
# Log::LAST.replace "progress"
|
9
|
+
# end
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# attr_accessor :history, :mean_max, :max_history
|
13
|
+
# def thr_msg
|
14
|
+
# if @history.nil?
|
15
|
+
# @history ||= [[0, @start], [@ticks, Time.now] ]
|
16
|
+
# elsif @last_ticks != @ticks
|
17
|
+
# @history << [@ticks, Time.now]
|
18
|
+
# max_history ||= begin
|
19
|
+
# max_history = case
|
20
|
+
# when @ticks > 20
|
21
|
+
# count = @ticks - @last_count
|
22
|
+
# count = 1 if count == 0
|
23
|
+
# if @max
|
24
|
+
# times = @max / count
|
25
|
+
# num = times / 20
|
26
|
+
# num = 2 if num < 2
|
27
|
+
# else
|
28
|
+
# num = 10
|
29
|
+
# end
|
30
|
+
# count * num
|
31
|
+
# else
|
32
|
+
# 20
|
33
|
+
# end
|
34
|
+
# max_history = 30 if max_history > 30
|
35
|
+
# max_history
|
36
|
+
# end
|
37
|
+
# @history.shift if @history.length > max_history
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# @last_ticks = @ticks
|
41
|
+
#
|
42
|
+
# @mean_max ||= 0
|
43
|
+
# if @history.length > 3
|
44
|
+
#
|
45
|
+
# sticks, stime = @history.first
|
46
|
+
# ssticks, sstime = @history[-3]
|
47
|
+
# lticks, ltime = @history.last
|
48
|
+
#
|
49
|
+
#
|
50
|
+
# mean = @mean = (lticks - sticks).to_f / (ltime - stime)
|
51
|
+
# short_mean = (lticks - ssticks).to_f / (ltime - sstime)
|
52
|
+
#
|
53
|
+
# @mean_max = mean if mean > @mean_max
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# if short_mean
|
57
|
+
# thr = short_mean
|
58
|
+
# else
|
59
|
+
# thr = begin
|
60
|
+
# (@ticks || 1) / (Time.now - @start)
|
61
|
+
# rescue
|
62
|
+
# 1
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# thr = 0.0000001 if thr == 0
|
67
|
+
#
|
68
|
+
# if mean.nil? or mean.to_i > 2
|
69
|
+
# str = "#{ Log.color :blue, thr.to_i.to_s } per sec."
|
70
|
+
# #str << " #{ Log.color :yellow, mean.to_i.to_s } avg. #{Log.color :yellow, @mean_max.to_i.to_s} max." if @mean_max > 0
|
71
|
+
# else
|
72
|
+
# if 1.0/thr < 1
|
73
|
+
# str = "#{ Log.color :blue, (1.0/thr).round(2).to_s } secs each"
|
74
|
+
# elsif 1.0/thr < 2
|
75
|
+
# str = "#{ Log.color :blue, (1.0/thr).round(1).to_s } secs each"
|
76
|
+
# else
|
77
|
+
# str = "#{ Log.color :blue, (1/thr).ceil.to_s } secs each"
|
78
|
+
# end
|
79
|
+
# #str << " #{ Log.color :yellow, (1/mean).ceil.to_s } avg. #{Log.color :yellow, (1/@mean_max).ceil.to_s} min." if @mean_max > 0
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# str
|
83
|
+
# end
|
84
|
+
#
|
85
|
+
#
|
86
|
+
# def eta_msg
|
87
|
+
# percent = self.percent
|
88
|
+
# time = Time.now
|
89
|
+
#
|
90
|
+
# indicator = ""
|
91
|
+
# 10.times{|i|
|
92
|
+
# if i < percent / 10 then
|
93
|
+
# indicator << Log.color(:yellow, ".")
|
94
|
+
# else
|
95
|
+
# indicator << " "
|
96
|
+
# end
|
97
|
+
# }
|
98
|
+
#
|
99
|
+
# indicator << " #{Log.color(:blue, percent.to_s << "%")}"
|
100
|
+
#
|
101
|
+
# used = time - @start
|
102
|
+
# if @mean_max and @mean_max > 0 and @mean > 0
|
103
|
+
# eta = (@max - @ticks) / @mean
|
104
|
+
# else
|
105
|
+
# eta = (@max - @ticks) / (@ticks/used)
|
106
|
+
# end
|
107
|
+
#
|
108
|
+
# used = Misc.format_seconds(used)
|
109
|
+
# eta = [eta/3600, eta/60 % 60, eta % 60].map{|t| "%02i" % t }.join(':')
|
110
|
+
#
|
111
|
+
# #indicator << " #{Log.color :yellow, used} used #{Log.color :yellow, eta} left - #{Log.color :yellow, ticks.to_s} of #{Log.color :yellow, @max.to_s} #{bytes ? 'bytes' : 'items'}"
|
112
|
+
# indicator << " #{Log.color :yellow, eta} => #{Log.color :yellow, used} - #{Log.color :yellow, ticks.to_s} of #{Log.color :yellow, @max.to_s} #{bytes ? 'bytes' : 'items'}"
|
113
|
+
#
|
114
|
+
# indicator
|
115
|
+
# end
|
116
|
+
#
|
117
|
+
# def report_msg
|
118
|
+
# str = Log.color(:magenta, "·")
|
119
|
+
# if @ticks == 0
|
120
|
+
# if @max
|
121
|
+
# return str << " " << Log.color(:magenta, "waiting on #{@max} #{bytes ? 'bytes' : 'items'}") << Log.color(:magenta, " · " << desc)
|
122
|
+
# else
|
123
|
+
# return str << " " << Log.color(:magenta, "waiting - PID: #{Process.pid}") << Log.color(:magenta, " · " << desc)
|
124
|
+
# end
|
125
|
+
# end
|
126
|
+
# str << " " << thr_msg
|
127
|
+
# if max
|
128
|
+
# str << Log.color(:blue, " -- ") << eta_msg
|
129
|
+
# else
|
130
|
+
# str << Log.color(:blue, " -- ") << ticks.to_s << " #{bytes ? 'bytes' : 'items'}"
|
131
|
+
# end
|
132
|
+
# str << Log.color(:magenta, " · " << desc)
|
133
|
+
# str
|
134
|
+
# end
|
135
|
+
#
|
136
|
+
# def load(info)
|
137
|
+
# info.each do |key, value|
|
138
|
+
# case key.to_sym
|
139
|
+
# when :start
|
140
|
+
# @start = value
|
141
|
+
# when :last_time
|
142
|
+
# @last_time = value
|
143
|
+
# when :last_count
|
144
|
+
# @last_count = value
|
145
|
+
# when :last_percent
|
146
|
+
# @last_percent = value
|
147
|
+
# when :desc
|
148
|
+
# @desc = value
|
149
|
+
# when :ticks
|
150
|
+
# @ticks = value
|
151
|
+
# when :max
|
152
|
+
# @max = value
|
153
|
+
# when :mean
|
154
|
+
# @mean = value
|
155
|
+
# end
|
156
|
+
# end
|
157
|
+
# end
|
158
|
+
#
|
159
|
+
# def save
|
160
|
+
# info = {:start => @start, :last_time => @last_time, :last_count => @last_count, :last_percent => @last_percent, :desc => @desc, :ticks => @ticks, :max => @max, :mean => @mean}
|
161
|
+
# info.delete_if{|k,v| v.nil?}
|
162
|
+
# Open.write(file, info.to_yaml)
|
163
|
+
# end
|
164
|
+
#
|
165
|
+
# def report(io = STDERR)
|
166
|
+
# if Log::LAST != "progress"
|
167
|
+
# bars = BARS
|
168
|
+
# if Log::LAST == "new_bar"
|
169
|
+
# Log::LAST.replace "progress"
|
170
|
+
# bar = bars.sort_by{|b| b.depth }.first
|
171
|
+
# print(io, Log.color(:magenta ,bar.report_msg) << "\n")
|
172
|
+
# else
|
173
|
+
# length = Log::ProgressBar.cleanup_bars
|
174
|
+
# print(io, Log.color(:magenta, "···Progress\n"))
|
175
|
+
# bars.sort_by{|b| b.depth }.reverse.each do |bar|
|
176
|
+
# if SILENCED.include? bar
|
177
|
+
# print(io, Log.color(:magenta, "·\n"))
|
178
|
+
# else
|
179
|
+
# print(io, Log.color(:magenta ,bar.report_msg) << "\n")
|
180
|
+
# end
|
181
|
+
# end
|
182
|
+
# end
|
183
|
+
# else
|
184
|
+
# bars = BARS
|
185
|
+
# end
|
186
|
+
# bars << self unless BARS.include? self
|
187
|
+
#
|
188
|
+
# print(io, Log.up_lines(bars.length) << Log.color(:magenta, "···Progress\n") << Log.down_lines(bars.length+1)) if Log::ProgressBar.offset == 0
|
189
|
+
# print(io, Log.up_lines(@depth) << report_msg << "\n" << Log.down_lines(@depth - 1))
|
190
|
+
# @last_time = Time.now
|
191
|
+
# @last_count = ticks
|
192
|
+
# @last_percent = percent if max and max > 0
|
193
|
+
# Log::LAST.replace "progress"
|
194
|
+
# save if file
|
195
|
+
# end
|
196
|
+
#
|
197
|
+
# def done(io = STDERR)
|
198
|
+
# done_msg = Log.color(:magenta, "· ") << Log.color(:green, "done")
|
199
|
+
# if @start
|
200
|
+
# ellapsed = (Time.now - @start).to_i
|
201
|
+
# else
|
202
|
+
# ellapsed = 0
|
203
|
+
# end
|
204
|
+
# ellapsed = [ellapsed/3600, ellapsed/60 % 60, ellapsed % 60].map{|t| "%02i" % t }.join(':')
|
205
|
+
# done_msg << " " << Log.color(:blue, (@ticks).to_s) << " #{bytes ? 'bytes' : 'items'} in " << Log.color(:green, ellapsed)
|
206
|
+
# @last_count = 0
|
207
|
+
# @last_time = @start
|
208
|
+
# done_msg << " - " << thr_msg
|
209
|
+
# done_msg << Log.color(:magenta, " · " << desc)
|
210
|
+
# print(io, Log.up_lines(@depth) << done_msg << Log.down_lines(@depth))
|
211
|
+
#
|
212
|
+
# Open.rm file if file and Open.exists?(file)
|
213
|
+
#
|
214
|
+
# @callback.call self if @callback
|
215
|
+
# end
|
216
|
+
#
|
217
|
+
# def error(io = STDERR)
|
218
|
+
# done_msg = Log.color(:magenta, "· ") << Log.color(:red, "error")
|
219
|
+
# if @start
|
220
|
+
# ellapsed = (Time.now - @start).to_i
|
221
|
+
# else
|
222
|
+
# ellapsed = 0
|
223
|
+
# end
|
224
|
+
# ellapsed = [ellapsed/3600, ellapsed/60 % 60, ellapsed % 60].map{|t| "%02i" % t }.join(':')
|
225
|
+
# done_msg << " " << Log.color(:blue, (@ticks).to_s) << " in " << Log.color(:green, ellapsed)
|
226
|
+
# @last_count = 0
|
227
|
+
# @last_time = @start
|
228
|
+
# done_msg << " - " << thr_msg
|
229
|
+
# done_msg << Log.color(:magenta, " · " << desc)
|
230
|
+
# print(io, Log.up_lines(@depth) << done_msg << Log.down_lines(@depth))
|
231
|
+
#
|
232
|
+
# Open.rm file if file and Open.exists?(file)
|
233
|
+
#
|
234
|
+
# begin
|
235
|
+
# @callback.call self
|
236
|
+
# rescue
|
237
|
+
# Log.debug "Callback failed for filed progress bar: #{$!.message}"
|
238
|
+
# end if @callback
|
239
|
+
# end
|
240
|
+
# end
|
241
|
+
#end
|