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.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/bin/rbbt +67 -90
  4. data/bin/rbbt_exec.rb +2 -2
  5. data/etc/app.d/base.rb +2 -2
  6. data/etc/app.d/semaphores.rb +3 -3
  7. data/lib/rbbt/annotations/annotated_array.rb +207 -207
  8. data/lib/rbbt/annotations/refactor.rb +27 -0
  9. data/lib/rbbt/annotations/util.rb +282 -282
  10. data/lib/rbbt/annotations.rb +343 -320
  11. data/lib/rbbt/association/database.rb +200 -225
  12. data/lib/rbbt/association/index.rb +294 -291
  13. data/lib/rbbt/association/item.rb +227 -227
  14. data/lib/rbbt/association/open.rb +35 -34
  15. data/lib/rbbt/association/util.rb +0 -169
  16. data/lib/rbbt/association.rb +2 -4
  17. data/lib/rbbt/entity/identifiers.rb +119 -118
  18. data/lib/rbbt/entity/refactor.rb +12 -0
  19. data/lib/rbbt/entity.rb +319 -315
  20. data/lib/rbbt/hpc/batch.rb +72 -53
  21. data/lib/rbbt/hpc/lsf.rb +2 -2
  22. data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
  23. data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
  24. data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
  25. data/lib/rbbt/hpc/orchestrate.rb +19 -13
  26. data/lib/rbbt/hpc/slurm.rb +18 -18
  27. data/lib/rbbt/knowledge_base/entity.rb +13 -5
  28. data/lib/rbbt/knowledge_base/query.rb +2 -2
  29. data/lib/rbbt/knowledge_base/registry.rb +32 -31
  30. data/lib/rbbt/knowledge_base/traverse.rb +1 -1
  31. data/lib/rbbt/knowledge_base.rb +1 -1
  32. data/lib/rbbt/monitor.rb +36 -25
  33. data/lib/rbbt/persist/refactor.rb +166 -0
  34. data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
  35. data/lib/rbbt/persist/tsv.rb +187 -185
  36. data/lib/rbbt/persist.rb +556 -551
  37. data/lib/rbbt/refactor.rb +20 -0
  38. data/lib/rbbt/resource/path/refactor.rb +178 -0
  39. data/lib/rbbt/resource/path.rb +317 -497
  40. data/lib/rbbt/resource/util.rb +0 -48
  41. data/lib/rbbt/resource.rb +3 -390
  42. data/lib/rbbt/tsv/accessor.rb +2 -838
  43. data/lib/rbbt/tsv/attach.rb +303 -299
  44. data/lib/rbbt/tsv/change_id.rb +244 -245
  45. data/lib/rbbt/tsv/csv.rb +87 -85
  46. data/lib/rbbt/tsv/dumper.rb +2 -100
  47. data/lib/rbbt/tsv/excel.rb +26 -24
  48. data/lib/rbbt/tsv/field_index.rb +4 -1
  49. data/lib/rbbt/tsv/filter.rb +3 -2
  50. data/lib/rbbt/tsv/index.rb +2 -284
  51. data/lib/rbbt/tsv/manipulate.rb +750 -747
  52. data/lib/rbbt/tsv/marshal.rb +3 -3
  53. data/lib/rbbt/tsv/matrix.rb +2 -2
  54. data/lib/rbbt/tsv/parallel/through.rb +2 -1
  55. data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
  56. data/lib/rbbt/tsv/parser.rb +678 -678
  57. data/lib/rbbt/tsv/refactor.rb +195 -0
  58. data/lib/rbbt/tsv/stream.rb +253 -251
  59. data/lib/rbbt/tsv/util.rb +420 -420
  60. data/lib/rbbt/tsv.rb +210 -208
  61. data/lib/rbbt/util/R/eval.rb +4 -4
  62. data/lib/rbbt/util/R/plot.rb +62 -166
  63. data/lib/rbbt/util/R.rb +21 -18
  64. data/lib/rbbt/util/cmd.rb +2 -318
  65. data/lib/rbbt/util/color.rb +269 -269
  66. data/lib/rbbt/util/colorize.rb +89 -89
  67. data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
  68. data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
  69. data/lib/rbbt/util/concurrency/processes.rb +389 -386
  70. data/lib/rbbt/util/config.rb +169 -167
  71. data/lib/rbbt/util/filecache.rb +1 -1
  72. data/lib/rbbt/util/iruby.rb +20 -0
  73. data/lib/rbbt/util/log/progress/report.rb +241 -241
  74. data/lib/rbbt/util/log/progress/util.rb +99 -99
  75. data/lib/rbbt/util/log/progress.rb +102 -102
  76. data/lib/rbbt/util/log/refactor.rb +49 -0
  77. data/lib/rbbt/util/log.rb +486 -532
  78. data/lib/rbbt/util/migrate.rb +2 -2
  79. data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
  80. data/lib/rbbt/util/misc/development.rb +12 -11
  81. data/lib/rbbt/util/misc/exceptions.rb +117 -112
  82. data/lib/rbbt/util/misc/format.rb +2 -230
  83. data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
  84. data/lib/rbbt/util/misc/inspect.rb +2 -476
  85. data/lib/rbbt/util/misc/lock.rb +109 -106
  86. data/lib/rbbt/util/misc/omics.rb +9 -1
  87. data/lib/rbbt/util/misc/pipes.rb +765 -793
  88. data/lib/rbbt/util/misc/refactor.rb +20 -0
  89. data/lib/rbbt/util/misc/ssw.rb +27 -17
  90. data/lib/rbbt/util/misc/system.rb +92 -105
  91. data/lib/rbbt/util/misc.rb +39 -20
  92. data/lib/rbbt/util/named_array/refactor.rb +4 -0
  93. data/lib/rbbt/util/named_array.rb +3 -220
  94. data/lib/rbbt/util/open/refactor.rb +7 -0
  95. data/lib/rbbt/util/open.rb +3 -857
  96. data/lib/rbbt/util/procpath.rb +6 -6
  97. data/lib/rbbt/util/python/paths.rb +27 -0
  98. data/lib/rbbt/util/python/run.rb +115 -0
  99. data/lib/rbbt/util/python/script.rb +110 -0
  100. data/lib/rbbt/util/python/util.rb +3 -3
  101. data/lib/rbbt/util/python.rb +22 -81
  102. data/lib/rbbt/util/semaphore.rb +152 -148
  103. data/lib/rbbt/util/simpleopt.rb +9 -8
  104. data/lib/rbbt/util/ssh/refactor.rb +19 -0
  105. data/lib/rbbt/util/ssh.rb +122 -118
  106. data/lib/rbbt/util/tar.rb +117 -115
  107. data/lib/rbbt/util/tmpfile.rb +69 -67
  108. data/lib/rbbt/util/version.rb +2 -0
  109. data/lib/rbbt/workflow/refactor/entity.rb +11 -0
  110. data/lib/rbbt/workflow/refactor/export.rb +66 -0
  111. data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
  112. data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
  113. data/lib/rbbt/workflow/refactor/task_info.rb +66 -0
  114. data/lib/rbbt/workflow/refactor.rb +150 -0
  115. data/lib/rbbt/workflow/remote_workflow/driver/rest.rb +1 -2
  116. data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
  117. data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
  118. data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
  119. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
  120. data/lib/rbbt/workflow/remote_workflow.rb +6 -1
  121. data/lib/rbbt/workflow/step/run.rb +766 -766
  122. data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
  123. data/lib/rbbt/workflow/step.rb +2 -362
  124. data/lib/rbbt/workflow/task.rb +118 -118
  125. data/lib/rbbt/workflow/usage.rb +289 -287
  126. data/lib/rbbt/workflow/util/archive.rb +6 -5
  127. data/lib/rbbt/workflow/util/data.rb +1 -1
  128. data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
  129. data/lib/rbbt/workflow/util/trace.rb +79 -44
  130. data/lib/rbbt/workflow.rb +4 -882
  131. data/lib/rbbt-util.rb +21 -13
  132. data/lib/rbbt.rb +16 -3
  133. data/python/rbbt/__init__.py +96 -4
  134. data/python/rbbt/workflow/remote.py +104 -0
  135. data/python/rbbt/workflow.py +64 -0
  136. data/python/test.py +10 -0
  137. data/share/Rlib/plot.R +37 -37
  138. data/share/Rlib/svg.R +22 -5
  139. data/share/install/software/lib/install_helpers +1 -1
  140. data/share/rbbt_commands/hpc/list +2 -3
  141. data/share/rbbt_commands/hpc/orchestrate +4 -4
  142. data/share/rbbt_commands/hpc/tail +2 -0
  143. data/share/rbbt_commands/hpc/task +10 -7
  144. data/share/rbbt_commands/lsf/list +2 -3
  145. data/share/rbbt_commands/lsf/orchestrate +4 -4
  146. data/share/rbbt_commands/lsf/tail +2 -0
  147. data/share/rbbt_commands/lsf/task +10 -7
  148. data/share/rbbt_commands/migrate +1 -1
  149. data/share/rbbt_commands/pbs/list +2 -3
  150. data/share/rbbt_commands/pbs/orchestrate +4 -4
  151. data/share/rbbt_commands/pbs/tail +2 -0
  152. data/share/rbbt_commands/pbs/task +10 -7
  153. data/share/rbbt_commands/resource/produce +8 -1
  154. data/share/rbbt_commands/slurm/list +2 -3
  155. data/share/rbbt_commands/slurm/orchestrate +4 -4
  156. data/share/rbbt_commands/slurm/tail +2 -0
  157. data/share/rbbt_commands/slurm/task +10 -7
  158. data/share/rbbt_commands/system/clean +5 -5
  159. data/share/rbbt_commands/system/status +5 -5
  160. data/share/rbbt_commands/tsv/get +2 -3
  161. data/share/rbbt_commands/tsv/info +10 -13
  162. data/share/rbbt_commands/tsv/keys +18 -14
  163. data/share/rbbt_commands/tsv/slice +2 -2
  164. data/share/rbbt_commands/tsv/transpose +6 -2
  165. data/share/rbbt_commands/workflow/info +20 -24
  166. data/share/rbbt_commands/workflow/list +1 -1
  167. data/share/rbbt_commands/workflow/prov +20 -13
  168. data/share/rbbt_commands/workflow/retry +43 -0
  169. data/share/rbbt_commands/workflow/server +12 -2
  170. data/share/rbbt_commands/workflow/task +80 -73
  171. data/share/rbbt_commands/workflow/write_info +26 -9
  172. data/share/software/opt/ssw/ssw.c +861 -0
  173. data/share/software/opt/ssw/ssw.h +130 -0
  174. data/share/workflow_config.ru +3 -3
  175. metadata +45 -6
@@ -1,284 +1,2 @@
1
- require 'rbbt/fix_width_table'
2
- require 'rbbt/util/misc'
3
-
4
- require 'rbbt/persist'
5
- require 'rbbt/persist/tsv'
6
-
7
- require 'rbbt/tsv/manipulate'
8
- require 'rbbt/tsv/filter'
9
-
10
- module TSV
11
-
12
- def index(options = {})
13
- options = Misc.add_defaults options,
14
- :target => :key, :fields => nil, :type => :single, :order => false
15
-
16
- persist_options = Misc.pull_keys options, :persist
17
- persist_options[:prefix] ||= "Index[#{options[:target] || :key}]"
18
-
19
- Log.debug "Index: #{ filename } - #{Misc.fingerprint options}"
20
- Persist.persist_tsv self, filename, options, persist_options do |new|
21
- with_unnamed do
22
- target, fields, index_type, order = Misc.process_options options, :target, :fields, :type, :order
23
-
24
- new.serializer = index_type if new.respond_to? :serializer and new.serializer == :type
25
-
26
- if order
27
-
28
- # Maybe best to do the stuff in memory first instead of the original
29
- # object, which could be persisted
30
- save = new
31
- new = {}
32
-
33
- new_key_field, new_fields = through target, fields, true do |key, values|
34
- next if key.empty?
35
- case type
36
- when :single
37
- values = [values]
38
- values.unshift key
39
- when :double
40
- values = values.dup
41
- values.unshift [key]
42
- when :list, :flat
43
- values = values.dup
44
- values.unshift key
45
- end
46
-
47
- values.each_with_index do |list, i|
48
- list = [list] unless type == :double
49
-
50
- list.uniq.each do |value|
51
- if new.include? value
52
- new_value = new[value]
53
- else
54
- new_value = []
55
- end
56
-
57
- if new_value[i].nil?
58
- new_value[i] = key
59
- else
60
- new_value[i] += "|" << key
61
- end
62
- new[value] = new_value
63
- end
64
- end
65
- end
66
-
67
- # Update original object
68
- new.each do |key, values|
69
- case
70
- when index_type == :double
71
- save[key] = [values.compact.collect{|v| v.split "|"}.flatten.uniq]
72
- when index_type == :flat
73
- save[key] = values.compact.collect{|v| v.split "|"}.flatten.uniq
74
- when index_type == :single
75
- save[key] = values.compact.collect{|v| v.split "|"}.flatten.first
76
- end
77
- end
78
-
79
- new = save
80
- else
81
- new_key_field, new_fields = through target, fields, true do |key, values|
82
- case
83
- when type == :single
84
- values = [values]
85
- when type == :double
86
- values = values.flatten
87
- else
88
- values = values.dup
89
- end
90
-
91
- values.unshift key
92
-
93
- values.uniq.each do |value|
94
- case index_type
95
- when :double
96
- if not new.include? value
97
- new[value] = [[key]]
98
- else
99
- current = new[value]
100
- current[0] << key
101
- new[value] = current
102
- end
103
- when :flat
104
- if not new.include? value
105
- new[value] = [key]
106
- else
107
- current = new[value]
108
- current << key
109
- new[value] = current
110
- end
111
-
112
- else
113
- new[value] = key unless new.include? value
114
- end
115
- end
116
- end
117
- end
118
-
119
- new_fields = [] if new_fields.nil?
120
- TSV.setup(new, :type => index_type, :filename => filename, :fields => [new_key_field], :key_field => new_fields * ", ", :namespace => namespace)
121
- end
122
- end
123
- end
124
-
125
- def self.index(file, options = {})
126
- persist_options = Misc.pull_keys options, :persist
127
- persist_options[:prefix] ||= "StaticIndex[#{options[:target] || :key}]"
128
-
129
- Log.debug "Static Index: #{ file } - #{Misc.fingerprint options}"
130
- Persist.persist_tsv nil, file, options, persist_options do |data|
131
- data_options = Misc.pull_keys options, :data
132
- data_options[:grep] ||= data_options[:tsv_grep] if data_options[:tsv_grep]
133
- identifiers = TSV.open(file, data_options)
134
- identifiers.with_monitor :desc => "Creating Index for #{ file }" do
135
- identifiers.index(options.merge :persist_data => data, :persist => persist_options[:persist])
136
- end
137
- end
138
- end
139
-
140
- def pos_index(pos_field = nil, options = {})
141
- pos_field ||= "Position"
142
-
143
- options = Misc.add_defaults options,
144
- :persist => false, :persist_file => nil, :persist_update => false
145
-
146
- persist_options = Misc.pull_keys options, :persist
147
- persist_options[:prefix] ||= "PosIndex[#{pos_field}]"
148
-
149
- Persist.persist(filename || self.object_id.to_s, :fwt, persist_options) do
150
- max_key_size = 0
151
- index_data = []
152
- with_unnamed do
153
- with_monitor :desc => "Creating Index Data", :step => 10000 do
154
- through :key, pos_field do |key, values|
155
- key_size = key.length
156
- max_key_size = key_size if key_size > max_key_size
157
-
158
- pos = values.first
159
- if Array === pos
160
- pos.each do |p|
161
- index_data << [key, p.to_i]
162
- end
163
- else
164
- index_data << [key, pos.to_i]
165
- end
166
- end
167
- end
168
- end
169
-
170
- index = FixWidthTable.get(:memory, max_key_size, false)
171
- index.add_point index_data
172
- index.read
173
- index
174
- end
175
- end
176
-
177
- def self.pos_index(file, pos_field = nil, options = {})
178
- pos_field ||= "Position"
179
-
180
- data_options = Misc.pull_keys options, :data
181
- filename = case
182
- when (String === file or Path === file)
183
- file
184
- when file.respond_to?(:filename)
185
- file.filename
186
- else
187
- file.object_id.to_s
188
- end
189
- persist_options = Misc.pull_keys options, :persist
190
- persist_options[:prefix] ||= "StaticPosIndex[#{pos_field}]"
191
-
192
- filters = Misc.process_options options, :filters
193
-
194
- if filters
195
- filename += ":Filtered[#{filters.collect{|f| f * "="} * ", "}]"
196
- end
197
-
198
- Persist.persist(filename, :fwt, persist_options) do
199
- tsv = TSV.open(file, data_options)
200
- if filters
201
- tsv.filter
202
- filters.each do |match, value|
203
- tsv.add_filter match, value
204
- end
205
- end
206
- tsv.pos_index(pos_field, options)
207
- end
208
- end
209
-
210
- def range_index(start_field = nil, end_field = nil, options = {})
211
- start_field ||= "Start"
212
- end_field ||= "End"
213
-
214
- options = Misc.add_defaults options,
215
- :persist => false, :persist_file => nil, :persist_update => false
216
-
217
- persist_options = Misc.pull_keys options, :persist
218
- persist_options[:prefix] ||= "RangeIndex[#{start_field}-#{end_field}]"
219
-
220
- Persist.persist(filename || self.object_id.to_s, :fwt, persist_options) do
221
- max_key_size = 0
222
- index_data = []
223
- with_unnamed do
224
- with_monitor :desc => "Creating Index Data", :step => 10000 do
225
- through :key, [start_field, end_field] do |key, values|
226
- key_size = key.length
227
- max_key_size = key_size if key_size > max_key_size
228
-
229
- start_pos, end_pos = values
230
- if Array === start_pos
231
- start_pos.zip(end_pos).each do |s,e|
232
- index_data << [key, [s.to_i, e.to_i]]
233
- end
234
- else
235
- index_data << [key, [start_pos.to_i, end_pos.to_i]]
236
- end
237
- end
238
- end
239
- end
240
-
241
- index = FixWidthTable.get(:memory, max_key_size, true)
242
- index.add_range index_data
243
- index.read
244
- index
245
- end
246
- end
247
-
248
- def self.range_index(file, start_field = nil, end_field = nil, options = {})
249
- start_field ||= "Start"
250
- end_field ||= "End"
251
-
252
- data_options = Misc.pull_keys options, :data
253
- filename = case
254
- when (String === file or Path === file)
255
- file
256
- when file.respond_to?(:filename)
257
- file.filename
258
- else
259
- file.object_id.to_s
260
- end
261
-
262
- persist_options = Misc.pull_keys options, :persist
263
- persist_options[:prefix] ||= "StaticRangeIndex[#{start_field}-#{end_field}]"
264
-
265
- filters = Misc.process_options options, :filters
266
-
267
- if filters
268
- filename += ":Filtered[#{filters.collect{|f| f * "="} * ", "}]"
269
- end
270
-
271
- Persist.persist(filename, :fwt, persist_options) do
272
- tsv = TSV.open(file, data_options)
273
- if filters
274
- tsv.filter
275
- filters.each do |match, value|
276
- tsv.add_filter match, value
277
- end
278
- end
279
-
280
- tsv.range_index(start_field, end_field, options)
281
- end
282
- end
283
- end
284
-
1
+ require_relative '../refactor'
2
+ Rbbt.require_instead 'scout/tsv'