rbbt-util 5.5.59 → 5.5.60

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2JmMzk4OWUzYjZkNTE2NTZkODI4NzQ3OGNmZTA3YTg0Y2NmMTMyMg==
4
+ NTllNjc1OWUxMDdmZmNhMzYyZmMyODU5YTczNzBmOWJkMDg1MTRlMQ==
5
5
  data.tar.gz: !binary |-
6
- NDNlMTU0Y2JhMjcwMzlmYjkwMmY0NWU0OGJmODVlZDRmODdkZjVkZg==
6
+ ZTFhYjMxOTg0ZmUwMzBiZDRkMGRlYzU1YzcxNjMyOGMxOTQ1MDdjYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmI5ZGEyN2M4YjE0Mjg0YzVmMTM4NTk0NzhkZDJiODE1MTE5Zjk0NjQyM2Yy
10
- MmY5MDIyNzRiMTJhMGI1OTM1MGFiZThmZDI1M2IyMDc2OGQ4OGRhMjVhNTEz
11
- NWViMGU3MTlkMDA3N2QwNWVlNGEyNmQxNWM3ZWY4ZDA0ZmY1Yzc=
9
+ OWVkOWNhMzlmM2MzOGM5ZjI1MzEyZDZkMzViYjNjMTI0MDVhZDFkZjgzZDEx
10
+ ZGZmOWI2MDc0ZjQyMWU4ZGU2MmViNTU0ZWVjOWEzZDdhOGQyNDk2NTk4Yjcz
11
+ ZjJlZTkxZWYwYjk5MjhhMGM5MDBlZDk0ZmZkZmY3NDI0ZDA5NGM=
12
12
  data.tar.gz: !binary |-
13
- NGNkMWM5OTFkY2ZiZTQyMDY1ZDhjZDFmMTM0YjQ2YTAwNGJhMTU5ZjM5ZWUy
14
- YzBmMjM2ZjRjMTFkMTEwMDg0NmU2Mjk5MmY2NmFhNzMwMGNmNTUzOTljZmEx
15
- ZjhkODIwN2Y4YzJiMDMxODVlZWZiZTIxMjcwOGZiMTM5MmU0MDQ=
13
+ NGRkZmJlZDg0ZmRlNTcxZDdjM2FlYTE0MTFkODc5NGUxZGJjMDIwNzczNjc1
14
+ ZjM5YjUxZTEzMGZiNmYxNjY4NGEyMWFiMTY4YjMzYmIwNGU1MzIwZDhlMDc4
15
+ MjVmN2Y3NzRiYTU2YzA0M2Q3ODFjN2JhNGM3Mzk2MzVhYWZlNTg=
data/etc/app.d/base.rb CHANGED
@@ -25,6 +25,8 @@ use Rack::Session::Cookie, :key => 'rack.session',
25
25
  #{{{ DIRECTORIES
26
26
  local_var = Rbbt.var.find(:current)
27
27
  set :cache_dir , local_var.sinatra.cache.find
28
+ set :persist_dir , local_var.sinatra.cache.persistence.find
29
+ set :persist_options , {:persist => true, :persist_dir => :persist_dir}
28
30
  set :file_dir , local_var.sinatra.files.find
29
31
  set :permalink_dir , local_var.sinatra.permalink.find
30
32
  set :favourites_dir , local_var.sinatra.favourites.find
@@ -70,7 +70,6 @@ class KnowledgeBase
70
70
  @registry.keys
71
71
  end
72
72
 
73
-
74
73
  def description(name)
75
74
  @descriptions[name] ||= get_index(name).key_field.split("~")
76
75
  end
@@ -114,41 +113,45 @@ class KnowledgeBase
114
113
  end
115
114
 
116
115
  def get_database(name, options = {})
117
- options = Misc.add_defaults options, :persist_dir => dir.databases
118
- persist_options = Misc.pull_keys options, :persist
119
-
120
- file, registered_options = registry[name]
121
- options = open_options.merge(registered_options || {}).merge(options)
122
- raise "Repo #{ name } not found and not registered" if file.nil?
123
-
124
- code = [name, Misc.hash2md5(options)] * "_"
125
- @databases[code] ||= begin
126
- Log.low "Opening database #{ name } from #{ Misc.fingerprint file }. #{options}"
127
- Association.open(file, options, persist_options).
128
- tap{|tsv| tsv.namespace = self.namespace}
129
- end
116
+ @databases[Misc.fingerprint([name, options])] ||= \
117
+ begin
118
+ Persist.memory("Database:" <<[name, self.dir] * "@") do
119
+ options = Misc.add_defaults options, :persist_dir => dir.databases
120
+ persist_options = Misc.pull_keys options, :persist
121
+
122
+ file, registered_options = registry[name]
123
+ options = open_options.merge(registered_options || {}).merge(options)
124
+ raise "Repo #{ name } not found and not registered" if file.nil?
125
+
126
+ Log.low "Opening database #{ name } from #{ Misc.fingerprint file }. #{options}"
127
+ Association.open(file, options, persist_options).
128
+ tap{|tsv| tsv.namespace = self.namespace}
129
+ end
130
+ end
130
131
  end
131
132
 
132
-
133
- def get_index(name, options = {})
134
- options = Misc.add_defaults options, :persist_dir => dir.indices
135
- persist_options = Misc.pull_keys options, :persist
136
-
137
- file, registered_options = registry[name]
138
- options = open_options.merge(registered_options || {}).merge(options)
139
- raise "Repo #{ name } not found and not registered" if file.nil?
140
133
 
141
- code = [name, Misc.hash2md5(options)] * "_"
142
- @indices[code] ||= begin
143
- Log.low "Opening index #{ name } from #{ Misc.fingerprint file }. #{options}"
144
- Association.index(file, options, persist_options).
145
- tap{|tsv| tsv.namespace = self.namespace}
146
- end
134
+ def get_index(name, options = {})
135
+ @indices[Misc.fingerprint([name, options])] ||= \
136
+ begin
137
+ Persist.memory("Index:" <<[name, self.dir] * "@") do
138
+ options = Misc.add_defaults options, :persist_dir => dir.indices
139
+ persist_options = Misc.pull_keys options, :persist
140
+
141
+ file, registered_options = registry[name]
142
+ options = open_options.merge(registered_options || {}).merge(options)
143
+ raise "Repo #{ name } not found and not registered" if file.nil?
144
+
145
+ Log.low "Opening index #{ name } from #{ Misc.fingerprint file }. #{options}"
146
+ Association.index(file, options, persist_options).
147
+ tap{|tsv| tsv.namespace = self.namespace}
148
+ end
149
+ end
147
150
  end
148
151
 
149
- def index(name, file, options = {}, persist_options = {})
150
- @indices[name] = Association.index(file, open_options.merge(options), persist_options)
151
- end
152
+ #def index(name, file, options = {}, persist_options = {})
153
+ # @indices[name] = Association.index(file, open_options.merge(options), persist_options)
154
+ #end
152
155
 
153
156
  #{{{ Add manual database
154
157
 
data/lib/rbbt/persist.rb CHANGED
@@ -54,9 +54,9 @@ module Persist
54
54
  prefix = Misc.process_options persist_options, :prefix
55
55
 
56
56
  if prefix.nil?
57
- perfile = file.gsub(/\//, '>')
57
+ perfile = file.to_s.gsub(/\//, '>')
58
58
  else
59
- perfile = prefix.to_s + ":" + file.gsub(/\//, '>')
59
+ perfile = prefix.to_s + ":" + file.to_s.gsub(/\//, '>')
60
60
  end
61
61
 
62
62
  if options.include? :filters
@@ -291,6 +291,14 @@ module Persist
291
291
  yield
292
292
  end
293
293
  end
294
+
295
+ def self.memory(name, options = {}, &block)
296
+ file = name
297
+ file << "_" << Misc.hash2md5(options) if options.any?
298
+ options = Misc.add_defaults options, :persist => true, :file => file
299
+
300
+ persist name, :memory, options, &block
301
+ end
294
302
  end
295
303
 
296
304
  module LocalPersist
data/lib/rbbt/util/cmd.rb CHANGED
@@ -71,7 +71,7 @@ module CMD
71
71
 
72
72
  self.close if self.eof? and not self.closed?
73
73
 
74
- data
74
+ data || ""
75
75
  end
76
76
  end
77
77
 
data/lib/rbbt/util/log.rb CHANGED
@@ -27,6 +27,10 @@ module Log
27
27
 
28
28
  HIGHLIGHT = "\033[1m"
29
29
 
30
+ def self.color(severity)
31
+ SEVERITY_COLOR[severity]
32
+ end
33
+
30
34
  def self.log(message = nil, severity = MEDIUM, &block)
31
35
  return if severity < self.severity
32
36
  message ||= block.call if block_given?
@@ -35,7 +39,10 @@ module Log
35
39
  severity_color = SEVERITY_COLOR[severity]
36
40
  time = Time.now.strftime("%m/%d/%y-%H:%M:%S")
37
41
 
38
- prefix = time << "[" << severity_color << severity.to_s << SEVERITY_COLOR[0] << "]"
42
+ sev_str = severity.to_s
43
+ sev_str = "" << HIGHLIGHT << sev_str << SEVERITY_COLOR[0] if severity >= INFO
44
+
45
+ prefix = time << "[" << severity_color << sev_str << SEVERITY_COLOR[0] << "]"
39
46
  message = "" << HIGHLIGHT << message << SEVERITY_COLOR[0] if severity >= INFO
40
47
  str = prefix << " " << message
41
48
 
@@ -240,6 +240,8 @@ module Misc
240
240
  end
241
241
 
242
242
  def self.fingerprint(obj)
243
+ #DEBUG
244
+ return "nil" if obj.nil?
243
245
  case obj
244
246
  when nil
245
247
  "nil"
@@ -251,6 +253,8 @@ module Misc
251
253
  else
252
254
  "'" << obj << "'"
253
255
  end
256
+ when AnnotatedArray
257
+ "<E: #{fingerprint Annotated.purge(obj)} #{fingerprint obj.info}>"
254
258
  when Array
255
259
  if (length = obj.length) > 10
256
260
  "[#{length} --" << (obj.values_at(0,1, length / 2, -2, -1).collect{|e| fingerprint(e)} * ",") << "]"
data/lib/rbbt/workflow.rb CHANGED
@@ -17,7 +17,7 @@ module Workflow
17
17
  end
18
18
  def self.extended(base)
19
19
  self.workflows << base
20
- base.libdir = Path.caller_lib_dir.tap{|p| p.resource = base}
20
+ base.libdir = Path.setup(Path.caller_lib_dir).tap{|p| p.resource = base}
21
21
  end
22
22
 
23
23
  def self.require_remote_workflow(wf_name, url)
data/share/config.ru CHANGED
@@ -1,41 +1,49 @@
1
1
  require 'rbbt'
2
2
  require 'rbbt/resource'
3
+ $LOAD_PATH.unshift('lib') unless $LOAD_PATH.include?('lib')
3
4
 
4
- load Rbbt.etc['app.d/init.rb'].find
5
+ def load_file(file)
6
+ if file.exists?
7
+ Log.info("Loading: " << file)
8
+ load file
9
+ end
10
+ end
5
11
 
6
- $class_name = class_name = File.basename(FileUtils.pwd)
12
+ def app_eval(app, file)
13
+ if file.exists?
14
+ app.class_eval do
15
+ Log.info("Loading: " << file)
16
+ eval file.read, nil, file
17
+ end
18
+ end
19
+ end
7
20
 
8
- $app = app = eval "class #{class_name} < Sinatra::Base; self end"
21
+ #{{{ INIT
22
+ load_file Rbbt.etc['app.d/init.rb'].find
9
23
 
10
- $LOAD_PATH.unshift('lib')
24
+ $class_name = class_name = File.basename(FileUtils.pwd)
25
+ $app = app = eval "class #{class_name} < Sinatra::Base; self end"
11
26
 
12
27
  #{{{ PRE
13
- Log.info{"Loading: " << Rbbt.etc['app.d/pre.rb'].find if Rbbt.etc['app.d/pre.rb'].exists?}
14
- load Rbbt.etc['app.d/pre.rb'].find if Rbbt.etc['app.d/pre.rb'].exists?
28
+ load_file Rbbt.etc['app.d/pre.rb'].find
15
29
 
16
30
  #{{{ BASE
17
- app.class_eval do
18
- Log.info{"Loading: " << Rbbt.etc['app.d/base.rb'].find}
19
- eval Rbbt.etc['app.d/base.rb'].read, nil, Rbbt.etc['app.d/base.rb'].find
20
- end
31
+ app_eval app, Rbbt.etc['app.d/base.rb'].find
21
32
 
22
33
  #{{{ RESOURCES
23
- Log.info{"Loading: " << Rbbt.etc['app.d/resources.rb'].find}
24
- load Rbbt.etc['app.d/resources.rb'].find
34
+ load_file Rbbt.etc['app.d/resources.rb'].find
25
35
 
26
36
  #{{{ ENTITIES
27
- Log.info{"Loading: " << Rbbt.etc['app.d/entities.rb'].find}
28
- load Rbbt.etc['app.d/entities.rb'].find
37
+ load_file Rbbt.etc['app.d/entities.rb'].find
29
38
 
30
39
  #{{{ FINDER
31
- app.class_eval do
32
- Log.info{"Loading: " << Rbbt.etc['app.d/finder.rb'].find}
33
- eval Rbbt.etc['app.d/finder.rb'].read
34
- end
40
+ app_eval app, Rbbt.etc['app.d/finder.rb'].find
35
41
 
36
42
  #{{{ POST
37
- Log.info{"Loading: " << Rbbt.etc['app.d/post.rb'].find if Rbbt.etc['app.d/post.rb'].exists?}
38
- load Rbbt.etc['app.d/post.rb'].find if Rbbt.etc['app.d/post.rb'].exists?
43
+ load_file Rbbt.etc['app.d/post.rb'].find if Rbbt.etc['app.d/post.rb'].exists?
44
+
45
+ #{{{ PRELOAD
46
+ load_file Rbbt.etc['app.d/preload.rb'].find if Rbbt.etc['app.d/preload.rb'].exists?
39
47
 
40
48
  #{{{ RUN
41
49
  $title = class_name
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ options = SOPT.get("-a--app*")
4
+
5
+
6
+ CMD.cmd("rbbt workflow monitor --quick -c -a -d #{Rbbt.var.jobs.find}").read
7
+ CMD.cmd("rm -f #{ Rbbt.tmp.tsv_open_locks.find.glob("*").collect{|f| "'#{f}'" } * " " }").read
8
+ CMD.cmd("find #{Rbbt.share.find_all.collect{|f| "'#{f}'" } * " " } -name '*.lock' -delete").read
9
+ CMD.cmd("find #{Rbbt.var.find_all.collect{|f| "'#{f}'" } * " " } -name '*.lock' -delete").read
10
+
11
+ app_dir = Rbbt.etc.app_dir.exists? ? Rbbt.etc.app_dir.read.strip : Rbbt.apps.find
12
+ Path.setup(app_dir)
13
+
14
+ options[:app].split(/,|\s/).collect do |app|
15
+ d = app_dir[app].var.sinatra.cache.find
16
+ CMD.cmd("rbbt workflow monitor --quick -c -a -d #{d}").read
17
+ end if options[:app]
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ options = SOPT.get("-a--app*")
4
+
5
+ workflow_dir = Rbbt.var.jobs.find
6
+
7
+ def report_jobs(workflow_dir, title = "WORKFLOW")
8
+ error = {}
9
+ running = {}
10
+ dead = {}
11
+ CMD.cmd("rbbt workflow monitor --quick -d '#{workflow_dir}'").read.split("\n").each do |line|
12
+ parts = line.split("/")
13
+ workflow, task, rest = parts[-3], parts[-2], parts[-1]
14
+ code = workflow.nil? ? nil : [workflow, task] * ":"
15
+ case
16
+ when rest =~ /error/
17
+ error[code] ||= 0
18
+ error[code] += 1
19
+ when rest =~ /dead/
20
+ dead[code] ||= 0
21
+ dead[code] += 1
22
+ when rest =~ /running/
23
+ running[code] ||= 0
24
+ running[code] += 1
25
+ when rest =~ /aborted/
26
+ dead[code] ||= 0
27
+ dead[code] += 1
28
+ else
29
+ raise rest
30
+ end
31
+ end
32
+
33
+ <<-EOF
34
+ # #{title} JOBS
35
+ Running jobs: #{ running.sort_by{|code,c| c}.reverse.collect{|code,c| [code, c].compact * " " } * ", " }
36
+ Dead/aborted jobs: #{ dead.sort_by{|code,c| c}.reverse.collect{|code,c| [code, c].compact * " " } * ", " }#{Log.color(0)}
37
+ Error jobs: #{ error.sort_by{|code,c| c}.reverse.collect{|code,c| [code, c].compact * " " } * ", " }#{Log.color(0)}
38
+ EOF
39
+ end
40
+
41
+ app_dir = Rbbt.etc.app_dir.exists? ? Rbbt.etc.app_dir.read.strip : Rbbt.apps.find
42
+ Path.setup(app_dir)
43
+
44
+ app_dirs = {}
45
+ options[:app].split(/,|\s/).collect do |app|
46
+ d = app_dir[app].var.sinatra.cache.find
47
+ report = report_jobs d, app
48
+ app_dirs[app] = report
49
+ end if options[:app]
50
+
51
+ puts <<EOF
52
+
53
+ #{ report_jobs Rbbt.var.jobs.find}
54
+ #{ app_dirs.collect{|d,report| report } * "\n" }
55
+
56
+ # LOCKED TSV
57
+ #{ Rbbt.var.tsv_open_locks.glob('*').collect{|f| "- " << File.basename(f) } * "\n" }
58
+
59
+ # LOCKS
60
+ #{ CMD.cmd("find #{Rbbt.share.find_all.collect{|f| "'#{f}'" } * " " } -name '*.lock'").read << CMD.cmd("find #{Rbbt.var.find_all.collect{|f| "'#{f}'" } * " " } -name '*.lock'").read }
61
+
62
+ # PERSIST
63
+ #{ CMD.cmd("find #{Rbbt.share.find_all.collect{|f| "'#{f}'" } * " " } -name '*.persist'").read << CMD.cmd("find #{Rbbt.var.find_all.collect{|f| "'#{f}'" } * " " } -name '*.persist'").read }
64
+ EOF
65
+
66
+
67
+
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.5.59
4
+ version: 5.5.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-29 00:00:00.000000000 Z
11
+ date: 2013-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -219,6 +219,8 @@ files:
219
219
  - share/rbbt_commands/resource/get
220
220
  - share/rbbt_commands/resource/produce
221
221
  - share/rbbt_commands/study/task
222
+ - share/rbbt_commands/system/purge
223
+ - share/rbbt_commands/system/report
222
224
  - share/rbbt_commands/tsv/attach
223
225
  - share/rbbt_commands/tsv/change_id
224
226
  - share/rbbt_commands/tsv/get
@@ -291,37 +293,37 @@ signing_key:
291
293
  specification_version: 4
292
294
  summary: Utilities for the Ruby Bioinformatics Toolkit (rbbt)
293
295
  test_files:
294
- - test/rbbt/tsv/test_accessor.rb
295
- - test/rbbt/tsv/test_index.rb
296
- - test/rbbt/tsv/test_util.rb
297
- - test/rbbt/tsv/test_filter.rb
298
- - test/rbbt/tsv/test_attach.rb
299
- - test/rbbt/tsv/test_manipulate.rb
300
- - test/rbbt/tsv/test_change_id.rb
301
- - test/rbbt/test_fix_width_table.rb
302
- - test/rbbt/association/test_index.rb
303
- - test/rbbt/association/test_item.rb
304
- - test/rbbt/test_association.rb
305
296
  - test/rbbt/test_workflow.rb
306
- - test/rbbt/workflow/test_step.rb
307
- - test/rbbt/workflow/test_task.rb
308
- - test/rbbt/workflow/test_soap.rb
309
297
  - test/rbbt/resource/test_path.rb
310
- - test/rbbt/test_tsv.rb
298
+ - test/rbbt/util/test_cmd.rb
299
+ - test/rbbt/util/test_chain_methods.rb
300
+ - test/rbbt/util/test_simpleDSL.rb
301
+ - test/rbbt/util/test_open.rb
302
+ - test/rbbt/util/test_R.rb
303
+ - test/rbbt/util/test_colorize.rb
304
+ - test/rbbt/util/test_simpleopt.rb
305
+ - test/rbbt/util/test_excel2tsv.rb
306
+ - test/rbbt/util/test_filecache.rb
307
+ - test/rbbt/util/test_misc.rb
308
+ - test/rbbt/util/test_tmpfile.rb
309
+ - test/rbbt/test_association.rb
311
310
  - test/rbbt/test_resource.rb
312
- - test/rbbt/test_annotations.rb
313
311
  - test/rbbt/test_entity.rb
314
312
  - test/rbbt/test_knowledge_base.rb
313
+ - test/rbbt/association/test_index.rb
314
+ - test/rbbt/association/test_item.rb
315
+ - test/rbbt/test_tsv.rb
316
+ - test/rbbt/workflow/test_soap.rb
317
+ - test/rbbt/workflow/test_task.rb
318
+ - test/rbbt/workflow/test_step.rb
315
319
  - test/rbbt/test_persist.rb
316
- - test/rbbt/util/test_filecache.rb
317
- - test/rbbt/util/test_tmpfile.rb
318
- - test/rbbt/util/test_excel2tsv.rb
319
- - test/rbbt/util/test_simpleopt.rb
320
- - test/rbbt/util/test_colorize.rb
321
- - test/rbbt/util/test_misc.rb
322
- - test/rbbt/util/test_open.rb
323
- - test/rbbt/util/test_cmd.rb
324
- - test/rbbt/util/test_chain_methods.rb
325
- - test/rbbt/util/test_R.rb
326
- - test/rbbt/util/test_simpleDSL.rb
320
+ - test/rbbt/test_annotations.rb
321
+ - test/rbbt/tsv/test_index.rb
322
+ - test/rbbt/tsv/test_change_id.rb
323
+ - test/rbbt/tsv/test_util.rb
324
+ - test/rbbt/tsv/test_accessor.rb
325
+ - test/rbbt/tsv/test_filter.rb
326
+ - test/rbbt/tsv/test_attach.rb
327
+ - test/rbbt/tsv/test_manipulate.rb
328
+ - test/rbbt/test_fix_width_table.rb
327
329
  - test/test_helper.rb