rbbt-util 6.0.4 → 6.0.5
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 +1 -1
- data/lib/rbbt/hpc/batch.rb +1 -1
- data/lib/rbbt/knowledge_base/enrichment.rb +9 -9
- data/lib/rbbt/knowledge_base/entity.rb +128 -128
- data/lib/rbbt/knowledge_base/query.rb +94 -94
- data/lib/rbbt/knowledge_base/registry.rb +189 -189
- data/lib/rbbt/knowledge_base/syndicate.rb +26 -26
- data/lib/rbbt/knowledge_base/traverse.rb +315 -315
- data/lib/rbbt/knowledge_base.rb +37 -34
- data/lib/rbbt/util/migrate.rb +3 -3
- data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +11 -11
- data/lib/rbbt/workflow/remote_workflow/remote_step.rb +1 -1
- data/lib/rbbt/workflow/remote_workflow.rb +2 -1
- data/lib/rbbt.rb +1 -1
- data/python/rbbt/'/Users/miki/config/tmp/undodir'/%Users%miki%git%rbbt-util%python%rbbt%__init__.py +0 -0
- data/share/rbbt_commands/hpc/list +1 -1
- data/share/rbbt_commands/lsf/list +1 -1
- data/share/rbbt_commands/pbs/list +1 -1
- data/share/rbbt_commands/resource/find +1 -1
- data/share/rbbt_commands/slurm/list +1 -1
- data/share/rbbt_commands/system/status +2 -2
- data/share/rbbt_commands/workflow/info +1 -1
- metadata +4 -3
@@ -1,189 +1,189 @@
|
|
1
|
-
require 'rbbt/association'
|
2
|
-
require 'rbbt/association/item'
|
3
|
-
|
4
|
-
class KnowledgeBase
|
5
|
-
|
6
|
-
def register(name, file = nil, options = {}, &block)
|
7
|
-
if block_given?
|
8
|
-
block.define_singleton_method(:filename) do name.to_s end
|
9
|
-
Log.debug("Registering #{ name } from code block")
|
10
|
-
@registry[name] = [block, options]
|
11
|
-
else
|
12
|
-
Log.debug("Registering #{ name }: #{ Log.fingerprint file } #{Log.fingerprint options}")
|
13
|
-
@registry[name] = [file, options]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def all_databases
|
18
|
-
@registry.keys
|
19
|
-
end
|
20
|
-
|
21
|
-
def fields(name)
|
22
|
-
@fields[name] ||= get_index(name).fields
|
23
|
-
end
|
24
|
-
|
25
|
-
def description(name)
|
26
|
-
@descriptions[name] ||= get_index(name).key_field.split("~")
|
27
|
-
end
|
28
|
-
|
29
|
-
def source(name)
|
30
|
-
description(name)[0]
|
31
|
-
end
|
32
|
-
|
33
|
-
def target(name)
|
34
|
-
description(name)[1]
|
35
|
-
end
|
36
|
-
|
37
|
-
def undirected(name)
|
38
|
-
description(name)[2]
|
39
|
-
end
|
40
|
-
|
41
|
-
def get_index(name, options = {})
|
42
|
-
name = name.to_s
|
43
|
-
options[:namespace] ||= self.namespace unless self.namespace.nil?
|
44
|
-
@indices[[name, options]] ||=
|
45
|
-
begin
|
46
|
-
if options.empty?
|
47
|
-
key = name.to_s
|
48
|
-
elsif options[:key]
|
49
|
-
key = options[:key]
|
50
|
-
key = name if key == :name
|
51
|
-
else
|
52
|
-
fp = Misc.digest(options)
|
53
|
-
key = name.to_s + "_" + fp
|
54
|
-
end
|
55
|
-
|
56
|
-
Persist.memory("Index:" << [key, dir] * "@") do
|
57
|
-
options = options.dup
|
58
|
-
|
59
|
-
persist_dir = dir
|
60
|
-
persist_path = persist_dir[key].find
|
61
|
-
file, registered_options = registry[name]
|
62
|
-
|
63
|
-
options = IndiferentHash.add_defaults options, registered_options if registered_options and registered_options.any?
|
64
|
-
options = IndiferentHash.add_defaults options, :persist_path => persist_path, :persist_dir => persist_dir, :persist => true
|
65
|
-
|
66
|
-
if entity_options
|
67
|
-
options[:entity_options] ||= {}
|
68
|
-
entity_options.each do |type, info|
|
69
|
-
options[:entity_options][type] ||= {}
|
70
|
-
options[:entity_options][type] = IndiferentHash.add_defaults options[:entity_options][type], info
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
persist_options = IndiferentHash.pull_keys options, :persist
|
75
|
-
persist_options = IndiferentHash.add_defaults persist_options, :path => persist_path
|
76
|
-
|
77
|
-
|
78
|
-
index = if persist_path.exists? and persist_options[:persist] and not persist_options[:update]
|
79
|
-
Log.low "Re-opening index #{ name } from #{ Log.fingerprint persist_path }. #{options}"
|
80
|
-
Association.index(file, **options.merge(persist_options: persist_options.dup))
|
81
|
-
else
|
82
|
-
options = IndiferentHash.add_defaults options, registered_options if registered_options
|
83
|
-
raise "Repo #{ name } not found and not registered" if file.nil?
|
84
|
-
Log.medium "Opening index #{ name } from #{ Log.fingerprint file }. #{options}"
|
85
|
-
file = file.call if Proc === file
|
86
|
-
Association.index(file, **options.merge(persist_options: persist_options.dup))
|
87
|
-
end
|
88
|
-
|
89
|
-
index.namespace = self.namespace unless self.namespace
|
90
|
-
|
91
|
-
index
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def get_database(name, options = {})
|
97
|
-
name = name.to_s
|
98
|
-
|
99
|
-
options = options.dup
|
100
|
-
if self.namespace == options[:namespace]
|
101
|
-
options.delete(:namespace)
|
102
|
-
end
|
103
|
-
@databases[[name, options]] ||=
|
104
|
-
begin
|
105
|
-
fp = Log.fingerprint([name,options])
|
106
|
-
|
107
|
-
if options.empty?
|
108
|
-
key = name.to_s
|
109
|
-
else
|
110
|
-
fp = Misc.digest(options)
|
111
|
-
key = name.to_s + "_" + fp
|
112
|
-
end
|
113
|
-
|
114
|
-
options[:namespace] ||= self.namespace unless self.namespace.nil?
|
115
|
-
|
116
|
-
key += '.database'
|
117
|
-
Persist.memory("Database:" << [key, dir] * "@") do
|
118
|
-
options = options.dup
|
119
|
-
|
120
|
-
persist_dir = dir
|
121
|
-
persist_path = persist_dir[key].find
|
122
|
-
file, registered_options = registry[name]
|
123
|
-
|
124
|
-
options = IndiferentHash.add_defaults options, registered_options if registered_options and registered_options.any?
|
125
|
-
options = IndiferentHash.add_defaults options, :persist_path => persist_path, :persist => true
|
126
|
-
|
127
|
-
if entity_options
|
128
|
-
options[:entity_options] ||= {}
|
129
|
-
entity_options.each do |type, info|
|
130
|
-
options[:entity_options][type] ||= {}
|
131
|
-
options[:entity_options][type] = IndiferentHash.add_defaults options[:entity_options][type], info
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
persist_options = IndiferentHash.pull_keys options, :persist
|
136
|
-
|
137
|
-
database = if persist_path.exists? and persist_options[:persist] and not persist_options[:update]
|
138
|
-
Log.low "Re-opening database #{ name } from #{ Log.fingerprint persist_path }. #{options}"
|
139
|
-
Association.database(file, options, persist_options)
|
140
|
-
else
|
141
|
-
options = IndiferentHash.add_defaults options, registered_options if registered_options
|
142
|
-
raise "Repo #{ name } not found and not registered" if file.nil?
|
143
|
-
Log.medium "Opening database #{ name } from #{ Log.fingerprint file }. #{options}"
|
144
|
-
file = file.call if Proc === file
|
145
|
-
Association.database(file, **options)
|
146
|
-
end
|
147
|
-
|
148
|
-
database.namespace = self.namespace if self.namespace
|
149
|
-
|
150
|
-
database
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def index_fields(name)
|
156
|
-
get_index(name).fields
|
157
|
-
end
|
158
|
-
|
159
|
-
def produce(name, *rest,&block)
|
160
|
-
register(name, *rest, &block)
|
161
|
-
get_index(name)
|
162
|
-
end
|
163
|
-
|
164
|
-
def info(name)
|
165
|
-
|
166
|
-
source = self.source(name)
|
167
|
-
target = self.target(name)
|
168
|
-
source_type = self.source_type(name)
|
169
|
-
target_type = self.target_type(name)
|
170
|
-
fields = self.fields(name)
|
171
|
-
source_entity_options = self.entity_options_for source_type, name
|
172
|
-
target_entity_options = self.entity_options_for target_type, name
|
173
|
-
undirected = self.undirected(name) == 'undirected'
|
174
|
-
|
175
|
-
info = {
|
176
|
-
:source => source,
|
177
|
-
:target => target,
|
178
|
-
:source_type => source_type,
|
179
|
-
:target_type => target_type,
|
180
|
-
:source_entity_options => source_entity_options,
|
181
|
-
:target_entity_options => target_entity_options,
|
182
|
-
:fields => fields,
|
183
|
-
:undirected => undirected,
|
184
|
-
}
|
185
|
-
|
186
|
-
info
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
1
|
+
#require 'rbbt/association'
|
2
|
+
#require 'rbbt/association/item'
|
3
|
+
#
|
4
|
+
#class KnowledgeBase
|
5
|
+
#
|
6
|
+
# def register(name, file = nil, options = {}, &block)
|
7
|
+
# if block_given?
|
8
|
+
# block.define_singleton_method(:filename) do name.to_s end
|
9
|
+
# Log.debug("Registering #{ name } from code block")
|
10
|
+
# @registry[name] = [block, options]
|
11
|
+
# else
|
12
|
+
# Log.debug("Registering #{ name }: #{ Log.fingerprint file } #{Log.fingerprint options}")
|
13
|
+
# @registry[name] = [file, options]
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# def all_databases
|
18
|
+
# @registry.keys
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# def fields(name)
|
22
|
+
# @fields[name] ||= get_index(name).fields
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# def description(name)
|
26
|
+
# @descriptions[name] ||= get_index(name).key_field.split("~")
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# def source(name)
|
30
|
+
# description(name)[0]
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# def target(name)
|
34
|
+
# description(name)[1]
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# def undirected(name)
|
38
|
+
# description(name)[2]
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# def get_index(name, options = {})
|
42
|
+
# name = name.to_s
|
43
|
+
# options[:namespace] ||= self.namespace unless self.namespace.nil?
|
44
|
+
# @indices[[name, options]] ||=
|
45
|
+
# begin
|
46
|
+
# if options.empty?
|
47
|
+
# key = name.to_s
|
48
|
+
# elsif options[:key]
|
49
|
+
# key = options[:key]
|
50
|
+
# key = name if key == :name
|
51
|
+
# else
|
52
|
+
# fp = Misc.digest(options)
|
53
|
+
# key = name.to_s + "_" + fp
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# Persist.memory("Index:" << [key, dir] * "@") do
|
57
|
+
# options = options.dup
|
58
|
+
#
|
59
|
+
# persist_dir = dir
|
60
|
+
# persist_path = persist_dir[key].find
|
61
|
+
# file, registered_options = registry[name]
|
62
|
+
#
|
63
|
+
# options = IndiferentHash.add_defaults options, registered_options if registered_options and registered_options.any?
|
64
|
+
# options = IndiferentHash.add_defaults options, :persist_path => persist_path, :persist_dir => persist_dir, :persist => true
|
65
|
+
#
|
66
|
+
# if entity_options
|
67
|
+
# options[:entity_options] ||= {}
|
68
|
+
# entity_options.each do |type, info|
|
69
|
+
# options[:entity_options][type] ||= {}
|
70
|
+
# options[:entity_options][type] = IndiferentHash.add_defaults options[:entity_options][type], info
|
71
|
+
# end
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# persist_options = IndiferentHash.pull_keys options, :persist
|
75
|
+
# persist_options = IndiferentHash.add_defaults persist_options, :path => persist_path
|
76
|
+
#
|
77
|
+
#
|
78
|
+
# index = if persist_path.exists? and persist_options[:persist] and not persist_options[:update]
|
79
|
+
# Log.low "Re-opening index #{ name } from #{ Log.fingerprint persist_path }. #{options}"
|
80
|
+
# Association.index(file, **options.merge(persist_options: persist_options.dup))
|
81
|
+
# else
|
82
|
+
# options = IndiferentHash.add_defaults options, registered_options if registered_options
|
83
|
+
# raise "Repo #{ name } not found and not registered" if file.nil?
|
84
|
+
# Log.medium "Opening index #{ name } from #{ Log.fingerprint file }. #{options}"
|
85
|
+
# file = file.call if Proc === file
|
86
|
+
# Association.index(file, **options.merge(persist_options: persist_options.dup))
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# index.namespace = self.namespace unless self.namespace
|
90
|
+
#
|
91
|
+
# index
|
92
|
+
# end
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
#
|
96
|
+
# def get_database(name, options = {})
|
97
|
+
# name = name.to_s
|
98
|
+
#
|
99
|
+
# options = options.dup
|
100
|
+
# if self.namespace == options[:namespace]
|
101
|
+
# options.delete(:namespace)
|
102
|
+
# end
|
103
|
+
# @databases[[name, options]] ||=
|
104
|
+
# begin
|
105
|
+
# fp = Log.fingerprint([name,options])
|
106
|
+
#
|
107
|
+
# if options.empty?
|
108
|
+
# key = name.to_s
|
109
|
+
# else
|
110
|
+
# fp = Misc.digest(options)
|
111
|
+
# key = name.to_s + "_" + fp
|
112
|
+
# end
|
113
|
+
#
|
114
|
+
# options[:namespace] ||= self.namespace unless self.namespace.nil?
|
115
|
+
#
|
116
|
+
# key += '.database'
|
117
|
+
# Persist.memory("Database:" << [key, dir] * "@") do
|
118
|
+
# options = options.dup
|
119
|
+
#
|
120
|
+
# persist_dir = dir
|
121
|
+
# persist_path = persist_dir[key].find
|
122
|
+
# file, registered_options = registry[name]
|
123
|
+
#
|
124
|
+
# options = IndiferentHash.add_defaults options, registered_options if registered_options and registered_options.any?
|
125
|
+
# options = IndiferentHash.add_defaults options, :persist_path => persist_path, :persist => true
|
126
|
+
#
|
127
|
+
# if entity_options
|
128
|
+
# options[:entity_options] ||= {}
|
129
|
+
# entity_options.each do |type, info|
|
130
|
+
# options[:entity_options][type] ||= {}
|
131
|
+
# options[:entity_options][type] = IndiferentHash.add_defaults options[:entity_options][type], info
|
132
|
+
# end
|
133
|
+
# end
|
134
|
+
#
|
135
|
+
# persist_options = IndiferentHash.pull_keys options, :persist
|
136
|
+
#
|
137
|
+
# database = if persist_path.exists? and persist_options[:persist] and not persist_options[:update]
|
138
|
+
# Log.low "Re-opening database #{ name } from #{ Log.fingerprint persist_path }. #{options}"
|
139
|
+
# Association.database(file, options, persist_options)
|
140
|
+
# else
|
141
|
+
# options = IndiferentHash.add_defaults options, registered_options if registered_options
|
142
|
+
# raise "Repo #{ name } not found and not registered" if file.nil?
|
143
|
+
# Log.medium "Opening database #{ name } from #{ Log.fingerprint file }. #{options}"
|
144
|
+
# file = file.call if Proc === file
|
145
|
+
# Association.database(file, **options)
|
146
|
+
# end
|
147
|
+
#
|
148
|
+
# database.namespace = self.namespace if self.namespace
|
149
|
+
#
|
150
|
+
# database
|
151
|
+
# end
|
152
|
+
# end
|
153
|
+
# end
|
154
|
+
#
|
155
|
+
# def index_fields(name)
|
156
|
+
# get_index(name).fields
|
157
|
+
# end
|
158
|
+
#
|
159
|
+
# def produce(name, *rest,&block)
|
160
|
+
# register(name, *rest, &block)
|
161
|
+
# get_index(name)
|
162
|
+
# end
|
163
|
+
#
|
164
|
+
# def info(name)
|
165
|
+
#
|
166
|
+
# source = self.source(name)
|
167
|
+
# target = self.target(name)
|
168
|
+
# source_type = self.source_type(name)
|
169
|
+
# target_type = self.target_type(name)
|
170
|
+
# fields = self.fields(name)
|
171
|
+
# source_entity_options = self.entity_options_for source_type, name
|
172
|
+
# target_entity_options = self.entity_options_for target_type, name
|
173
|
+
# undirected = self.undirected(name) == 'undirected'
|
174
|
+
#
|
175
|
+
# info = {
|
176
|
+
# :source => source,
|
177
|
+
# :target => target,
|
178
|
+
# :source_type => source_type,
|
179
|
+
# :target_type => target_type,
|
180
|
+
# :source_entity_options => source_entity_options,
|
181
|
+
# :target_entity_options => target_entity_options,
|
182
|
+
# :fields => fields,
|
183
|
+
# :undirected => undirected,
|
184
|
+
# }
|
185
|
+
#
|
186
|
+
# info
|
187
|
+
# end
|
188
|
+
#
|
189
|
+
#end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
class KnowledgeBase
|
2
|
-
def syndicate(name, kb)
|
3
|
-
kb.all_databases.each do |database|
|
4
|
-
if name.nil?
|
5
|
-
db_name = database
|
6
|
-
else
|
7
|
-
db_name = [database, name] * "@"
|
8
|
-
end
|
9
|
-
file, kb_options = kb.registry[database]
|
10
|
-
options = {}
|
11
|
-
options[:entity_options] = kb_options[:entity_options]
|
12
|
-
options[:undirected] = kb_options[:undirected] if kb_options
|
13
|
-
if kb.entity_options
|
14
|
-
options[:entity_options] = kb.entity_options.merge(options[:entity_options] || {})
|
15
|
-
end
|
16
|
-
|
17
|
-
register(db_name, nil, options) do
|
18
|
-
kb.get_database(database)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def all_databases
|
24
|
-
@registry.keys
|
25
|
-
end
|
26
|
-
end
|
1
|
+
#class KnowledgeBase
|
2
|
+
# def syndicate(name, kb)
|
3
|
+
# kb.all_databases.each do |database|
|
4
|
+
# if name.nil?
|
5
|
+
# db_name = database
|
6
|
+
# else
|
7
|
+
# db_name = [database, name] * "@"
|
8
|
+
# end
|
9
|
+
# file, kb_options = kb.registry[database]
|
10
|
+
# options = {}
|
11
|
+
# options[:entity_options] = kb_options[:entity_options]
|
12
|
+
# options[:undirected] = kb_options[:undirected] if kb_options
|
13
|
+
# if kb.entity_options
|
14
|
+
# options[:entity_options] = kb.entity_options.merge(options[:entity_options] || {})
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# register(db_name, nil, options) do
|
18
|
+
# kb.get_database(database)
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# def all_databases
|
24
|
+
# @registry.keys
|
25
|
+
# end
|
26
|
+
#end
|