rbbt-util 5.21.46 → 5.21.47

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1842f04355fb68456343e2efd33e3f91a392b087
4
- data.tar.gz: f900fd25199c8ea1e115288ae19419a076a7b295
3
+ metadata.gz: 819899d0b037631acb37460fb3cb4a6cea8e287f
4
+ data.tar.gz: 9f820f17c0417b8367b203ac296639c48a49fcf8
5
5
  SHA512:
6
- metadata.gz: c5acb1a420921a7929890ca011e7e40dc8bea24dde6f8d722bc97306050e70f1220c6688cd00a7c2b5ecc1ce351a8fed55458e8e62d280be9bc0de7fa49a3601
7
- data.tar.gz: 606c4d21d9c52b3f466cc8f0c6dfef007fd755dffe051d99dba04dc296e8479e99b1a241cf03adaede913b78bee3732109ecc81cbb04edfcf5a0de72eebf2104
6
+ metadata.gz: 3df9c99be5f1e0d9efc7fd35c7efa36e16584486dabca43282cded1febaa9987b9bd9c876728dbe8dada63c959cf5539e41239fad662166e7cb2a1e486f76550
7
+ data.tar.gz: c75ee8154d92c0f75cf8a0da3df765d26e858f07d0eac923a62a607cebf00a6cc33beb93fc58582e1e3edbc2e7c8b1b9ac4b26d0ac3aa4a11cadc432049be612
@@ -31,7 +31,7 @@ module Resource
31
31
  attr_accessor :pkgdir, :subdir, :resources, :rake_dirs, :remote_server, :search_paths
32
32
 
33
33
  def root()
34
- Path.setup @subdir || "", @pkgdir, self
34
+ Path.setup @subdir || "", @pkgdir, self, @search_paths
35
35
  end
36
36
 
37
37
  def method_missing(name, prev = nil, *args)
@@ -85,7 +85,7 @@ module Path
85
85
  :default => :user
86
86
  })
87
87
 
88
- STANDARD_SEARCH = %w(current user local global lib fast cache bulk)
88
+ STANDARD_SEARCH = %w(current user local workflow global lib fast cache bulk)
89
89
 
90
90
  search_path_file = File.join(ENV['HOME'], '.rbbt/etc/search_paths')
91
91
  if File.exist?(search_path_file)
@@ -11,11 +11,15 @@ module Colorize
11
11
  end
12
12
  end
13
13
 
14
- def self.continuous(array, start = :white, eend = :black)
14
+ def self.continuous(array, start = :white, eend = :black, percent = false)
15
15
  start_color = Color.new from_name(start)
16
16
  end_color = Color.new from_name(eend)
17
17
 
18
- array = array.collect{|v| n = v.to_f; n = n > 100 ? 100 : n; n < 0.001 ? 0.001 : n}
18
+ if percent
19
+ array = array.collect{|v| n = v.to_f; n = n > 100 ? 100 : n; n < 0.001 ? 0.001 : n}
20
+ else
21
+ array = array.collect{|v| n = v.to_f; }
22
+ end
19
23
  max = array.max
20
24
  min = array.min
21
25
  range = max - min
@@ -24,6 +28,21 @@ module Colorize
24
28
  start_color.blend end_color, ratio
25
29
  end
26
30
  end
31
+
32
+ def self.gradient(array, value, start = :green, eend = :red, percent = false)
33
+ index = array.index value
34
+ colors = continuous(array, start, eend, percent)
35
+ colors[index]
36
+ end
37
+
38
+ def self.rank_gradient(array, value, start = :green, eend = :red, percent = false)
39
+ index = array.index value
40
+ sorted = array.sort
41
+ array = array.collect{|e| sorted.index e}
42
+ colors = continuous(array, start, eend, percent)
43
+ colors[index]
44
+ end
45
+
27
46
 
28
47
  def self.distinct(array)
29
48
  colors = Rbbt.share.color["diverging_colors.hex"].list.collect{|c| Color.new c}
@@ -294,23 +294,6 @@ module Workflow
294
294
  @_m
295
295
  end
296
296
 
297
- def get_job_step(step_path, task = nil, input_values = nil, dependencies = nil)
298
- step_path = step_path.call if Proc === step_path
299
- persist = input_values.nil? ? false : true
300
- persist = false
301
- key = Path === step_path ? step_path.find : step_path
302
- step = Step.new step_path, task, input_values, dependencies
303
-
304
-
305
- step.extend step_module
306
-
307
- step.task ||= task
308
- step.inputs ||= input_values
309
- step.dependencies = dependencies if dependencies and (step.dependencies.nil? or step.dependencies.length < dependencies.length)
310
-
311
- step
312
- end
313
-
314
297
  def job(taskname, jobname = nil, inputs = {})
315
298
  taskname = taskname.to_sym
316
299
  return remote_tasks[taskname].job(taskname, jobname, inputs) if remote_tasks and remote_tasks.include? taskname
@@ -354,9 +337,21 @@ module Workflow
354
337
  job
355
338
  end
356
339
 
357
- def load_step(path)
358
- task = task_for path
359
- get_job_step path, tasks[task.to_sym]
340
+ def get_job_step(step_path, task = nil, input_values = nil, dependencies = nil)
341
+ step_path = step_path.call if Proc === step_path
342
+ persist = input_values.nil? ? false : true
343
+ persist = false
344
+ key = Path === step_path ? step_path.find : step_path
345
+ step = Step.new step_path, task, input_values, dependencies
346
+
347
+
348
+ step.extend step_module
349
+
350
+ step.task ||= task
351
+ step.inputs ||= input_values
352
+ step.dependencies = dependencies if dependencies and (step.dependencies.nil? or step.dependencies.length < dependencies.length)
353
+
354
+ step
360
355
  end
361
356
 
362
357
  def load_id(id)
@@ -366,14 +361,23 @@ module Workflow
366
361
  step = Step.new path, tasks[task.to_sym]
367
362
  step.info
368
363
  if step.info.include? :dependencies
369
- step.dependencies = step.info[:dependencies].collect do |task, job|
364
+ step.dependencies = step.info[:dependencies].collect do |task, job, path|
370
365
  next if job.nil?
371
- load_id(File.join(task.to_s, job))
366
+ load_step(path)
372
367
  end
373
368
  end
374
369
  step
375
370
  end
376
371
 
372
+ def load_step(path)
373
+ task = task_for path
374
+ if task
375
+ get_job_step path, tasks[task.to_sym]
376
+ else
377
+ get_job_step path
378
+ end
379
+ end
380
+
377
381
  def load_name(task, name)
378
382
  return remote_tasks[task].load_step(path) if remote_tasks and remote_tasks.include? task
379
383
  task = tasks[task.to_sym] if String === task or Symbol === task
@@ -350,7 +350,12 @@ class Step
350
350
  end
351
351
 
352
352
  def dirty?
353
- rec_dependencies.collect{|dependency| dependency.path unless dependency.error? and not dependency.recoverable_error? }.compact.uniq.reject{|path| not (Path === path) or path.exists?}.any?
353
+ dirty_files = rec_dependencies.collect{|dependency| dependency.path unless dependency.error? and not dependency.recoverable_error? }.compact.uniq.reject{|path| not (Path === path) or path.exists?}
354
+ if dirty_files.any?
355
+ true
356
+ else
357
+ false
358
+ end
354
359
  end
355
360
 
356
361
  def done?
@@ -358,7 +363,7 @@ class Step
358
363
  end
359
364
 
360
365
  def streaming?
361
- IO === @result or @saved_stream or status == :streaming
366
+ (IO === @result) or (not @saved_stream.nil?) or status == :streaming
362
367
  end
363
368
 
364
369
 
@@ -806,7 +811,11 @@ module Workflow
806
811
  workdir_find = File.expand_path(workdir_find)
807
812
  path = File.expand_path(path)
808
813
  dir = File.dirname(path)
809
- Misc.path_relative_to(workdir_find, dir).sub(/([^\/]+)\/.*/,'\1')
814
+ begin
815
+ Misc.path_relative_to(workdir_find, dir).sub(/([^\/]+)\/.*/,'\1')
816
+ rescue
817
+ nil
818
+ end
810
819
  end
811
820
 
812
821
  def task_exports
@@ -220,6 +220,13 @@ class Step
220
220
  end
221
221
  end
222
222
 
223
+ def update
224
+ if dirty?
225
+ dependencies.collect{|d| d.update}
226
+ clean
227
+ end
228
+ end
229
+
223
230
  def clean
224
231
  status = []
225
232
  status << "dirty" if dirty?
@@ -267,7 +267,7 @@ class Step
267
267
  end
268
268
  end
269
269
 
270
- clean if dirty?
270
+ update
271
271
 
272
272
  if dofork
273
273
  fork(true) unless started?
@@ -499,7 +499,11 @@ class Step
499
499
  dependencies.each{|dep| dep.join }
500
500
  end
501
501
 
502
- sleep 1 until path.exists? or error? or aborted?
502
+ until path.exists? or error? or aborted?
503
+ iii [:sleep, status, streaming?]
504
+ sleep 1
505
+ join_stream if streaming?
506
+ end
503
507
 
504
508
  self
505
509
  ensure
@@ -10,7 +10,6 @@ def load_file(file)
10
10
  load file
11
11
  end
12
12
  end
13
-
14
13
  def app_eval(app, file)
15
14
  if Array === file
16
15
  file.each{|f| app_eval app, f }
@@ -22,6 +21,7 @@ def app_eval(app, file)
22
21
  end
23
22
  end
24
23
 
24
+
25
25
  #{{{ INIT
26
26
  ENV["RBBT_LOG"] = Log.severity.to_s
27
27
  require Rbbt.etc['app.d/init.rb'].find
@@ -30,79 +30,86 @@ require Rbbt.etc['app.d/init.rb'].find
30
30
  workflow = Rbbt.etc['target_workflow'].read
31
31
  wf = Workflow.require_workflow workflow, true
32
32
 
33
+
33
34
  $title = wf.to_s
34
35
  $app_name = app_name = wf.to_s + "REST"
35
36
  $app = app = eval "class #{app_name} < Sinatra::Base; self end"
36
37
 
38
+ Rbbt.search_paths = Path::SEARCH_PATHS.merge(:workflow => File.join(wf.libdir, '{TOPLEVEL}','{SUBPATH}'))
39
+
40
+ etc_dir = Rbbt.etc
41
+ #etc_dir.search_paths = Path::SEARCH_PATHS.merge(:workflow => File.join(wf.libdir, '{TOPLEVEL}','{SUBPATH}'))
42
+
43
+
37
44
  #{{{ PRE
38
- load_file Rbbt.etc['app.d/pre.rb'].find
45
+ load_file etc_dir['app.d/pre.rb'].find
39
46
 
40
47
  app.get '/' do
41
48
  redirect to(File.join('/', wf.to_s))
42
49
  end
43
50
 
44
51
  #{{{ BASE
45
- app_eval app, Rbbt.etc['app.d/base.rb'].find
52
+ app_eval app, etc_dir['app.d/base.rb'].find
46
53
 
47
54
  app.add_workflow wf, :priority
48
55
 
49
56
  #{{{ WORKFLOWS
50
- app_eval app, Rbbt.etc['app.d/workflows.rb'].find_all
57
+ app_eval app, etc_dir['app.d/workflows.rb'].find_all
51
58
 
52
59
  #{{{ RESOURCES
53
- load_file Rbbt.etc['app.d/resources.rb'].find
60
+ load_file etc_dir['app.d/resources.rb'].find
54
61
 
55
62
  #{{{ KNOWLEDGEBASE
56
- load_file Rbbt.etc['app.d/knowledge_bases.rb'].find
63
+ load_file etc_dir['app.d/knowledge_bases.rb'].find
57
64
 
58
65
  #{{{ REQUIRES
59
- load_file Rbbt.etc['app.d/requires.rb'].find
66
+ load_file etc_dir['app.d/requires.rb'].find
60
67
 
61
68
  #{{{ ENTITIES
62
- load_file Rbbt.etc['app.d/entities.rb'].find
69
+ load_file etc_dir['app.d/entities.rb'].find
63
70
 
64
71
  #{{{ ROUTES
65
- app_eval app, Rbbt.etc['app.d/routes.rb'].find_all
72
+ app_eval app, etc_dir['app.d/routes.rb'].find_all
66
73
 
67
74
  #{{{ FINDER
68
- app_eval app, Rbbt.etc['app.d/finder.rb'].find
75
+ app_eval app, etc_dir['app.d/finder.rb'].find
69
76
 
70
77
  #{{{ POST
71
- load_file Rbbt.etc['app.d/post.rb'].find_all
78
+ load_file etc_dir['app.d/post.rb'].find_all
72
79
 
73
80
  #{{{ PRELOAD
74
- load_file Rbbt.etc['app.d/preload.rb'].find_all
81
+ load_file etc_dir['app.d/preload.rb'].find_all
75
82
 
76
- if Rbbt.etc['target_workflow_exports'].exists?
77
- exports = Rbbt.etc['target_workflow_exports'].read.split("\n")
83
+ if etc_dir['target_workflow_exports'].exists?
84
+ exports = etc_dir['target_workflow_exports'].read.split("\n")
78
85
  exports.each do |task|
79
86
  wf.export task.to_sym
80
87
  end
81
88
  end
82
89
 
83
- if Rbbt.etc['target_workflow_stream_exports'].exists?
84
- exports = Rbbt.etc['target_workflow_stream_exports'].read.split("\n")
90
+ if etc_dir['target_workflow_stream_exports'].exists?
91
+ exports = etc_dir['target_workflow_stream_exports'].read.split("\n")
85
92
  exports.each do |task|
86
93
  wf.export_stream task.to_sym
87
94
  end
88
95
  end
89
96
 
90
- if Rbbt.etc['target_workflow_async_exports'].exists?
91
- exports = Rbbt.etc['target_workflow_async_exports'].read.split("\n")
97
+ if etc_dir['target_workflow_async_exports'].exists?
98
+ exports = etc_dir['target_workflow_async_exports'].read.split("\n")
92
99
  exports.each do |task|
93
100
  wf.export_asynchronous task.to_sym
94
101
  end
95
102
  end
96
103
 
97
- if Rbbt.etc['target_workflow_sync_exports'].exists?
98
- exports = Rbbt.etc['target_workflow_sync_exports'].read.split("\n")
104
+ if etc_dir['target_workflow_sync_exports'].exists?
105
+ exports = etc_dir['target_workflow_sync_exports'].read.split("\n")
99
106
  exports.each do |task|
100
107
  wf.export_synchronous task.to_sym
101
108
  end
102
109
  end
103
110
 
104
- if Rbbt.etc['target_workflow_exec_exports'].exists?
105
- exports = Rbbt.etc['target_workflow_exec_exports'].read.split("\n")
111
+ if etc_dir['target_workflow_exec_exports'].exists?
112
+ exports = etc_dir['target_workflow_exec_exports'].read.split("\n")
106
113
  exports.each do |task|
107
114
  wf.export_exec task.to_sym
108
115
  end
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.21.46
4
+ version: 5.21.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-25 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake