scout-gear 10.6.1 → 10.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 217809c3c2f63740c3208ed81c6850a14cae2c6dc0687d185384b13e7747d07e
4
- data.tar.gz: d174ef3d473a5b3f25b520d9fb088b4717527f53c5c322727da4d89f935a3e61
3
+ metadata.gz: ac64d599e0df97b8ba5abd7aef4855ed1181ab9d9a3ba39196255b6649f56a0c
4
+ data.tar.gz: 9f1cf16da9432beb46eeb486de5bab1c57e460b09f2126556126eb356c6a6fd6
5
5
  SHA512:
6
- metadata.gz: e5387627839d6370801c22d6fa3b483db9ad3ea04242b7e999c8827c2999ced34c25369643a3c7aba4736afa2abf0caf390ed68ba2aa5dd1156b3ef7f063a9ec
7
- data.tar.gz: 8b5f90d48f7712e7b6b692f03b9eb7fab9b22540c7f8ffa2daae0158f13be362369ed018a23d13f435b24ebce6bc761a9634386ddf84cec100f0ab0447095157
6
+ metadata.gz: 27015e493797ff3e80631a49e0d9bf2ccc115997e86d449b217dd55adc6dd0abd7701019c19467e9c48aa6bc7ff3c372238fcd58200069533686e2729870938f
7
+ data.tar.gz: 4930f226926fdc18b06952f037f8e60b45b49116be115409cbcee36bf66202f0bb909691f20fddc6711babbb2ec9b604a5f3e551742ab52cb3f96748665b13a6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 10.6.1
1
+ 10.7.0
data/lib/scout/entity.rb CHANGED
@@ -3,6 +3,7 @@ require_relative 'entity/format'
3
3
  require_relative 'entity/property'
4
4
  require_relative 'entity/object'
5
5
  require_relative 'entity/identifiers'
6
+
6
7
  module Entity
7
8
  def self.extended(base)
8
9
  base.extend Annotation
@@ -1,17 +1,21 @@
1
1
  module Persist
2
+ REPO_CACHE = {}
2
3
  def self.annotation_repo_persist(repo, name, &block)
3
4
 
4
5
  if String === repo
5
- repo = repo.find if Path === repo
6
- repo = Persist.open_tokyocabinet(repo, false, :list, :BDB)
7
- repo_fields = ["literal", "annotation_types", "JSON"]
8
- TSV.setup(repo, :fields => repo_fields, :key_field => "Annotation ID")
9
- repo.save_annotation_hash
6
+ repo = REPO_CACHE[repo] ||= begin
7
+ repo = repo.find if Path === repo
8
+ repo = Persist.open_tokyocabinet(repo, false, :list, :BDB)
9
+ repo_fields = ["literal", "annotation_types", "JSON"]
10
+ TSV.setup(repo, :fields => repo_fields, :key_field => "Annotation ID")
11
+ repo.save_annotation_hash
12
+ repo
13
+ end
10
14
  repo.close
11
- else
12
- repo_fields = repo.fields
13
15
  end
14
16
 
17
+ repo_fields = repo.fields
18
+
15
19
  subkey = name + ":"
16
20
 
17
21
  keys = repo.read_and_close do
@@ -154,7 +154,7 @@ module TSV
154
154
 
155
155
  other_values.zip(overlaps).each do |v,overlap|
156
156
  if type == :list
157
- current_values[overlap] = v if current_values[overlap].nil? || String === current_values[overlap] && current_values[overlap].empty?
157
+ current_values[overlap] = v if current_values[overlap].nil? || (String === current_values[overlap] && current_values[overlap].empty?)
158
158
  elsif type == :flat
159
159
  next if v.nil?
160
160
  v = [v] unless Array === v
@@ -206,7 +206,7 @@ module TSV
206
206
  if overlap == :key
207
207
  other_key = Array === v ? v : v.first
208
208
  elsif type == :list
209
- new_values[overlap] = v if v[overlap].nil? || String === v[overlap] && v[overlap].empty?
209
+ new_values[overlap] = v if new_values[overlap].nil? || (String === new_values[overlap] && new_values[overlap].empty?)
210
210
  else
211
211
  v = [v] unless Array === v
212
212
  new_values[overlap].concat v
@@ -80,6 +80,7 @@ module TSV
80
80
  def each(*args, **kwargs, &block)
81
81
  kwargs[:into] = @dumper
82
82
  kwargs[:bar] = "Transform #{Log.fingerprint @parser} into #{Log.fingerprint @target}" if TrueClass === kwargs[:bar]
83
+ @dumper.namespace ||= @namespace
83
84
  @dumper.init if @dumper.respond_to?(:init) && ! @dumper.initialized
84
85
  Open.traverse(@parser, *args, **kwargs) do |k,v|
85
86
  NamedArray.setup(v, @parser.fields, k) unless @unnamed
@@ -1,6 +1,6 @@
1
1
  require_relative 'parser'
2
2
  module TSV
3
- def traverse(key_field_pos = :key, fields_pos = nil, type: nil, one2one: false, unnamed: false, key_field: nil, fields: nil, bar: false, cast: nil, select: nil, &block)
3
+ def traverse(key_field_pos = :key, fields_pos = nil, type: nil, one2one: false, unnamed: false, key_field: nil, fields: nil, bar: false, cast: nil, select: nil, uniq: false, &block)
4
4
  key_field = key_field_pos if key_field.nil?
5
5
  fields = fields_pos.dup if fields.nil?
6
6
  type = @type if type.nil?
@@ -74,6 +74,7 @@ module TSV
74
74
  values = TSV.cast_value(values, cast) if cast
75
75
 
76
76
  if Array === key
77
+ key = key.uniq if uniq
77
78
  if @type == :double && one2one
78
79
  if one2one == :strict
79
80
  key.each_with_index do |key_i,i|
data/lib/scout/tsv.rb CHANGED
@@ -11,13 +11,12 @@ require_relative 'tsv/open'
11
11
  require_relative 'tsv/attach'
12
12
  require_relative 'tsv/change_id'
13
13
  require_relative 'tsv/stream'
14
- require_relative 'tsv/entity'
15
14
  require_relative 'tsv/annotation'
16
15
  require_relative 'tsv/csv'
17
16
 
18
17
  module TSV
19
18
  extend Annotation
20
- annotation :key_field, :fields, :type, :cast, :filename, :namespace, :unnamed, :identifiers, :entity_options, :serializer
19
+ annotation :key_field, :fields, :type, :cast, :filename, :namespace, :unnamed, :identifiers, :serializer
21
20
 
22
21
  def self.str2options(str)
23
22
  field_options,_sep, rest = str.partition("#")
@@ -122,8 +121,6 @@ module TSV
122
121
  end
123
122
  end
124
123
 
125
- tsv.entity_options = entity_options
126
-
127
124
  tsv
128
125
  end
129
126
  end
@@ -138,17 +138,19 @@ class WorkQueue
138
138
  end
139
139
 
140
140
  def abort
141
+ @aborted = true
141
142
  Log.low "Aborting #{@workers.length} workers in queue #{queue_id}"
142
143
  @worker_mutex.synchronize do
143
144
  @workers.each do |w|
144
- ScoutSemaphore.post_semaphore(@output.write_sem) if @output
145
- ScoutSemaphore.post_semaphore(@input.read_sem) if @input
145
+ ScoutSemaphore.post_semaphore(@output.write_sem)
146
+ ScoutSemaphore.post_semaphore(@input.read_sem)
146
147
  w.abort
147
148
  end
148
149
  end
149
150
  end
150
151
 
151
152
  def close
153
+ return if @closed || @aborted
152
154
  @closed = true
153
155
  @worker_mutex.synchronize{ @workers.length }.times do
154
156
  begin
@@ -165,6 +167,7 @@ class WorkQueue
165
167
  end
166
168
 
167
169
  def join(clean = true)
170
+ close
168
171
  begin
169
172
  @waiter.join if @waiter
170
173
  @reader.join if @reader
@@ -21,12 +21,14 @@ module Workflow
21
21
  @helpers ||= {}
22
22
  end
23
23
 
24
- def helper(name, *args, &block)
24
+ def helper(name, *args, **kwargs, &block)
25
25
  if block_given?
26
26
  helpers[name] = block
27
27
  else
28
28
  raise RbbtException, "helper #{name} unkown in #{self} workflow" unless helpers[name]
29
- helpers[name].call(*args)
29
+ o = Object.new
30
+ o.extend step_module
31
+ o.send(name, *args, **kwargs)
30
32
  end
31
33
  end
32
34
 
@@ -246,6 +246,7 @@ module Workflow
246
246
  workload = new_workload
247
247
  sleep timer
248
248
  end
249
+ all_jobs.each{|s| s.join }
249
250
  rescue TryAgain
250
251
  retry
251
252
  end
@@ -36,7 +36,7 @@ class Step
36
36
 
37
37
  dependencies.each do |dep|
38
38
  if dep.present? && ! dep.updated?
39
- Log.debug "Clean outdated #{dep.path}"
39
+ Log.medium "Clean outdated #{dep.path}"
40
40
  dep.clean
41
41
  end
42
42
 
@@ -26,6 +26,7 @@ class Step
26
26
  newer = rec_dependencies.select{|dep| Path.newer?(self.path, dep.path) }
27
27
  newer += input_dependencies.select{|dep| Path.newer?(self.path, dep.path) }
28
28
 
29
+ Log.low "Newer deps found for #{Log.fingerprint self}: #{Log.fingerprint newer}" if newer.any?
29
30
  newer.empty?
30
31
  end
31
32
 
@@ -101,7 +101,7 @@ module Task
101
101
  else
102
102
  dep = _res
103
103
  dependencies << dep
104
- dep_non_default_inputs = find_dep_non_default_inputs.call(dep, block_options)
104
+ dep_non_default_inputs = find_dep_non_default_inputs.call(dep, definition_options)
105
105
  non_default_inputs.concat(dep_non_default_inputs)
106
106
  end
107
107
  end
@@ -47,7 +47,7 @@ module Task
47
47
  elsif String === value && Symbol === provided && provided.to_s == value
48
48
  same_as_default = true
49
49
  else
50
- same_as_default = false
50
+ same_as_default = false
51
51
  end
52
52
  if ! provided.nil? && ! same_as_default
53
53
  non_default_inputs << name.to_sym
data/scout-gear.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: scout-gear 10.6.1 ruby lib
5
+ # stub: scout-gear 10.7.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-gear".freeze
9
- s.version = "10.6.1".freeze
9
+ s.version = "10.7.0".freeze
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Miguel Vazquez".freeze]
14
- s.date = "2024-05-28"
14
+ s.date = "2024-06-05"
15
15
  s.description = "Temporary files, logs, path, resources, persistence, workflows, TSV, etc.".freeze
16
16
  s.email = "mikisvaz@gmail.com".freeze
17
17
  s.executables = ["scout".freeze]
@@ -72,7 +72,6 @@ Gem::Specification.new do |s|
72
72
  "lib/scout/tsv/change_id/translate.rb",
73
73
  "lib/scout/tsv/csv.rb",
74
74
  "lib/scout/tsv/dumper.rb",
75
- "lib/scout/tsv/entity.rb",
76
75
  "lib/scout/tsv/index.rb",
77
76
  "lib/scout/tsv/open.rb",
78
77
  "lib/scout/tsv/parser.rb",
@@ -184,7 +183,6 @@ Gem::Specification.new do |s|
184
183
  "test/scout/tsv/test_change_id.rb",
185
184
  "test/scout/tsv/test_csv.rb",
186
185
  "test/scout/tsv/test_dumper.rb",
187
- "test/scout/tsv/test_entity.rb",
188
186
  "test/scout/tsv/test_index.rb",
189
187
  "test/scout/tsv/test_open.rb",
190
188
  "test/scout/tsv/test_parser.rb",
@@ -117,6 +117,7 @@ class TestWorkQueue < Test::Unit::TestCase
117
117
 
118
118
  assert_raise ScoutException do
119
119
  begin
120
+ t.join
120
121
  q.join(false)
121
122
  rescue
122
123
  t.raise($!)
@@ -158,6 +159,7 @@ class TestWorkQueue < Test::Unit::TestCase
158
159
 
159
160
  assert_raise ScoutException do
160
161
  begin
162
+ t.join
161
163
  q.join(false)
162
164
  rescue Exception
163
165
  t.raise($!)
@@ -85,4 +85,20 @@ class TestWorkflow < Test::Unit::TestCase
85
85
  assert_equal "Baking batter (Mixing base (Mixing base (Whisking eggs from share/pantry/eggs) with mixer (share/pantry/flour)) with mixer (share/pantry/blueberries))",
86
86
  Baking.job(:bake_muffin_tray, "Blueberry muffin", :add_bluberries => true).run
87
87
  end
88
+
89
+ def test_call_helper
90
+ wf = Module.new do
91
+ extend Workflow
92
+
93
+ helper :m1 do
94
+ "TEST"
95
+ end
96
+
97
+ helper :m2 do
98
+ m1
99
+ end
100
+ end
101
+
102
+ assert_equal "TEST", wf.helper(:m2)
103
+ end
88
104
  end
@@ -449,4 +449,33 @@ A Id3
449
449
  assert res["row2"].include? "Id3"
450
450
  assert ! res["row2"].include?("b")
451
451
  end
452
+
453
+ def test_attach_list_to_list_with_complete
454
+ content1 =<<-EOF
455
+ #Id ValueA ValueB
456
+ row1 a b
457
+ row2 A B
458
+ EOF
459
+
460
+ content2 =<<-EOF
461
+ #Id ValueC
462
+ row1 c
463
+ row2 C
464
+ row3 CC
465
+ EOF
466
+
467
+ tsv1 = tsv2 = index = nil
468
+ TmpFile.with_file(content1) do |filename|
469
+ tsv1 = TSV.open(File.open(filename), type: :list, fields: ["ValueA"], sep: /\s+/)
470
+ end
471
+
472
+ TmpFile.with_file(content2) do |filename|
473
+ tsv2 = TSV.open(File.open(filename), type: :list, sep: /\s+/)
474
+ end
475
+
476
+ res = tsv1.attach tsv2, :fields => ["ValueC"], complete: true
477
+ assert res["row2"].include?("C")
478
+ refute res["row2"].include?("b")
479
+ assert res["row3"].include?("CC")
480
+ end
452
481
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout-gear
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.6.1
4
+ version: 10.7.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: 2024-05-28 00:00:00.000000000 Z
11
+ date: 2024-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scout-essentials
@@ -184,7 +184,6 @@ files:
184
184
  - lib/scout/tsv/change_id/translate.rb
185
185
  - lib/scout/tsv/csv.rb
186
186
  - lib/scout/tsv/dumper.rb
187
- - lib/scout/tsv/entity.rb
188
187
  - lib/scout/tsv/index.rb
189
188
  - lib/scout/tsv/open.rb
190
189
  - lib/scout/tsv/parser.rb
@@ -296,7 +295,6 @@ files:
296
295
  - test/scout/tsv/test_change_id.rb
297
296
  - test/scout/tsv/test_csv.rb
298
297
  - test/scout/tsv/test_dumper.rb
299
- - test/scout/tsv/test_entity.rb
300
298
  - test/scout/tsv/test_index.rb
301
299
  - test/scout/tsv/test_open.rb
302
300
  - test/scout/tsv/test_parser.rb
@@ -1,5 +0,0 @@
1
- module TSV
2
- def prepare_entity(obj, *args)
3
- obj
4
- end
5
- end
File without changes