scout-gear 1.2.0 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +4 -0
  3. data/.vimproject +663 -4
  4. data/Rakefile +1 -0
  5. data/VERSION +1 -1
  6. data/bin/scout +235 -0
  7. data/lib/scout/cmd.rb +344 -0
  8. data/lib/scout/concurrent_stream.rb +259 -0
  9. data/lib/scout/exceptions.rb +15 -8
  10. data/lib/scout/indiferent_hash/options.rb +8 -26
  11. data/lib/scout/indiferent_hash.rb +0 -30
  12. data/lib/scout/log/color.rb +2 -2
  13. data/lib/scout/log/fingerprint.rb +11 -1
  14. data/lib/scout/log/progress/report.rb +0 -1
  15. data/lib/scout/log/progress/util.rb +1 -1
  16. data/lib/scout/log/progress.rb +4 -4
  17. data/lib/scout/log.rb +10 -2
  18. data/lib/scout/meta_extension.rb +15 -1
  19. data/lib/scout/misc/digest.rb +56 -0
  20. data/lib/scout/misc/filesystem.rb +26 -0
  21. data/lib/scout/misc/format.rb +226 -0
  22. data/lib/scout/misc/insist.rb +56 -0
  23. data/lib/scout/misc.rb +5 -11
  24. data/lib/scout/open/lock.rb +61 -0
  25. data/lib/scout/open/remote.rb +120 -0
  26. data/lib/scout/open/stream.rb +372 -0
  27. data/lib/scout/open/util.rb +225 -0
  28. data/lib/scout/open.rb +169 -0
  29. data/lib/scout/path/find.rb +78 -26
  30. data/lib/scout/path/tmpfile.rb +8 -0
  31. data/lib/scout/path/util.rb +17 -5
  32. data/lib/scout/path.rb +13 -31
  33. data/lib/scout/persist/open.rb +17 -0
  34. data/lib/scout/persist/path.rb +15 -0
  35. data/lib/scout/persist/serialize.rb +140 -0
  36. data/lib/scout/persist.rb +54 -0
  37. data/lib/scout/resource/path.rb +15 -0
  38. data/lib/scout/resource/produce/rake.rb +69 -0
  39. data/lib/scout/resource/produce.rb +246 -0
  40. data/lib/scout/resource/scout.rb +3 -0
  41. data/lib/scout/resource.rb +37 -0
  42. data/lib/scout/simple_opt/accessor.rb +54 -0
  43. data/lib/scout/simple_opt/doc.rb +102 -0
  44. data/lib/scout/simple_opt/get.rb +57 -0
  45. data/lib/scout/simple_opt/parse.rb +67 -0
  46. data/lib/scout/simple_opt/setup.rb +26 -0
  47. data/lib/scout/simple_opt.rb +5 -0
  48. data/lib/scout/tmpfile.rb +39 -1
  49. data/lib/scout/workflow/definition.rb +72 -0
  50. data/lib/scout/workflow/documentation.rb +77 -0
  51. data/lib/scout/workflow/step/info.rb +77 -0
  52. data/lib/scout/workflow/step.rb +96 -0
  53. data/lib/scout/workflow/task/inputs.rb +112 -0
  54. data/lib/scout/workflow/task.rb +141 -0
  55. data/lib/scout/workflow/usage.rb +294 -0
  56. data/lib/scout/workflow/util.rb +11 -0
  57. data/lib/scout/workflow.rb +39 -0
  58. data/lib/scout-gear.rb +5 -0
  59. data/lib/scout.rb +1 -0
  60. data/lib/workflow-scout.rb +2 -0
  61. data/scout-gear.gemspec +78 -5
  62. data/scout_commands/alias +48 -0
  63. data/scout_commands/find +83 -0
  64. data/scout_commands/glob +0 -0
  65. data/scout_commands/rbbt +23 -0
  66. data/scout_commands/workflow/task +707 -0
  67. data/test/scout/indiferent_hash/test_case_insensitive.rb +16 -0
  68. data/test/scout/indiferent_hash/test_options.rb +11 -1
  69. data/test/scout/misc/test_digest.rb +30 -0
  70. data/test/scout/misc/test_filesystem.rb +30 -0
  71. data/test/scout/misc/test_insist.rb +13 -0
  72. data/test/scout/open/test_lock.rb +52 -0
  73. data/test/scout/open/test_remote.rb +25 -0
  74. data/test/scout/open/test_stream.rb +515 -0
  75. data/test/scout/open/test_util.rb +73 -0
  76. data/test/scout/path/test_find.rb +37 -1
  77. data/test/scout/persist/test_open.rb +37 -0
  78. data/test/scout/persist/test_path.rb +37 -0
  79. data/test/scout/persist/test_serialize.rb +114 -0
  80. data/test/scout/resource/test_path.rb +40 -0
  81. data/test/scout/resource/test_produce.rb +62 -0
  82. data/test/scout/simple_opt/test_get.rb +11 -0
  83. data/test/scout/simple_opt/test_parse.rb +10 -0
  84. data/test/scout/simple_opt/test_setup.rb +77 -0
  85. data/test/scout/test_cmd.rb +85 -0
  86. data/test/scout/test_concurrent_stream.rb +29 -0
  87. data/test/scout/test_misc.rb +0 -7
  88. data/test/scout/test_open.rb +146 -0
  89. data/test/scout/test_path.rb +3 -1
  90. data/test/scout/test_persist.rb +83 -0
  91. data/test/scout/test_resource.rb +26 -0
  92. data/test/scout/test_workflow.rb +87 -0
  93. data/test/scout/workflow/step/test_info.rb +28 -0
  94. data/test/scout/workflow/task/test_inputs.rb +182 -0
  95. data/test/scout/workflow/test_step.rb +36 -0
  96. data/test/scout/workflow/test_task.rb +178 -0
  97. data/test/scout/workflow/test_usage.rb +26 -0
  98. data/test/scout/workflow/test_util.rb +17 -0
  99. data/test/test_helper.rb +17 -0
  100. data/test/test_scout-gear.rb +0 -0
  101. metadata +76 -3
@@ -0,0 +1,178 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ class TestTask < Test::Unit::TestCase
5
+ def test_basic_task
6
+ task = Task.setup do |s=""|
7
+ (self + s).length
8
+ end
9
+
10
+ assert_equal 4, task.exec_on("1234")
11
+ assert_equal 6, task.exec_on("1234","56")
12
+ end
13
+
14
+ def test_step
15
+ task = Task.setup do |s=""|
16
+ s.length
17
+ end
18
+
19
+ s = task.job('test', ['12'])
20
+ assert_equal 2, s.run
21
+ end
22
+
23
+ def test_override_inputs
24
+ wf = Workflow.annonymous_workflow "TaskInputs" do
25
+ input :input1, :string
26
+ task :step1 => :string do |i| i end
27
+
28
+ dep :step1, :input1 => 1
29
+ input :input2, :string
30
+ task :step2 => :string do |i| i end
31
+ end
32
+
33
+ job = wf.job(:step2, :input1 => 2)
34
+ assert_equal Task::DEFAULT_NAME, job.name
35
+ assert_not_equal Task::DEFAULT_NAME, job.step(:step1).name
36
+ end
37
+
38
+ def test_override_inputs_block
39
+ Log.severity = 0
40
+ wf = Workflow.annonymous_workflow "TaskInputs" do
41
+ input :input1, :string
42
+ task :step1 => :string do |i| i end
43
+
44
+ dep :step1 do |id,options|
45
+ {:inputs => {:input1 => 1}}
46
+ end
47
+ input :input2, :string
48
+ task :step2 => :string do |i| i end
49
+ end
50
+
51
+ job = wf.job(:step2, :input1 => 2)
52
+ assert_equal Task::DEFAULT_NAME, job.name
53
+ assert_not_equal Task::DEFAULT_NAME, job.step(:step1).name
54
+ end
55
+
56
+ def test_task_override_dep
57
+ Log.severity = 0
58
+ wf = Workflow.annonymous_workflow "TaskInputs" do
59
+ input :input1, :integer
60
+ task :step1 => :integer do |i| i end
61
+
62
+ dep :step1
63
+ input :input2, :integer, "Integer", 3
64
+ task :step2 => :integer do |i| i * step(:step1).load end
65
+ end
66
+
67
+ assert_equal 6, wf.job(:step2, :input1 => 2, :input2 => 3).run
68
+
69
+ step1_job = wf.job(:step1, :input1 => 6)
70
+ assert_equal 18, wf.job(:step2, :input1 => 2, "TaskInputs#step1" => step1_job).run
71
+
72
+ assert_equal 18, wf.job(:step2, :input1 => 2, "TaskInputs#step1" => step1_job).run
73
+
74
+ assert_equal 18, wf.job(:step2, "TaskInputs#step1" => step1_job).run
75
+ end
76
+
77
+ def test_input_dep
78
+ wf = Workflow.annonymous_workflow "TaskInputs" do
79
+ input :v1, :integer
80
+ input :v2, :integer
81
+ task :sum => :integer do |v1,v2|
82
+ v1 + v2
83
+ end
84
+
85
+ input :input1, :integer
86
+ task :step1 => :integer do |i| i end
87
+
88
+ input :input2, :integer
89
+ task :step2 => :integer do |i| i end
90
+
91
+ dep :step1, :input1 => 2
92
+ dep :step2, :input2 => 3
93
+ dep :sum, :v1 => :step1, :v2 => :step2
94
+ task :my_sum => :integer do
95
+ dependencies.last.load
96
+ end
97
+
98
+ dep :my_sum
99
+ task :double => :integer do
100
+ step(:my_sum).load * 2
101
+ end
102
+ end
103
+
104
+ job = wf.job(:my_sum)
105
+ assert_equal 5, job.run
106
+ assert_equal Task::DEFAULT_NAME, job.name
107
+
108
+ job = wf.job(:double)
109
+ assert_equal Task::DEFAULT_NAME, job.name
110
+
111
+ step1 = wf.job(:step1, :input1 => 3)
112
+ job = wf.job(:double, "TaskInputs#step1" => step1)
113
+ assert_equal 12, job.run
114
+ assert_not_equal Task::DEFAULT_NAME, job.name
115
+
116
+ step1 = wf.job(:step1, :input1 => 4)
117
+ job = wf.job(:double, "TaskInputs#step1" => step1)
118
+ assert_equal 14, job.run
119
+ assert_not_equal Task::DEFAULT_NAME, job.name
120
+ end
121
+
122
+ def test_input_dep_override
123
+ wf = Workflow.annonymous_workflow "TaskInputs" do
124
+ input :v1, :integer
125
+ input :v2, :integer
126
+ task :sum => :integer do |v1,v2|
127
+ v1 + v2
128
+ end
129
+
130
+ input :input1, :integer
131
+ task :step1 => :integer do |i| i end
132
+
133
+ input :input2, :integer
134
+ task :step2 => :integer do |i| i end
135
+
136
+ dep :step1
137
+ dep :step2
138
+ task :my_sum => :integer do
139
+ dependencies.inject(0){|acc,d| acc += d.load }
140
+ end
141
+ end
142
+
143
+ step2 = wf.job(:step2, :input2 => 4)
144
+ job = wf.job(:my_sum, :input1 => 2, :input2 => 3, "TaskInputs#step2"=> step2)
145
+ assert_equal 6, job.exec
146
+
147
+ job = wf.job(:my_sum, :input1 => 2, :input2 => 3)
148
+ assert_equal 5, job.run
149
+
150
+ TmpFile.with_file(4) do |file|
151
+ job = wf.job(:my_sum, :input1 => 2, :input2 => 3, "TaskInputs#step2"=> file)
152
+ assert_equal 6, job.run
153
+ assert_not_equal Task::DEFAULT_NAME, job.name
154
+ end
155
+ end
156
+
157
+ def test_input_rename
158
+ wf = Workflow.annonymous_workflow "TaskInputs" do
159
+ input :v1, :integer
160
+ input :v2, :integer
161
+ task :sum => :integer do |v1,v2|
162
+ v1 + v2
163
+ end
164
+
165
+ input :vv1, :integer
166
+ input :vv2, :integer
167
+ dep :sum, :v1 => :vv1, :v2 => :vv2
168
+ task :my_sum => :integer do
169
+ dependencies.last.load
170
+ end
171
+ end
172
+
173
+ Log.severity = 0
174
+ job = wf.job(:my_sum, :vv1 => 2, :vv2 => 3)
175
+ assert_equal 5, job.run
176
+ end
177
+ end
178
+
@@ -0,0 +1,26 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/workflow'
5
+ class TestWorkflowUsage < Test::Unit::TestCase
6
+ module UsageWorkflow
7
+ extend Workflow
8
+
9
+ desc "Desc"
10
+ input :array, :array, "Array"
11
+ task :step1 => :string do
12
+ end
13
+
14
+ dep :step1
15
+ desc "Desc2"
16
+ input :float, :float, "Float"
17
+ task :step2 => :string do
18
+ end
19
+ end
20
+
21
+ def __test_usage
22
+ UsageWorkflow.tasks[:step1].doc
23
+ UsageWorkflow.doc
24
+ end
25
+ end
26
+
@@ -0,0 +1,17 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/workflow'
5
+
6
+ class TestWorkflowUtil < Test::Unit::TestCase
7
+ def test_annonymous_workflow
8
+ wf = Workflow.annonymous_workflow "TEST" do
9
+ task :length => :integer do
10
+ self.length
11
+ end
12
+ end
13
+ bindings = "12345"
14
+ assert_equal 5, wf.tasks[:length].exec_on(bindings)
15
+ end
16
+ end
17
+
data/test/test_helper.rb CHANGED
@@ -22,6 +22,23 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
22
22
  #require 'scout/helper/misc/development'
23
23
  require 'scout/tmpfile'
24
24
  require 'scout/log'
25
+ require 'scout/persist'
26
+ require 'scout/workflow'
25
27
 
26
28
  class Test::Unit::TestCase
29
+
30
+ def tmpdir
31
+ @tmpdir = Path.setup('tmp/test_tmpdir').find
32
+ end
33
+
34
+ setup do
35
+ Persist.cache_dir = tmpdir.var.cache
36
+ Open.remote_cache_dir = tmpdir.var.cache
37
+ Workflow.directory = tmpdir.var.jobs
38
+ Workflow.workflows.each{|wf| wf.directory = Workflow.directory[wf.name] }
39
+ end
40
+
41
+ teardown do
42
+ Open.rm_rf tmpdir
43
+ end
27
44
  end
File without changes
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: 1.2.0
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-24 00:00:00.000000000 Z
11
+ date: 2023-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -90,6 +90,7 @@ extra_rdoc_files:
90
90
  - README.rdoc
91
91
  files:
92
92
  - ".document"
93
+ - ".gitmodules"
93
94
  - ".vimproject"
94
95
  - LICENSE.txt
95
96
  - README.rdoc
@@ -97,6 +98,9 @@ files:
97
98
  - VERSION
98
99
  - bin/scout
99
100
  - lib/scout-gear.rb
101
+ - lib/scout.rb
102
+ - lib/scout/cmd.rb
103
+ - lib/scout/concurrent_stream.rb
100
104
  - lib/scout/exceptions.rb
101
105
  - lib/scout/indiferent_hash.rb
102
106
  - lib/scout/indiferent_hash/case_insensitive.rb
@@ -110,22 +114,91 @@ files:
110
114
  - lib/scout/log/progress/util.rb
111
115
  - lib/scout/meta_extension.rb
112
116
  - lib/scout/misc.rb
117
+ - lib/scout/misc/digest.rb
118
+ - lib/scout/misc/filesystem.rb
119
+ - lib/scout/misc/format.rb
120
+ - lib/scout/misc/insist.rb
121
+ - lib/scout/open.rb
122
+ - lib/scout/open/lock.rb
123
+ - lib/scout/open/remote.rb
124
+ - lib/scout/open/stream.rb
125
+ - lib/scout/open/util.rb
113
126
  - lib/scout/path.rb
114
127
  - lib/scout/path/find.rb
128
+ - lib/scout/path/tmpfile.rb
115
129
  - lib/scout/path/util.rb
130
+ - lib/scout/persist.rb
131
+ - lib/scout/persist/open.rb
132
+ - lib/scout/persist/path.rb
133
+ - lib/scout/persist/serialize.rb
134
+ - lib/scout/resource.rb
135
+ - lib/scout/resource/path.rb
136
+ - lib/scout/resource/produce.rb
137
+ - lib/scout/resource/produce/rake.rb
138
+ - lib/scout/resource/scout.rb
139
+ - lib/scout/simple_opt.rb
140
+ - lib/scout/simple_opt/accessor.rb
141
+ - lib/scout/simple_opt/doc.rb
142
+ - lib/scout/simple_opt/get.rb
143
+ - lib/scout/simple_opt/parse.rb
144
+ - lib/scout/simple_opt/setup.rb
116
145
  - lib/scout/tmpfile.rb
146
+ - lib/scout/workflow.rb
147
+ - lib/scout/workflow/definition.rb
148
+ - lib/scout/workflow/documentation.rb
149
+ - lib/scout/workflow/step.rb
150
+ - lib/scout/workflow/step/info.rb
151
+ - lib/scout/workflow/task.rb
152
+ - lib/scout/workflow/task/inputs.rb
153
+ - lib/scout/workflow/usage.rb
154
+ - lib/scout/workflow/util.rb
155
+ - lib/workflow-scout.rb
117
156
  - scout-gear.gemspec
157
+ - scout_commands/alias
158
+ - scout_commands/find
159
+ - scout_commands/glob
160
+ - scout_commands/rbbt
161
+ - scout_commands/workflow/task
162
+ - test/scout/indiferent_hash/test_case_insensitive.rb
118
163
  - test/scout/indiferent_hash/test_options.rb
119
164
  - test/scout/log/test_progress.rb
165
+ - test/scout/misc/test_digest.rb
166
+ - test/scout/misc/test_filesystem.rb
167
+ - test/scout/misc/test_insist.rb
168
+ - test/scout/open/test_lock.rb
169
+ - test/scout/open/test_remote.rb
170
+ - test/scout/open/test_stream.rb
171
+ - test/scout/open/test_util.rb
120
172
  - test/scout/path/test_find.rb
121
173
  - test/scout/path/test_util.rb
174
+ - test/scout/persist/test_open.rb
175
+ - test/scout/persist/test_path.rb
176
+ - test/scout/persist/test_serialize.rb
177
+ - test/scout/resource/test_path.rb
178
+ - test/scout/resource/test_produce.rb
179
+ - test/scout/simple_opt/test_get.rb
180
+ - test/scout/simple_opt/test_parse.rb
181
+ - test/scout/simple_opt/test_setup.rb
182
+ - test/scout/test_cmd.rb
183
+ - test/scout/test_concurrent_stream.rb
122
184
  - test/scout/test_indiferent_hash.rb
123
185
  - test/scout/test_log.rb
124
186
  - test/scout/test_meta_extension.rb
125
187
  - test/scout/test_misc.rb
188
+ - test/scout/test_open.rb
126
189
  - test/scout/test_path.rb
190
+ - test/scout/test_persist.rb
191
+ - test/scout/test_resource.rb
127
192
  - test/scout/test_tmpfile.rb
193
+ - test/scout/test_workflow.rb
194
+ - test/scout/workflow/step/test_info.rb
195
+ - test/scout/workflow/task/test_inputs.rb
196
+ - test/scout/workflow/test_step.rb
197
+ - test/scout/workflow/test_task.rb
198
+ - test/scout/workflow/test_usage.rb
199
+ - test/scout/workflow/test_util.rb
128
200
  - test/test_helper.rb
201
+ - test/test_scout-gear.rb
129
202
  homepage: http://github.com/mikisvaz/scout-gear
130
203
  licenses:
131
204
  - MIT
@@ -145,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
218
  - !ruby/object:Gem::Version
146
219
  version: '0'
147
220
  requirements: []
148
- rubygems_version: 3.4.6
221
+ rubygems_version: 3.4.11
149
222
  signing_key:
150
223
  specification_version: 4
151
224
  summary: basic gear for scouts