rbbt-util 5.18.1 → 5.19.0
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/bin/rbbt +6 -0
- data/lib/rbbt/persist.rb +12 -3
- data/lib/rbbt/persist/tsv.rb +11 -3
- data/lib/rbbt/resource/path.rb +1 -0
- data/lib/rbbt/tsv/accessor.rb +5 -3
- data/lib/rbbt/tsv/attach.rb +7 -3
- data/lib/rbbt/util/misc/development.rb +1 -1
- data/lib/rbbt/util/misc/inspect.rb +1 -1
- data/lib/rbbt/util/open.rb +1 -0
- data/lib/rbbt/util/tc_cache.rb +18 -0
- data/lib/rbbt/workflow/step/run.rb +5 -0
- data/share/rbbt_commands/resource/produce +4 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bf01122d1f1460989b9d2527d19cd87942f3d07
|
4
|
+
data.tar.gz: e1575d23a2667e28938be48e396e6d7c4f605c45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e327f95dcdd0f274b53a1001fe65ef4ccd0411a3cc1ab852b70f0e7e609d9835476768d4873dde308080871e8ebcc1d4bcb406f0ac93b58ca815a85c2c10aa0f
|
7
|
+
data.tar.gz: 9d0616c4bd35dc136da7019ffd913b6b08e1f76a36c9e6bca096b2491bdafb171dba9031abedc4c67782e8f8b81f77dd323a4966fb829f62f57d760aa47a95f4
|
data/bin/rbbt
CHANGED
@@ -43,6 +43,7 @@ $ rbbt <command> <subcommand> ... -a --arg1 --arg2='value' --arg3 'another-value
|
|
43
43
|
--nocolor #{Log.color :yellow, "Disable colored output"}
|
44
44
|
--nobar #{Log.color :yellow, "Disable progress report"}
|
45
45
|
--nostream #{Log.color :yellow, "Disable persistance/job streaming"}
|
46
|
+
--update_persist #{Log.color :yellow, "Update persisted TSV files if source has been updated"}
|
46
47
|
--locate_file #{Log.color :yellow, "Report the location of the script instead of executing it"}
|
47
48
|
--dump_mem* #{Log.color :yellow, "Dump strings in memory each second into file"}
|
48
49
|
-nolock--no_lock_id #{Log.color :yellow, "Do not track lockfiles with ids (prevent stale file handlers for high-througput and high-concurrency)"}
|
@@ -54,6 +55,7 @@ locate = options.delete :locate_file
|
|
54
55
|
if options[:log_file]
|
55
56
|
Log.logfile(options[:log_file])
|
56
57
|
end
|
58
|
+
|
57
59
|
if options[:log]
|
58
60
|
Log.severity = options[:log].to_i
|
59
61
|
else
|
@@ -76,6 +78,10 @@ if mem_dump = options.delete(:dump_mem)
|
|
76
78
|
end
|
77
79
|
|
78
80
|
|
81
|
+
if options.delete(:update_persist)
|
82
|
+
ENV["RBBT_UPDATE_TSV_PERSIST"] = "true"
|
83
|
+
end
|
84
|
+
|
79
85
|
if options.delete :nostream
|
80
86
|
ENV["RBBT_NO_STREAM"] = "true"
|
81
87
|
end
|
data/lib/rbbt/persist.rb
CHANGED
@@ -27,6 +27,8 @@ module Persist
|
|
27
27
|
|
28
28
|
def self.newer?(path, file)
|
29
29
|
return true if not Open.exists? file
|
30
|
+
path = path.find if Path === path
|
31
|
+
file = file.find if Path === file
|
30
32
|
return File.mtime(path) - File.mtime(file) if File.mtime(path) < File.mtime(file)
|
31
33
|
return false
|
32
34
|
end
|
@@ -82,7 +84,7 @@ module Persist
|
|
82
84
|
options_md5 = Misc.hash2md5 clean_options
|
83
85
|
filename << ":" << options_md5 unless options_md5.empty?
|
84
86
|
|
85
|
-
persistence_dir[filename]
|
87
|
+
persistence_dir[filename]
|
86
88
|
end
|
87
89
|
|
88
90
|
TRUE_STRINGS = Set.new ["true", "True", "TRUE", "t", "T", "1", "yes", "Yes", "YES", "y", "Y", "ON", "on"] unless defined? TRUE_STRINGS
|
@@ -333,10 +335,17 @@ module Persist
|
|
333
335
|
other_options = Misc.process_options persist_options, :other
|
334
336
|
path = persistence_path(name, persist_options, other_options || {})
|
335
337
|
|
338
|
+
if ENV["RBBT_UPDATE_TSV_PERSIST"] == 'true' and name and Open.exists?(name)
|
339
|
+
persist_options[:check] ||= []
|
340
|
+
persist_options[:check] << name
|
341
|
+
else
|
342
|
+
check_options = {}
|
343
|
+
end
|
344
|
+
|
336
345
|
case
|
337
346
|
when type.to_sym == :memory
|
338
347
|
repo = persist_options[:repo] || Persist::MEMORY
|
339
|
-
repo[path] ||= yield
|
348
|
+
repo[path.find] ||= yield
|
340
349
|
|
341
350
|
when (type.to_sym == :annotations and persist_options.include? :annotation_repo)
|
342
351
|
|
@@ -419,7 +428,7 @@ module Persist
|
|
419
428
|
end
|
420
429
|
|
421
430
|
else
|
422
|
-
persist_file(path, type, persist_options, &block)
|
431
|
+
persist_file(path.find, type, persist_options, &block)
|
423
432
|
end
|
424
433
|
|
425
434
|
end
|
data/lib/rbbt/persist/tsv.rb
CHANGED
@@ -98,9 +98,14 @@ module Persist
|
|
98
98
|
|
99
99
|
path = persistence_path(filename, persist_options, options)
|
100
100
|
|
101
|
-
|
101
|
+
if ENV["RBBT_UPDATE_TSV_PERSIST"] == 'true' and filename
|
102
|
+
check_options = {:check => [filename]}
|
103
|
+
else
|
104
|
+
check_options = {}
|
105
|
+
end
|
102
106
|
|
103
|
-
if is_persisted?(path) and not persist_options[:update]
|
107
|
+
if is_persisted?(path, check_options) and not persist_options[:update]
|
108
|
+
path = path.find if Path === path
|
104
109
|
Log.debug "TSV persistence up-to-date: #{ path }"
|
105
110
|
if persist_options[:shard_function]
|
106
111
|
return open_sharder(path, false, nil, persist_options[:engine], persist_options, &persist_options[:shard_function])
|
@@ -109,9 +114,11 @@ module Persist
|
|
109
114
|
end
|
110
115
|
end
|
111
116
|
|
117
|
+
lock_filename = Persist.persistence_path(path, {:dir => TSV.lock_dir})
|
112
118
|
Misc.lock lock_filename do
|
113
119
|
begin
|
114
|
-
if is_persisted?(path) and not persist_options[:update]
|
120
|
+
if is_persisted?(path, check_options) and not persist_options[:update]
|
121
|
+
path = path.find if Path === path
|
115
122
|
Log.debug "TSV persistence (suddenly) up-to-date: #{ path }"
|
116
123
|
|
117
124
|
if persist_options[:shard_function]
|
@@ -120,6 +127,7 @@ module Persist
|
|
120
127
|
return open_database(path, false, nil, persist_options[:engine] || TokyoCabinet::HDB, persist_options)
|
121
128
|
end
|
122
129
|
end
|
130
|
+
path = path.find if Path === path
|
123
131
|
|
124
132
|
FileUtils.rm_rf path if File.exists? path
|
125
133
|
|
data/lib/rbbt/resource/path.rb
CHANGED
data/lib/rbbt/tsv/accessor.rb
CHANGED
@@ -415,12 +415,14 @@ module TSV
|
|
415
415
|
sorted = elems.sort do |a, b|
|
416
416
|
a_value = a.last
|
417
417
|
b_value = b.last
|
418
|
+
a_empty = a_value.nil? or (a_value.respond_to?(:empty?) and a_value.empty?)
|
419
|
+
b_empty = b_value.nil? or (b_value.respond_to?(:empty?) and b_value.empty?)
|
418
420
|
case
|
419
|
-
when (
|
421
|
+
when (a_empty and b_empty)
|
420
422
|
0
|
421
|
-
when
|
423
|
+
when a_empty
|
422
424
|
-1
|
423
|
-
when
|
425
|
+
when b_empty
|
424
426
|
1
|
425
427
|
when Array === a_value
|
426
428
|
if a_value.length == 1 and b_value.length == 1
|
data/lib/rbbt/tsv/attach.rb
CHANGED
@@ -237,9 +237,13 @@ module TSV
|
|
237
237
|
attach_index other, index, fields
|
238
238
|
end
|
239
239
|
rescue Exception
|
240
|
-
|
241
|
-
|
242
|
-
|
240
|
+
if same_key
|
241
|
+
Log.warn "Could not translate identifiers with same_key"
|
242
|
+
same_key = false
|
243
|
+
retry
|
244
|
+
else
|
245
|
+
raise $!
|
246
|
+
end
|
243
247
|
end
|
244
248
|
Log.debug("Attachment of fields:#{Misc.fingerprint fields } from #{other.filename.inspect} finished.")
|
245
249
|
|
@@ -298,7 +298,6 @@ module Misc
|
|
298
298
|
end
|
299
299
|
|
300
300
|
|
301
|
-
#options = Misc.add_defaults options, :respawn => true, :cpus => cpus, :into => Set.new
|
302
301
|
options = Misc.add_defaults options, :respawn => true, :cpus => cpus
|
303
302
|
options = Misc.add_defaults options, :bar => "Bootstrap in #{ options[:cpus] } cpus: #{ Misc.fingerprint Annotated.purge(elems) }"
|
304
303
|
respawn = options[:respawn] and options[:cpus] and options[:cpus].to_i > 1
|
@@ -311,6 +310,7 @@ module Misc
|
|
311
310
|
res = yield elem
|
312
311
|
rescue Interrupt
|
313
312
|
Log.warn "Process #{Process.pid} was aborted"
|
313
|
+
raise $!
|
314
314
|
end
|
315
315
|
res = nil unless options[:into]
|
316
316
|
raise RbbtProcessQueue::RbbtProcessQueueWorker::Respawn, res if respawn == :always and cpus > 1
|
data/lib/rbbt/util/open.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rbbt/tsv'
|
2
|
+
require 'rbbt/persist'
|
3
|
+
module TCCache
|
4
|
+
def self.open(file, type = :single)
|
5
|
+
database = Persist.open_tokyocabinet(file, true, type, "HDB")
|
6
|
+
database.extend TCCache
|
7
|
+
end
|
8
|
+
|
9
|
+
def cache(key)
|
10
|
+
if self.include? key
|
11
|
+
return self[key]
|
12
|
+
else
|
13
|
+
self.write_and_read do
|
14
|
+
self[key] = yield
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -285,6 +285,7 @@ class Step
|
|
285
285
|
|
286
286
|
def produce(force=true)
|
287
287
|
return self if done? and not dirty?
|
288
|
+
|
288
289
|
if error? or aborted?
|
289
290
|
if force
|
290
291
|
clean
|
@@ -292,9 +293,13 @@ class Step
|
|
292
293
|
raise "Error in job: #{status}"
|
293
294
|
end
|
294
295
|
end
|
296
|
+
|
295
297
|
clean if dirty? or not running?
|
298
|
+
|
296
299
|
run(true) unless started?
|
300
|
+
|
297
301
|
join unless done?
|
302
|
+
|
298
303
|
self
|
299
304
|
end
|
300
305
|
|
@@ -7,6 +7,7 @@ require 'rbbt/workflow'
|
|
7
7
|
options = SOPT.get <<EOF
|
8
8
|
-w--workflows* Workflows to use; 'all' for all in Rbbt.etc.workflows:
|
9
9
|
-r--requires* Files to require; 'all' for all in Rbbt.etc.requires:
|
10
|
+
-f--force Force the production if the file is already present
|
10
11
|
-h--help Help
|
11
12
|
EOF
|
12
13
|
|
@@ -41,7 +42,9 @@ end
|
|
41
42
|
|
42
43
|
resource, path = ARGV
|
43
44
|
|
45
|
+
force = options[:force]
|
46
|
+
|
44
47
|
resource = Kernel.const_get(resource)
|
45
48
|
|
46
|
-
puts resource[path].produce.find
|
49
|
+
puts resource[path].produce(force).find
|
47
50
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -263,6 +263,7 @@ files:
|
|
263
263
|
- lib/rbbt/util/simpleopt/setup.rb
|
264
264
|
- lib/rbbt/util/tar.rb
|
265
265
|
- lib/rbbt/util/task/job.rb
|
266
|
+
- lib/rbbt/util/tc_cache.rb
|
266
267
|
- lib/rbbt/util/tmpfile.rb
|
267
268
|
- lib/rbbt/workflow.rb
|
268
269
|
- lib/rbbt/workflow/accessor.rb
|