rbbt-util 5.44.1 → 6.0.4
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.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/bin/rbbt +67 -90
- data/bin/rbbt_exec.rb +2 -2
- 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/filecache.rb +1 -1
- 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 +2 -2
- 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 +92 -105
- 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 +66 -0
- data/lib/rbbt/workflow/refactor.rb +150 -0
- data/lib/rbbt/workflow/remote_workflow/driver/rest.rb +1 -2
- 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 +96 -4
- data/python/rbbt/workflow/remote.py +104 -0
- data/python/rbbt/workflow.py +64 -0
- data/python/test.py +10 -0
- 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/retry +43 -0
- data/share/rbbt_commands/workflow/server +12 -2
- data/share/rbbt_commands/workflow/task +80 -73
- 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 +45 -6
@@ -1,781 +1,783 @@
|
|
1
|
-
module TSV
|
2
|
-
|
3
|
-
def self.obj_stream(obj)
|
4
|
-
case obj
|
5
|
-
when nil
|
6
|
-
nil
|
7
|
-
when (defined? Step and Step)
|
8
|
-
obj.result
|
9
|
-
when IO, File, Zlib::GzipReader, Bgzf
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
path =
|
25
|
-
if
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
#filename_obj
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
options[:
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
when
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
if
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
when
|
432
|
-
traverse_array(obj
|
433
|
-
when
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
when
|
444
|
-
|
445
|
-
|
446
|
-
raise "
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
mutex.
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
q.
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
stream = obj_stream(
|
523
|
-
stream.abort if stream.respond_to? :abort
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
stream = obj_stream(
|
533
|
-
stream.abort if stream.respond_to? :abort
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
store.
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
store
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
when
|
599
|
-
|
600
|
-
|
601
|
-
when
|
602
|
-
obj.
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
when
|
607
|
-
close_streams << obj.result
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
close_streams
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
into = options[:into]
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
threads =
|
698
|
-
cpus =
|
699
|
-
|
700
|
-
if
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
when
|
705
|
-
options[:type] = :keys
|
706
|
-
|
707
|
-
options[:
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
max
|
719
|
-
|
720
|
-
|
721
|
-
max
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
bar
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
end
|
1
|
+
#module TSV
|
2
|
+
#
|
3
|
+
# def self.obj_stream(obj)
|
4
|
+
# case obj
|
5
|
+
# when nil
|
6
|
+
# nil
|
7
|
+
# when (defined? Step and Step)
|
8
|
+
# obj.result
|
9
|
+
# #when IO, File, Zlib::GzipReader, Bgzf
|
10
|
+
# when IO, File, Zlib::GzipReader #, Bgzf
|
11
|
+
# obj
|
12
|
+
# when TSV::Dumper
|
13
|
+
# obj.stream
|
14
|
+
# when TSV::Parser
|
15
|
+
# obj.stream
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# def self.guess_max(obj)
|
20
|
+
# begin
|
21
|
+
# case obj
|
22
|
+
# when (defined? Step and Step)
|
23
|
+
# if obj.done?
|
24
|
+
# path = obj.path
|
25
|
+
# path = path.find if path.respond_to? :find
|
26
|
+
# if File.exist? path
|
27
|
+
# CMD.cmd("wc -l '#{path}'").read.to_i
|
28
|
+
# else
|
29
|
+
# nil
|
30
|
+
# end
|
31
|
+
# else
|
32
|
+
# nil
|
33
|
+
# end
|
34
|
+
# when TSV
|
35
|
+
# obj.length
|
36
|
+
# when Array, Hash
|
37
|
+
# obj.size
|
38
|
+
# when File
|
39
|
+
# return nil if Open.gzip?(obj) or Open.bgzip?(obj)
|
40
|
+
# CMD.cmd("wc -l '#{obj.path}'").read.to_i
|
41
|
+
# when Path, String
|
42
|
+
# obj = obj.find if Path === obj
|
43
|
+
# if File.exist? obj
|
44
|
+
# return nil if Open.gzip?(obj) or Open.bgzip?(obj)
|
45
|
+
# CMD.cmd("wc -l '#{obj}'").read.to_i
|
46
|
+
# else
|
47
|
+
# nil
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
# rescue Exception
|
51
|
+
# Log.exception $!
|
52
|
+
# nil
|
53
|
+
# end
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# def self.stream_name(obj)
|
57
|
+
# return "nil" if obj.nil?
|
58
|
+
# #filename_obj = obj.respond_to?(:filename) ? obj.filename : nil
|
59
|
+
# #filename_obj ||= obj.respond_to?(:path) ? obj.path : nil
|
60
|
+
# stream_obj = obj_stream(obj) || obj
|
61
|
+
# obj.class.to_s << "-" << Misc.fingerprint(stream_obj)
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# def self.report(msg, obj, into)
|
65
|
+
# into = into[:into] if Hash === into and into.include? :into
|
66
|
+
#
|
67
|
+
# Log.low{"#{ msg } #{stream_name(obj)} -> #{stream_name(into)}"}
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# #{{{ TRAVERSE OBJECTS
|
71
|
+
#
|
72
|
+
# def self.traverse_tsv(tsv, options = {}, &block)
|
73
|
+
# callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
74
|
+
#
|
75
|
+
# begin
|
76
|
+
# error = false
|
77
|
+
# fields = tsv.fields
|
78
|
+
# if callback
|
79
|
+
# bar.init if bar
|
80
|
+
# tsv.through options[:key_field], options[:fields] do |k,v|
|
81
|
+
# begin
|
82
|
+
# callback.call yield(k,v,fields)
|
83
|
+
# rescue Exception
|
84
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint([k, v, fields])}"
|
85
|
+
# raise $!
|
86
|
+
# ensure
|
87
|
+
# bar.tick if bar
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
# else
|
91
|
+
# bar.init if bar
|
92
|
+
# tsv.through options[:key_field], options[:fields] do |k,v|
|
93
|
+
# begin
|
94
|
+
# yield k,v,fields
|
95
|
+
# ensure
|
96
|
+
# bar.tick if bar
|
97
|
+
# end
|
98
|
+
# end
|
99
|
+
# end
|
100
|
+
# rescue
|
101
|
+
# error = true
|
102
|
+
# raise $!
|
103
|
+
# ensure
|
104
|
+
# join.call(error) if join
|
105
|
+
# Log::ProgressBar.remove_bar(bar, error) if bar
|
106
|
+
# end
|
107
|
+
# end
|
108
|
+
#
|
109
|
+
# def self.traverse_hash(hash, options = {}, &block)
|
110
|
+
# callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
111
|
+
#
|
112
|
+
# begin
|
113
|
+
# error = false
|
114
|
+
# if callback
|
115
|
+
# bar.init if bar
|
116
|
+
# hash.each do |k,v|
|
117
|
+
# begin
|
118
|
+
# callback.call yield(k,v)
|
119
|
+
# ensure
|
120
|
+
# bar.tick if bar
|
121
|
+
# end
|
122
|
+
# end
|
123
|
+
# else
|
124
|
+
# bar.init if bar
|
125
|
+
# hash.each do |k,v|
|
126
|
+
# begin
|
127
|
+
# yield k,v
|
128
|
+
# rescue Exception
|
129
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint([k, v])}"
|
130
|
+
# raise $!
|
131
|
+
# ensure
|
132
|
+
# bar.tick if bar
|
133
|
+
# end
|
134
|
+
# end
|
135
|
+
# end
|
136
|
+
# rescue
|
137
|
+
# error = true
|
138
|
+
# raise $!
|
139
|
+
# ensure
|
140
|
+
# join.call(error) if join
|
141
|
+
# Log::ProgressBar.remove_bar(bar, error) if bar
|
142
|
+
# end
|
143
|
+
# end
|
144
|
+
#
|
145
|
+
# def self.traverse_array(array, options = {}, &block)
|
146
|
+
# callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
147
|
+
#
|
148
|
+
# begin
|
149
|
+
# error = false
|
150
|
+
# if callback
|
151
|
+
# bar.init if bar
|
152
|
+
# array.each do |e|
|
153
|
+
# begin
|
154
|
+
# callback.call yield(e)
|
155
|
+
# rescue Exception
|
156
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint(e)}"
|
157
|
+
# raise $!
|
158
|
+
# ensure
|
159
|
+
# bar.tick if bar
|
160
|
+
# end
|
161
|
+
# end
|
162
|
+
# else
|
163
|
+
# bar.init if bar
|
164
|
+
# array.each do |e|
|
165
|
+
# begin
|
166
|
+
# yield e
|
167
|
+
# rescue Exception
|
168
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint(e)}"
|
169
|
+
# raise $!
|
170
|
+
# ensure
|
171
|
+
# bar.tick if bar
|
172
|
+
# end
|
173
|
+
# end
|
174
|
+
# end
|
175
|
+
#
|
176
|
+
# rescue
|
177
|
+
# error = true
|
178
|
+
# raise $!
|
179
|
+
# ensure
|
180
|
+
# join.call(error) if join
|
181
|
+
# Log::ProgressBar.remove_bar(bar, error) if bar
|
182
|
+
# end
|
183
|
+
# end
|
184
|
+
#
|
185
|
+
# def self.traverse_enumerable(enum, options = {}, &block)
|
186
|
+
# callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
187
|
+
#
|
188
|
+
# begin
|
189
|
+
# error = false
|
190
|
+
# if callback
|
191
|
+
# bar.init if bar
|
192
|
+
# while enum.any?
|
193
|
+
# e = enum.pop
|
194
|
+
# begin
|
195
|
+
# callback.call yield(e)
|
196
|
+
# rescue Exception
|
197
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint(e)}"
|
198
|
+
# raise $!
|
199
|
+
# ensure
|
200
|
+
# bar.tick if bar
|
201
|
+
# end
|
202
|
+
# end
|
203
|
+
# else
|
204
|
+
# bar.init if bar
|
205
|
+
# while enum.any?
|
206
|
+
# e = enum.pop
|
207
|
+
# begin
|
208
|
+
# yield e
|
209
|
+
# rescue Exception
|
210
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint(e)}"
|
211
|
+
# raise $!
|
212
|
+
# ensure
|
213
|
+
# bar.tick if bar
|
214
|
+
# end
|
215
|
+
# end
|
216
|
+
# end
|
217
|
+
#
|
218
|
+
# rescue
|
219
|
+
# error = true
|
220
|
+
# raise $!
|
221
|
+
# ensure
|
222
|
+
# join.call(error) if join
|
223
|
+
# Log::ProgressBar.remove_bar(bar, error) if bar
|
224
|
+
# end
|
225
|
+
# end
|
226
|
+
#
|
227
|
+
# def self.traverse_priority_queue(queue, options = {}, &block)
|
228
|
+
# callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
229
|
+
#
|
230
|
+
# begin
|
231
|
+
# error = false
|
232
|
+
# if callback
|
233
|
+
# bar.init if bar
|
234
|
+
# while queue.any?
|
235
|
+
# e = queue.pop
|
236
|
+
# begin
|
237
|
+
# callback.call yield(e)
|
238
|
+
# rescue Exception
|
239
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint(e)}"
|
240
|
+
# raise $!
|
241
|
+
# ensure
|
242
|
+
# bar.tick if bar
|
243
|
+
# end
|
244
|
+
# end
|
245
|
+
# else
|
246
|
+
# bar.init if bar
|
247
|
+
# while queue.any?
|
248
|
+
# e = queue.pop
|
249
|
+
# begin
|
250
|
+
# yield e
|
251
|
+
# rescue Exception
|
252
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint(e)}"
|
253
|
+
# raise $!
|
254
|
+
# ensure
|
255
|
+
# bar.tick if bar
|
256
|
+
# end
|
257
|
+
# end
|
258
|
+
# end
|
259
|
+
#
|
260
|
+
# rescue
|
261
|
+
# error = true
|
262
|
+
# raise $!
|
263
|
+
# ensure
|
264
|
+
# join.call(error) if join
|
265
|
+
# Log::ProgressBar.remove_bar(bar, error) if bar
|
266
|
+
# end
|
267
|
+
# end
|
268
|
+
#
|
269
|
+
# def self.traverse_io_array(io, options = {}, &block)
|
270
|
+
# callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
271
|
+
# begin
|
272
|
+
# error = false
|
273
|
+
# if File === io and io.closed?
|
274
|
+
# begin
|
275
|
+
# Log.low{"Rewinding stream #{stream_name(io)}"}
|
276
|
+
# io.reopen io.filename, "r"
|
277
|
+
# rescue
|
278
|
+
# Log.exception $!
|
279
|
+
# raise "File closed and could not reopen #{stream_name(io)}"
|
280
|
+
# end
|
281
|
+
# end
|
282
|
+
#
|
283
|
+
# if callback
|
284
|
+
# bar.init if bar
|
285
|
+
# while line = io.gets
|
286
|
+
# if line[-1] != "\n"
|
287
|
+
# while c = io.getc
|
288
|
+
# line << c
|
289
|
+
# break if c=="\n"
|
290
|
+
# end
|
291
|
+
# end
|
292
|
+
# begin
|
293
|
+
# callback.call yield line.chomp
|
294
|
+
# rescue Exception
|
295
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint(line)}"
|
296
|
+
# raise $!
|
297
|
+
# ensure
|
298
|
+
# bar.tick if bar
|
299
|
+
# end
|
300
|
+
# end
|
301
|
+
# else
|
302
|
+
# bar.init if bar
|
303
|
+
# while line = io.gets
|
304
|
+
# begin
|
305
|
+
# yield line.chomp
|
306
|
+
# rescue Exception
|
307
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint(line)}"
|
308
|
+
# raise $!
|
309
|
+
# ensure
|
310
|
+
# bar.tick if bar
|
311
|
+
# end
|
312
|
+
# end
|
313
|
+
# end
|
314
|
+
# rescue
|
315
|
+
# error = true
|
316
|
+
# raise $!
|
317
|
+
# ensure
|
318
|
+
# join.call(error) if join
|
319
|
+
# Log::ProgressBar.remove_bar(bar, error) if bar
|
320
|
+
# end
|
321
|
+
# end
|
322
|
+
#
|
323
|
+
# def self.traverse_io(io, options = {}, &block)
|
324
|
+
# callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
325
|
+
#
|
326
|
+
# begin
|
327
|
+
# error = false
|
328
|
+
# if File === io and io.closed?
|
329
|
+
# begin
|
330
|
+
# Log.low{"Rewinding stream #{stream_name(io)}"}
|
331
|
+
# io.reopen io.filename, "r"
|
332
|
+
# rescue
|
333
|
+
# Log.exception $!
|
334
|
+
# raise "File closed and could not reopen #{stream_name(io)}"
|
335
|
+
# end
|
336
|
+
# end
|
337
|
+
#
|
338
|
+
# options[:monitor] = bar
|
339
|
+
# if callback
|
340
|
+
# bar.init if bar
|
341
|
+
# exception = nil
|
342
|
+
# begin
|
343
|
+
# TSV::Parser.traverse(io, options) do |k,v,f|
|
344
|
+
# begin
|
345
|
+
# callback.call yield k, v, f
|
346
|
+
# rescue Exception
|
347
|
+
# exception = $!
|
348
|
+
# Log.warn "Traverse exception on element: #{Misc.fingerprint([k, v, f])}"
|
349
|
+
# raise $!
|
350
|
+
# end
|
351
|
+
# bar.tick if bar
|
352
|
+
# end
|
353
|
+
# ensure
|
354
|
+
# raise exception if exception
|
355
|
+
# end
|
356
|
+
# else
|
357
|
+
# TSV::Parser.traverse(io, options.merge(:monitor => bar), &block)
|
358
|
+
# end
|
359
|
+
# rescue
|
360
|
+
# error = true
|
361
|
+
# raise $!
|
362
|
+
# ensure
|
363
|
+
# join.call(error) if join
|
364
|
+
# Log::ProgressBar.remove_bar(bar, error) if bar
|
365
|
+
# end
|
366
|
+
# end
|
367
|
+
#
|
368
|
+
# def self.traverse_obj(obj, options = {}, &block)
|
369
|
+
# if options[:type] == :keys
|
370
|
+
# options[:fields] = []
|
371
|
+
# options[:type] = :single
|
372
|
+
# end
|
373
|
+
#
|
374
|
+
# name = stream_name(obj)
|
375
|
+
# Log.low{"Traversing #{name} #{Log.color :green, "->"} #{stream_name(options[:into])}"}
|
376
|
+
# begin
|
377
|
+
# case obj
|
378
|
+
# when (defined? FastContainers && FastContainers::PriorityQueue === obj)
|
379
|
+
# traverse_priority_queue(obj, options, &block)
|
380
|
+
# when TSV
|
381
|
+
# traverse_tsv(obj, options, &block)
|
382
|
+
# when Hash
|
383
|
+
# traverse_hash(obj, options, &block)
|
384
|
+
# when TSV::Parser
|
385
|
+
# callback = Misc.process_options options, :callback
|
386
|
+
# if callback
|
387
|
+
# obj.traverse(options) do |k,v|
|
388
|
+
# callback.call yield k, v
|
389
|
+
# end
|
390
|
+
# else
|
391
|
+
# obj.traverse(options, &block)
|
392
|
+
# end
|
393
|
+
# #when IO, File, Zlib::GzipReader, Bgzf, StringIO
|
394
|
+
# when IO, File, Zlib::GzipReader, StringIO
|
395
|
+
# begin
|
396
|
+
# if options[:type] == :array or options[:type] == :line
|
397
|
+
# traverse_io_array(obj, options, &block)
|
398
|
+
# else
|
399
|
+
# traverse_io(obj, options, &block)
|
400
|
+
# end
|
401
|
+
# rescue Aborted
|
402
|
+
# obj.abort if obj.respond_to? :abort
|
403
|
+
# raise $!
|
404
|
+
# rescue Exception
|
405
|
+
# obj.abort if obj.respond_to? :abort
|
406
|
+
# raise $!
|
407
|
+
# ensure
|
408
|
+
# obj.close if obj.respond_to? :close and not obj.closed?
|
409
|
+
# obj.join if obj.respond_to? :join
|
410
|
+
# end
|
411
|
+
# when Path
|
412
|
+
# obj.open do |stream|
|
413
|
+
# traverse_obj(stream, options, &block)
|
414
|
+
# end
|
415
|
+
# when TSV::Dumper
|
416
|
+
# traverse_obj(obj.stream, options, &block)
|
417
|
+
# when (defined? Step and Step)
|
418
|
+
#
|
419
|
+
# obj.clean if obj.aborted? or obj.recoverable_error?
|
420
|
+
# obj.run(true) unless obj.done? || obj.started? || obj.result
|
421
|
+
#
|
422
|
+
# stream = obj.get_stream
|
423
|
+
# options = {:type => :array}.merge(options) if obj.result_type == :array
|
424
|
+
#
|
425
|
+
# if stream
|
426
|
+
# traverse_obj(stream, options, &block)
|
427
|
+
# else
|
428
|
+
# obj.join
|
429
|
+
# traverse_obj(obj.path, options, &block)
|
430
|
+
# end
|
431
|
+
# when Array
|
432
|
+
# traverse_array(obj, options, &block)
|
433
|
+
# when Set
|
434
|
+
# traverse_array(obj.to_a, options, &block)
|
435
|
+
# when String
|
436
|
+
# if Open.remote?(obj) || Open.ssh?(obj) || Misc.is_filename?(obj)
|
437
|
+
# Open.open(obj) do |s|
|
438
|
+
# traverse_obj(s, options, &block)
|
439
|
+
# end
|
440
|
+
# else
|
441
|
+
# raise "Can not open obj for traversal #{Misc.fingerprint obj}"
|
442
|
+
# end
|
443
|
+
# when Enumerable
|
444
|
+
# traverse_enumerable(obj, options, &block)
|
445
|
+
# when nil
|
446
|
+
# raise "Can not traverse nil object into #{stream_name(options[:into])}"
|
447
|
+
# else
|
448
|
+
# raise "Unknown object for traversal: #{Misc.fingerprint obj }"
|
449
|
+
# end
|
450
|
+
# rescue IOError
|
451
|
+
# Log.low{"IOError traversing #{stream_name(obj)}: #{$!.message}"}
|
452
|
+
# abort_stream obj
|
453
|
+
# abort_stream options[:into], $!
|
454
|
+
# raise $!
|
455
|
+
# rescue Errno::EPIPE
|
456
|
+
# Log.low{"Pipe closed while traversing #{stream_name(obj)}: #{$!.message}"}
|
457
|
+
# abort_stream obj
|
458
|
+
# abort_stream options[:into], $!
|
459
|
+
# raise $!
|
460
|
+
# rescue Aborted
|
461
|
+
# Log.low{"Aborted traversing #{stream_name(obj)}"}
|
462
|
+
# abort_stream obj
|
463
|
+
# abort_stream options[:into], $!
|
464
|
+
# raise $!
|
465
|
+
# rescue Exception
|
466
|
+
# Log.low{"Exception traversing #{stream_name(obj)}"}
|
467
|
+
# abort_stream obj unless String === obj
|
468
|
+
# abort_stream options[:into], $!
|
469
|
+
# raise $!
|
470
|
+
# end
|
471
|
+
# end
|
472
|
+
#
|
473
|
+
# def self.traverse_threads(num, obj, options, &block)
|
474
|
+
# callback = Misc.process_options options, :callback
|
475
|
+
#
|
476
|
+
# q = RbbtThreadQueue.new num
|
477
|
+
#
|
478
|
+
# if callback
|
479
|
+
# block = Proc.new do |*args|
|
480
|
+
# mutex = args.pop
|
481
|
+
# res = yield *args
|
482
|
+
# mutex.synchronize do
|
483
|
+
# callback.call res
|
484
|
+
# end
|
485
|
+
# end
|
486
|
+
# end
|
487
|
+
#
|
488
|
+
# q.init true, &block
|
489
|
+
#
|
490
|
+
# traverse_obj(obj, options) do |*p|
|
491
|
+
# q.process p
|
492
|
+
# end
|
493
|
+
#
|
494
|
+
# q.join
|
495
|
+
# nil
|
496
|
+
# end
|
497
|
+
#
|
498
|
+
# def self.traverse_cpus(num, obj, options, &block)
|
499
|
+
# begin
|
500
|
+
# error = false
|
501
|
+
#
|
502
|
+
# callback, cleanup, join, respawn, bar = Misc.process_options options, :callback, :cleanup, :join, :respawn, :bar
|
503
|
+
# respawn = true if ENV["RBBT_RESPAWN"] and ENV["RBBT_RESPAWN"] == "true"
|
504
|
+
#
|
505
|
+
# Log.low "Traversing in #{ num } cpus: #{respawn ? "respawn" : "no respawn"}"
|
506
|
+
# q = RbbtProcessQueue.new num, cleanup, join, respawn, !!bar
|
507
|
+
# callback = Proc.new{ bar.tick } if callback.nil? and bar
|
508
|
+
# q.callback &callback
|
509
|
+
# q.init &block
|
510
|
+
#
|
511
|
+
# bar.init if bar
|
512
|
+
# traverse_obj(obj, options) do |*p|
|
513
|
+
# q.process *p
|
514
|
+
# end
|
515
|
+
#
|
516
|
+
# q.join
|
517
|
+
#
|
518
|
+
# rescue Interrupt, Aborted
|
519
|
+
# error = true
|
520
|
+
# Log.low{"Aborted traversal in CPUs for #{stream_name(obj) || Misc.fingerprint(obj)}: #{$!.backtrace*","}"}
|
521
|
+
# q.abort
|
522
|
+
# stream = obj_stream(obj)
|
523
|
+
# stream.abort if stream.respond_to? :abort
|
524
|
+
# stream = obj_stream(options[:into])
|
525
|
+
# stream.abort if stream.respond_to? :abort
|
526
|
+
# q.join
|
527
|
+
# raise "Traversal aborted"
|
528
|
+
# rescue Exception
|
529
|
+
# error = true
|
530
|
+
# Log.low{"Exception during traversal in CPUs for #{stream_name(obj) || Misc.fingerprint(obj)}: #{$!.message}"}
|
531
|
+
# q.abort
|
532
|
+
# stream = obj_stream(obj)
|
533
|
+
# stream.abort if stream.respond_to? :abort
|
534
|
+
# stream = obj_stream(options[:into])
|
535
|
+
# stream.abort if stream.respond_to? :abort
|
536
|
+
# q.join
|
537
|
+
# raise $!
|
538
|
+
# ensure
|
539
|
+
# Log::ProgressBar.remove_bar(bar, error) if bar
|
540
|
+
# end
|
541
|
+
# end
|
542
|
+
#
|
543
|
+
# def self.store_into(store, value)
|
544
|
+
# if MultipleResult === value
|
545
|
+
# value.each do |v|
|
546
|
+
# store_into store, v
|
547
|
+
# end
|
548
|
+
# return
|
549
|
+
# end
|
550
|
+
# begin
|
551
|
+
# return false if value.nil?
|
552
|
+
# case store
|
553
|
+
# when TSV
|
554
|
+
# if store.type == :double or store.type == :flat
|
555
|
+
# case value
|
556
|
+
# when TSV, Hash
|
557
|
+
# store.merge_zip value
|
558
|
+
# else
|
559
|
+
# store.zip_new *value
|
560
|
+
# end
|
561
|
+
# else
|
562
|
+
# k,v = value
|
563
|
+
# store[k] = v
|
564
|
+
# end
|
565
|
+
# when Hash
|
566
|
+
# case value
|
567
|
+
# when TSV, Hash
|
568
|
+
# store.merge! value
|
569
|
+
# else
|
570
|
+
# k,v = value
|
571
|
+
# store[k] = v
|
572
|
+
# end
|
573
|
+
# when TSV::Dumper
|
574
|
+
# return false if value.nil?
|
575
|
+
# store.add *value
|
576
|
+
# when IO
|
577
|
+
# return false if value.nil?
|
578
|
+
# value.chomp!
|
579
|
+
# store.puts value
|
580
|
+
# else
|
581
|
+
# store << value
|
582
|
+
# end
|
583
|
+
# true
|
584
|
+
# rescue Aborted, Interrupt
|
585
|
+
# Log.low "Aborted storing into #{Misc.fingerprint store}"
|
586
|
+
# abort_stream(store, $!)
|
587
|
+
# raise $!
|
588
|
+
# rescue Exception
|
589
|
+
# Log.low "Exception storing into #{Misc.fingerprint store}: #{$!.message}"
|
590
|
+
# abort_stream(store, $!)
|
591
|
+
# raise $!
|
592
|
+
# end
|
593
|
+
# end
|
594
|
+
#
|
595
|
+
# def self.get_streams_to_close(obj)
|
596
|
+
# close_streams = []
|
597
|
+
# case obj
|
598
|
+
# when IO, File
|
599
|
+
# close_streams << obj
|
600
|
+
# when TSV::Parser
|
601
|
+
# when TSV::Dumper
|
602
|
+
# close_streams << obj.result.in_stream
|
603
|
+
# when (defined? Step and Step)
|
604
|
+
# obj.mutex.synchronize do
|
605
|
+
# case obj.result
|
606
|
+
# when IO
|
607
|
+
# close_streams << obj.result
|
608
|
+
# when TSV::Dumper
|
609
|
+
# close_streams << obj.result.in_stream
|
610
|
+
# end
|
611
|
+
# end
|
612
|
+
# obj.inputs.each do |input|
|
613
|
+
# close_streams = get_streams_to_close(input) + close_streams
|
614
|
+
# end
|
615
|
+
# obj.dependencies.each do |dependency|
|
616
|
+
# close_streams = get_streams_to_close(dependency) + close_streams
|
617
|
+
# end
|
618
|
+
# end
|
619
|
+
# close_streams
|
620
|
+
# end
|
621
|
+
#
|
622
|
+
# def self.traverse_run(obj, threads, cpus, options = {}, &block)
|
623
|
+
# threads = nil if threads == 1
|
624
|
+
# cpus = nil if cpus == 1
|
625
|
+
# if ENV["RBBT_NO_MAP_REDUCE"] == "true" or (threads.nil? and cpus.nil?)
|
626
|
+
# traverse_obj obj, options, &block
|
627
|
+
# else
|
628
|
+
# if threads
|
629
|
+
# traverse_threads threads, obj, options, &block
|
630
|
+
# else
|
631
|
+
# close_streams = Misc.process_options(options, :close_streams) || []
|
632
|
+
# close_streams = [close_streams] unless Array === close_streams
|
633
|
+
#
|
634
|
+
# close_streams.concat(get_streams_to_close(obj))
|
635
|
+
# options[:close_streams] = close_streams
|
636
|
+
#
|
637
|
+
# if close_streams and close_streams.any?
|
638
|
+
# options[:cleanup] = Proc.new do
|
639
|
+
# close_streams.uniq.each do |s|
|
640
|
+
# s.close unless s.closed?
|
641
|
+
# end
|
642
|
+
# end
|
643
|
+
# end
|
644
|
+
#
|
645
|
+
# traverse_cpus cpus, obj, options, &block
|
646
|
+
# end
|
647
|
+
# end
|
648
|
+
# end
|
649
|
+
#
|
650
|
+
# def self.traverse_stream(obj, threads = nil, cpus = nil, options = {}, &block)
|
651
|
+
# into = options[:into]
|
652
|
+
#
|
653
|
+
# thread = Thread.new do
|
654
|
+
# begin
|
655
|
+
# traverse_run(obj, threads, cpus, options, &block)
|
656
|
+
# into.close if into.respond_to?(:close) and not (into.respond_to?(:closed?) and into.closed?)
|
657
|
+
# rescue Exception
|
658
|
+
# abort_stream obj
|
659
|
+
# abort_stream into
|
660
|
+
# raise $!
|
661
|
+
# end
|
662
|
+
# end
|
663
|
+
#
|
664
|
+
# ConcurrentStream.setup(obj_stream(into), :threads => thread)
|
665
|
+
# end
|
666
|
+
#
|
667
|
+
# def self.traverse(obj, options = {}, &block)
|
668
|
+
# into = options[:into]
|
669
|
+
#
|
670
|
+
# into = options[:into] = Open.open(into, :mode => "w") if Misc.is_filename?(into)
|
671
|
+
#
|
672
|
+
# case into
|
673
|
+
# when :stream
|
674
|
+
# sout = Misc.open_pipe false, false do |sin|
|
675
|
+
# begin
|
676
|
+
# traverse(obj, options.merge(:into => sin), &block)
|
677
|
+
# rescue Exception
|
678
|
+
# Log.exception $!
|
679
|
+
# begin
|
680
|
+
# sout.abort if sout.respond_to? :abort
|
681
|
+
# sout.join if sout.respond_to? :join
|
682
|
+
# ensure
|
683
|
+
# raise $!
|
684
|
+
# end
|
685
|
+
# end
|
686
|
+
# end
|
687
|
+
# return sout
|
688
|
+
# when :dumper
|
689
|
+
# obj_options = obj.respond_to?(:options) ? obj.options : {}
|
690
|
+
# dumper = TSV::Dumper.new obj_options.merge(options)
|
691
|
+
# dumper.init
|
692
|
+
# _options = options.merge(obj_options).merge(:into => dumper)
|
693
|
+
# traverse(obj, _options, &block)
|
694
|
+
# return dumper
|
695
|
+
# end
|
696
|
+
#
|
697
|
+
# threads = Misc.process_options options, :threads
|
698
|
+
# cpus = Misc.process_options options, :cpus
|
699
|
+
# threads = nil if threads and threads.to_i <= 1
|
700
|
+
# cpus = nil if cpus and cpus.to_i <= 1
|
701
|
+
#
|
702
|
+
# if options[:keys]
|
703
|
+
# case options[:keys]
|
704
|
+
# when TrueClass
|
705
|
+
# options[:type] = :keys
|
706
|
+
# when String
|
707
|
+
# options[:type] = :keys
|
708
|
+
# options[:key_field] = options[:keys]
|
709
|
+
# options[:fields] = []
|
710
|
+
# end
|
711
|
+
# end
|
712
|
+
#
|
713
|
+
# bar = Misc.process_options options, :bar
|
714
|
+
# bar ||= Misc.process_options options, :progress
|
715
|
+
# options[:bar] = case bar
|
716
|
+
# when String
|
717
|
+
# max = guess_max(obj)
|
718
|
+
# Log::ProgressBar.new_bar(max, {:desc => bar})
|
719
|
+
# when TrueClass
|
720
|
+
# max = guess_max(obj)
|
721
|
+
# Log::ProgressBar.new_bar(max, nil)
|
722
|
+
# when Numeric
|
723
|
+
# max = guess_max(obj)
|
724
|
+
# Log::ProgressBar.new_bar(bar)
|
725
|
+
# when Hash
|
726
|
+
# max = Misc.process_options(bar, :max) || max
|
727
|
+
# Log::ProgressBar.new_bar(max, bar)
|
728
|
+
# when Log::ProgressBar
|
729
|
+
# bar.max ||= guess_max(obj)
|
730
|
+
# bar
|
731
|
+
# else
|
732
|
+
# if (defined? Step and Step === bar)
|
733
|
+
# max = guess_max(obj)
|
734
|
+
# Log::ProgressBar.new_bar(max, {:desc => bar.status, :file => bar.file(:progress)})
|
735
|
+
# else
|
736
|
+
# bar
|
737
|
+
# end
|
738
|
+
# end
|
739
|
+
#
|
740
|
+
# if into
|
741
|
+
# bar = Misc.process_options options, :bar
|
742
|
+
#
|
743
|
+
# options[:join] = Proc.new do |error|
|
744
|
+
# error = false if error.nil?
|
745
|
+
# Log::ProgressBar.remove_bar(bar, error) if bar
|
746
|
+
# end if bar
|
747
|
+
#
|
748
|
+
# options[:callback] = Proc.new do |e|
|
749
|
+
# begin
|
750
|
+
# store_into into, e
|
751
|
+
# rescue Aborted
|
752
|
+
# Log.low "Aborted callback #{stream_name(obj)} #{Log.color :green, "->"} #{stream_name(options[:into])}"
|
753
|
+
# abort_stream(into, $!)
|
754
|
+
# raise $!
|
755
|
+
# rescue Exception
|
756
|
+
# Log.low "Exception callback #{stream_name(obj)} #{Log.color :green, "->"} #{stream_name(options[:into])}"
|
757
|
+
# abort_stream(into, $!)
|
758
|
+
# raise $!
|
759
|
+
# ensure
|
760
|
+
# bar.tick if bar
|
761
|
+
# end
|
762
|
+
# end
|
763
|
+
#
|
764
|
+
# bar.init if bar
|
765
|
+
# begin
|
766
|
+
# case into
|
767
|
+
# when TSV::Dumper, IO
|
768
|
+
# traverse_stream(obj, threads, cpus, options, &block)
|
769
|
+
# else
|
770
|
+
# traverse_run(obj, threads, cpus, options, &block)
|
771
|
+
# end
|
772
|
+
# rescue Exception
|
773
|
+
# Log.exception $!
|
774
|
+
# abort_stream(into, $!)
|
775
|
+
# raise $!
|
776
|
+
# end
|
777
|
+
#
|
778
|
+
# into
|
779
|
+
# else
|
780
|
+
# traverse_run(obj, threads, cpus, options, &block)
|
781
|
+
# end
|
782
|
+
# end
|
783
|
+
#end
|