scout-gear 7.2.0 → 7.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +37 -3
  3. data/VERSION +1 -1
  4. data/lib/scout/concurrent_stream.rb +9 -8
  5. data/lib/scout/exceptions.rb +1 -0
  6. data/lib/scout/log/color.rb +0 -1
  7. data/lib/scout/log/progress/util.rb +65 -0
  8. data/lib/scout/misc/helper.rb +31 -0
  9. data/lib/scout/misc/monitor.rb +1 -1
  10. data/lib/scout/misc.rb +1 -0
  11. data/lib/scout/open/stream.rb +21 -27
  12. data/lib/scout/persist.rb +42 -28
  13. data/lib/scout/semaphore.rb +8 -1
  14. data/lib/scout/tsv/dumper.rb +13 -8
  15. data/lib/scout/tsv/index.rb +127 -15
  16. data/lib/scout/tsv/open.rb +128 -0
  17. data/lib/scout/tsv/parser.rb +70 -43
  18. data/lib/scout/tsv/path.rb +4 -4
  19. data/lib/scout/tsv/persist/adapter.rb +52 -33
  20. data/lib/scout/tsv/persist/fix_width_table.rb +324 -0
  21. data/lib/scout/tsv/persist/serialize.rb +117 -0
  22. data/lib/scout/tsv/persist/tokyocabinet.rb +3 -3
  23. data/lib/scout/tsv/persist.rb +0 -2
  24. data/lib/scout/tsv/traverse.rb +130 -35
  25. data/lib/scout/tsv/util/filter.rb +303 -0
  26. data/lib/scout/tsv/util/process.rb +73 -0
  27. data/lib/scout/tsv/util/select.rb +220 -0
  28. data/lib/scout/tsv/util.rb +77 -19
  29. data/lib/scout/tsv.rb +2 -2
  30. data/lib/scout/work_queue/worker.rb +1 -1
  31. data/lib/scout/workflow/definition.rb +8 -0
  32. data/lib/scout/workflow/step/info.rb +4 -0
  33. data/lib/scout/workflow/step/progress.rb +14 -0
  34. data/lib/scout/workflow/step.rb +10 -5
  35. data/lib/scout/workflow/task.rb +8 -4
  36. data/lib/scout/workflow/usage.rb +2 -0
  37. data/scout-gear.gemspec +33 -10
  38. data/scout_commands/workflow/task +3 -2
  39. data/scout_commands/workflow/task_old +2 -2
  40. data/test/scout/open/test_stream.rb +1 -1
  41. data/test/scout/test_persist.rb +61 -0
  42. data/test/scout/test_tmpfile.rb +1 -1
  43. data/test/scout/test_tsv.rb +10 -1
  44. data/test/scout/test_work_queue.rb +1 -0
  45. data/test/scout/tsv/persist/test_adapter.rb +10 -0
  46. data/test/scout/tsv/persist/test_fix_width_table.rb +134 -0
  47. data/test/scout/tsv/test_index.rb +94 -2
  48. data/test/scout/tsv/test_open.rb +9 -0
  49. data/test/scout/tsv/test_parser.rb +28 -3
  50. data/test/scout/tsv/test_persist.rb +7 -0
  51. data/test/scout/tsv/test_traverse.rb +110 -3
  52. data/test/scout/tsv/test_util.rb +23 -0
  53. data/test/scout/tsv/util/test_filter.rb +188 -0
  54. data/test/scout/tsv/util/test_process.rb +47 -0
  55. data/test/scout/tsv/util/test_select.rb +44 -0
  56. data/test/scout/work_queue/test_worker.rb +63 -6
  57. data/test/scout/workflow/step/test_load.rb +3 -3
  58. data/test/scout/workflow/test_step.rb +10 -10
  59. data/test/test_helper.rb +3 -1
  60. metadata +19 -6
@@ -16,27 +16,84 @@ class TestQueueWorker < Test::Unit::TestCase
16
16
  end
17
17
  end
18
18
 
19
- def test_semaphore
20
- ScoutSemaphore.with_semaphore 1 do |sem|
19
+ def test_semaphore_pipe
20
+
21
+ 2.times do
22
+ num_lines = 10
23
+ num_workers = 100
21
24
 
22
25
  TmpFile.with_file do |outfile|
23
- 2.times do
26
+ Open.rm(outfile)
27
+ ScoutSemaphore.with_semaphore 1 do |sem|
24
28
  sout = Open.open_pipe do |sin|
25
- workers = 100.times.collect{ WorkQueue::Worker.new }
29
+ workers = num_workers.times.collect{ WorkQueue::Worker.new }
26
30
  workers.each do |w|
27
31
  w.run do
28
32
  ScoutSemaphore.synchronize(sem) do
29
- 10.times do
30
- sin.puts Process.pid
33
+ sin.puts "Start - #{Process.pid}"
34
+ num_lines.times do |i|
35
+ sin.puts "line-#{i}-#{Process.pid}"
31
36
  end
37
+ sin.puts "End - #{Process.pid}"
32
38
  end
33
39
  end
34
40
  end
41
+ sin.close
35
42
 
36
43
  WorkQueue::Worker.join(workers)
37
44
  end
45
+
38
46
  Open.consume_stream(sout, false, outfile)
47
+ txt = Open.read(outfile)
48
+ pid_list = txt.split("\n")
49
+
50
+ assert_equal (num_lines + 2) * num_workers, pid_list.length
51
+
52
+ assert_nothing_raised do
53
+ seen = []
54
+ current = nil
55
+ pid_list.each do |pid|
56
+ if pid != current
57
+ raise "Out of order #{Log.fingerprint seen} #{ pid }" if seen.include? pid
58
+ end
59
+ current = pid
60
+ seen << pid
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ def test_semaphore
68
+
69
+ 2.times do
70
+ num_lines = 10
71
+ num_workers = 500
72
+
73
+ TmpFile.with_file do |outfile|
74
+ Open.rm(outfile)
75
+ ScoutSemaphore.with_semaphore 1 do |sem|
76
+ workers = num_workers.times.collect{ WorkQueue::Worker.new }
77
+ Open.touch(outfile)
78
+ workers.each do |w|
79
+ w.run do
80
+ ScoutSemaphore.synchronize(sem) do
81
+ sin = Open.open(outfile, :mode => 'a')
82
+ sin.puts "Start - #{Process.pid}"
83
+ num_lines.times do |i|
84
+ sin.puts "line-#{i}-#{Process.pid}"
85
+ end
86
+ sin.puts "End - #{Process.pid}"
87
+ sin.close
88
+ end
89
+ end
90
+ end
91
+
92
+ WorkQueue::Worker.join(workers)
93
+
94
+
39
95
  pid_list = Open.read(outfile).split("\n")
96
+ assert_equal (num_lines + 2) * num_workers, pid_list.length
40
97
 
41
98
  assert_nothing_raised do
42
99
  seen = []
@@ -41,7 +41,7 @@ class TestStepLoad < Test::Unit::TestCase
41
41
  end
42
42
  end
43
43
 
44
- step2 = wf.job(:step2, :input1 => "TEST")
44
+ step2 = wf.job(:step2, nil, :input1 => "TEST_STRING")
45
45
  step1 = step2.step(:step1)
46
46
 
47
47
  step2.run
@@ -53,8 +53,8 @@ class TestStepLoad < Test::Unit::TestCase
53
53
  Open.mv step1.info_file, dir.var.jobs.RelocateWorkflow.step1[File.basename(step1.info_file)]
54
54
 
55
55
  new_step2 = Step.load(step2.path)
56
- assert_equal "TEST".reverse, new_step2.load
57
- assert_equal "TEST", new_step2.dependencies.first.load
56
+ assert_equal "TEST_STRING".reverse, new_step2.load
57
+ assert_equal "TEST_STRING", new_step2.dependencies.first.load
58
58
  end
59
59
  end
60
60
 
@@ -27,7 +27,6 @@ class TestWorkflowStep < Test::Unit::TestCase
27
27
 
28
28
  step2.dependencies = [step1]
29
29
 
30
-
31
30
  assert_equal "12 has 2 characters", step2.run
32
31
  assert_equal "12 has 2 characters", step2.run
33
32
  end
@@ -50,7 +49,7 @@ class TestWorkflowStep < Test::Unit::TestCase
50
49
 
51
50
  step2 = Step.new tmpfile.step2 do
52
51
  step1 = dependencies.first
53
- stream = step1.get_stream
52
+ stream = step1.stream
54
53
 
55
54
  Open.open_pipe do |sin|
56
55
  while line = stream.gets
@@ -87,7 +86,7 @@ class TestWorkflowStep < Test::Unit::TestCase
87
86
 
88
87
  assert step1.path.read.end_with? "line-#{times-1}\n"
89
88
  assert_equal times/2, lines.length
90
- assert_equal times/2, step2.path.read.split("\n").length
89
+ assert_equal times/2, step2.join.path.read.split("\n").length
91
90
  end
92
91
 
93
92
  def test_streaming_duplicate
@@ -108,7 +107,7 @@ class TestWorkflowStep < Test::Unit::TestCase
108
107
 
109
108
  step2 = Step.new tmpfile.step2 do
110
109
  step1 = dependencies.first
111
- stream = step1.get_stream
110
+ stream = step1.stream
112
111
 
113
112
  Open.open_pipe do |sin|
114
113
  while line = stream.gets
@@ -123,7 +122,7 @@ class TestWorkflowStep < Test::Unit::TestCase
123
122
 
124
123
  step3 = Step.new tmpfile.step3 do
125
124
  step1, step2 = dependencies
126
- stream = step2.get_stream
125
+ stream = step2.stream
127
126
 
128
127
  Open.open_pipe do |sin|
129
128
  while line = stream.gets
@@ -164,7 +163,7 @@ class TestWorkflowStep < Test::Unit::TestCase
164
163
 
165
164
  step2 = Step.new tmpfile.step2 do
166
165
  step1 = dependencies.first
167
- stream = step1.get_stream
166
+ stream = step1.stream
168
167
 
169
168
  Open.open_pipe do |sin|
170
169
  while line = stream.gets
@@ -179,7 +178,7 @@ class TestWorkflowStep < Test::Unit::TestCase
179
178
 
180
179
  step3 = Step.new tmpfile.step3 do
181
180
  step1 = dependencies.first
182
- stream = step1.get_stream
181
+ stream = step1.stream
183
182
 
184
183
  Open.open_pipe do |sin|
185
184
  while line = stream.gets
@@ -199,14 +198,14 @@ class TestWorkflowStep < Test::Unit::TestCase
199
198
  mutex = Mutex.new
200
199
  Open.open_pipe do |sin|
201
200
  t2 = Thread.new do
202
- stream2 = step2.get_stream
201
+ stream2 = step2.stream
203
202
  while line = stream2.gets
204
203
  sin.puts line
205
204
  end
206
205
  end
207
206
 
208
207
  t3 = Thread.new do
209
- stream3 = step3.get_stream
208
+ stream3 = step3.stream
210
209
  while line = stream3.gets
211
210
  sin.puts line
212
211
  end
@@ -220,12 +219,13 @@ class TestWorkflowStep < Test::Unit::TestCase
220
219
 
221
220
  lines = []
222
221
  io = step4.run
223
- Log::ProgressBar.with_bar do |b|
222
+ Log::ProgressBar.with_bar severity: 0 do |b|
224
223
  while line = io.gets
225
224
  b.tick
226
225
  lines << line.strip
227
226
  end
228
227
  end
228
+ io.close
229
229
 
230
230
  assert_equal times, lines.length
231
231
  end
data/test/test_helper.rb CHANGED
@@ -33,12 +33,14 @@ class Test::Unit::TestCase
33
33
  end
34
34
 
35
35
  def tmpdir
36
- @tmpdir = Path.setup('tmp/test_tmpdir').find
36
+ @tmpdir ||= Path.setup('tmp/test_tmpdir').find
37
37
  end
38
38
 
39
39
  setup do
40
+ TmpFile.tmpdir = tmpdir.tmpfiles
40
41
  Log::ProgressBar.default_severity = 0
41
42
  Persist.cache_dir = tmpdir.var.cache
43
+ Persist::MEMORY_CACHE.clear
42
44
  Open.remote_cache_dir = tmpdir.var.cache
43
45
  Workflow.directory = tmpdir.var.jobs
44
46
  Workflow.workflows.each{|wf| wf.directory = Workflow.directory[wf.name] }
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: 7.2.0
4
+ version: 7.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-09 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -119,6 +119,7 @@ files:
119
119
  - lib/scout/misc/digest.rb
120
120
  - lib/scout/misc/filesystem.rb
121
121
  - lib/scout/misc/format.rb
122
+ - lib/scout/misc/helper.rb
122
123
  - lib/scout/misc/insist.rb
123
124
  - lib/scout/misc/monitor.rb
124
125
  - lib/scout/misc/system.rb
@@ -154,13 +155,19 @@ files:
154
155
  - lib/scout/tsv.rb
155
156
  - lib/scout/tsv/dumper.rb
156
157
  - lib/scout/tsv/index.rb
158
+ - lib/scout/tsv/open.rb
157
159
  - lib/scout/tsv/parser.rb
158
160
  - lib/scout/tsv/path.rb
159
161
  - lib/scout/tsv/persist.rb
160
162
  - lib/scout/tsv/persist/adapter.rb
163
+ - lib/scout/tsv/persist/fix_width_table.rb
164
+ - lib/scout/tsv/persist/serialize.rb
161
165
  - lib/scout/tsv/persist/tokyocabinet.rb
162
166
  - lib/scout/tsv/traverse.rb
163
167
  - lib/scout/tsv/util.rb
168
+ - lib/scout/tsv/util/filter.rb
169
+ - lib/scout/tsv/util/process.rb
170
+ - lib/scout/tsv/util/select.rb
164
171
  - lib/scout/work_queue.rb
165
172
  - lib/scout/work_queue/socket.rb
166
173
  - lib/scout/work_queue/worker.rb
@@ -173,6 +180,7 @@ files:
173
180
  - lib/scout/workflow/step/file.rb
174
181
  - lib/scout/workflow/step/info.rb
175
182
  - lib/scout/workflow/step/load.rb
183
+ - lib/scout/workflow/step/progress.rb
176
184
  - lib/scout/workflow/step/provenance.rb
177
185
  - lib/scout/workflow/task.rb
178
186
  - lib/scout/workflow/task/inputs.rb
@@ -234,13 +242,18 @@ files:
234
242
  - test/scout/test_work_queue.rb
235
243
  - test/scout/test_workflow.rb
236
244
  - test/scout/tsv/persist/test_adapter.rb
245
+ - test/scout/tsv/persist/test_fix_width_table.rb
237
246
  - test/scout/tsv/persist/test_tokyocabinet.rb
238
247
  - test/scout/tsv/test_dumper.rb
239
248
  - test/scout/tsv/test_index.rb
249
+ - test/scout/tsv/test_open.rb
240
250
  - test/scout/tsv/test_parser.rb
241
251
  - test/scout/tsv/test_persist.rb
242
252
  - test/scout/tsv/test_traverse.rb
243
253
  - test/scout/tsv/test_util.rb
254
+ - test/scout/tsv/util/test_filter.rb
255
+ - test/scout/tsv/util/test_process.rb
256
+ - test/scout/tsv/util/test_select.rb
244
257
  - test/scout/work_queue/test_socket.rb
245
258
  - test/scout/work_queue/test_worker.rb
246
259
  - test/scout/workflow/step/test_dependencies.rb
@@ -260,7 +273,7 @@ homepage: http://github.com/mikisvaz/scout-gear
260
273
  licenses:
261
274
  - MIT
262
275
  metadata: {}
263
- post_install_message:
276
+ post_install_message:
264
277
  rdoc_options: []
265
278
  require_paths:
266
279
  - lib
@@ -275,8 +288,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
288
  - !ruby/object:Gem::Version
276
289
  version: '0'
277
290
  requirements: []
278
- rubygems_version: 3.4.11
279
- signing_key:
291
+ rubygems_version: 3.2.15
292
+ signing_key:
280
293
  specification_version: 4
281
294
  summary: basic gear for scouts
282
295
  test_files: []