scout-gear 2.0.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +65 -2
  3. data/Rakefile +2 -0
  4. data/VERSION +1 -1
  5. data/bin/scout +233 -24
  6. data/lib/scout/cmd.rb +344 -0
  7. data/lib/scout/concurrent_stream.rb +259 -0
  8. data/lib/scout/exceptions.rb +15 -8
  9. data/lib/scout/indiferent_hash/options.rb +8 -26
  10. data/lib/scout/log/color.rb +2 -2
  11. data/lib/scout/log/fingerprint.rb +11 -1
  12. data/lib/scout/log/progress/report.rb +0 -1
  13. data/lib/scout/log/progress/util.rb +1 -1
  14. data/lib/scout/log/progress.rb +4 -4
  15. data/lib/scout/log.rb +10 -2
  16. data/lib/scout/meta_extension.rb +19 -3
  17. data/lib/scout/misc/digest.rb +56 -0
  18. data/lib/scout/misc/filesystem.rb +26 -0
  19. data/lib/scout/misc/format.rb +17 -6
  20. data/lib/scout/misc/insist.rb +56 -0
  21. data/lib/scout/misc/monitor.rb +23 -0
  22. data/lib/scout/misc.rb +5 -11
  23. data/lib/scout/open/lock.rb +61 -0
  24. data/lib/scout/open/remote.rb +120 -0
  25. data/lib/scout/open/stream.rb +373 -0
  26. data/lib/scout/open/util.rb +225 -0
  27. data/lib/scout/open.rb +169 -0
  28. data/lib/scout/path/find.rb +68 -21
  29. data/lib/scout/path/tmpfile.rb +8 -0
  30. data/lib/scout/path/util.rb +14 -1
  31. data/lib/scout/path.rb +6 -30
  32. data/lib/scout/persist/open.rb +17 -0
  33. data/lib/scout/persist/path.rb +15 -0
  34. data/lib/scout/persist/serialize.rb +151 -0
  35. data/lib/scout/persist.rb +54 -0
  36. data/lib/scout/resource/path.rb +20 -0
  37. data/lib/scout/resource/produce/rake.rb +69 -0
  38. data/lib/scout/resource/produce.rb +246 -0
  39. data/lib/scout/resource/scout.rb +3 -0
  40. data/lib/scout/resource/util.rb +48 -0
  41. data/lib/scout/resource.rb +39 -0
  42. data/lib/scout/simple_opt/accessor.rb +1 -1
  43. data/lib/scout/simple_opt/doc.rb +29 -23
  44. data/lib/scout/simple_opt/parse.rb +4 -3
  45. data/lib/scout/tmpfile.rb +39 -1
  46. data/lib/scout/workflow/definition.rb +78 -0
  47. data/lib/scout/workflow/documentation.rb +83 -0
  48. data/lib/scout/workflow/step/info.rb +77 -0
  49. data/lib/scout/workflow/step/load.rb +18 -0
  50. data/lib/scout/workflow/step.rb +132 -0
  51. data/lib/scout/workflow/task/inputs.rb +114 -0
  52. data/lib/scout/workflow/task.rb +155 -0
  53. data/lib/scout/workflow/usage.rb +314 -0
  54. data/lib/scout/workflow/util.rb +11 -0
  55. data/lib/scout/workflow.rb +40 -0
  56. data/lib/scout-gear.rb +4 -0
  57. data/lib/scout.rb +1 -0
  58. data/lib/workflow-scout.rb +2 -0
  59. data/scout-gear.gemspec +77 -5
  60. data/scout_commands/alias +48 -0
  61. data/scout_commands/find +83 -0
  62. data/scout_commands/glob +0 -0
  63. data/scout_commands/rbbt +23 -0
  64. data/scout_commands/workflow/info +29 -0
  65. data/scout_commands/workflow/list +27 -0
  66. data/scout_commands/workflow/task +58 -0
  67. data/scout_commands/workflow/task_old +706 -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 +28 -0
  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/resource/test_util.rb +27 -0
  83. data/test/scout/simple_opt/test_doc.rb +16 -0
  84. data/test/scout/test_cmd.rb +85 -0
  85. data/test/scout/test_concurrent_stream.rb +29 -0
  86. data/test/scout/test_meta_extension.rb +9 -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 +30 -0
  94. data/test/scout/workflow/step/test_load.rb +65 -0
  95. data/test/scout/workflow/task/test_inputs.rb +182 -0
  96. data/test/scout/workflow/test_definition.rb +0 -0
  97. data/test/scout/workflow/test_documentation.rb +30 -0
  98. data/test/scout/workflow/test_step.rb +36 -0
  99. data/test/scout/workflow/test_task.rb +179 -0
  100. data/test/scout/workflow/test_usage.rb +35 -0
  101. data/test/scout/workflow/test_util.rb +17 -0
  102. data/test/test_helper.rb +17 -0
  103. data/test/test_scout-gear.rb +0 -0
  104. metadata +75 -3
@@ -0,0 +1,36 @@
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 TestWorkflowStep < Test::Unit::TestCase
5
+
6
+ def test_step
7
+ TmpFile.with_file do |tmpfile|
8
+ step = Step.new tmpfile, ["12"] do |s|
9
+ s.length
10
+ end
11
+ step.type = :integer
12
+
13
+ assert_equal 2, step.run
14
+ end
15
+ end
16
+
17
+ def test_dependency
18
+ Log.with_severity 0 do
19
+ tmpfile = tmpdir.test_step
20
+ step1 = Step.new tmpfile.step1, ["12"] do |s|
21
+ s.length
22
+ end
23
+
24
+ step2 = Step.new tmpfile.step2 do
25
+ step1 = dependencies.first
26
+ step1.inputs.first + " has " + step1.load.to_s + " characters"
27
+ end
28
+
29
+ step2.dependencies = [step1]
30
+
31
+
32
+ assert_equal "12 has 2 characters", step2.run
33
+ assert_equal "12 has 2 characters", step2.run
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,179 @@
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
+ s.clean
21
+ assert_equal 2, s.run
22
+ end
23
+
24
+ def test_override_inputs
25
+ wf = Workflow.annonymous_workflow "TaskInputs" do
26
+ input :input1, :string
27
+ task :step1 => :string do |i| i end
28
+
29
+ dep :step1, :input1 => 1
30
+ input :input2, :string
31
+ task :step2 => :string do |i| i end
32
+ end
33
+
34
+ job = wf.job(:step2, :input1 => 2)
35
+ assert_equal Task::DEFAULT_NAME, job.name
36
+ assert_not_equal Task::DEFAULT_NAME, job.step(:step1).name
37
+ end
38
+
39
+ def test_override_inputs_block
40
+ Log.severity = 0
41
+ wf = Workflow.annonymous_workflow "TaskInputs" do
42
+ input :input1, :string
43
+ task :step1 => :string do |i| i end
44
+
45
+ dep :step1 do |id,options|
46
+ {:inputs => {:input1 => 1}}
47
+ end
48
+ input :input2, :string
49
+ task :step2 => :string do |i| i end
50
+ end
51
+
52
+ job = wf.job(:step2, :input1 => 2)
53
+ assert_equal Task::DEFAULT_NAME, job.name
54
+ assert_not_equal Task::DEFAULT_NAME, job.step(:step1).name
55
+ end
56
+
57
+ def test_task_override_dep
58
+ Log.severity = 0
59
+ wf = Workflow.annonymous_workflow "TaskInputs" do
60
+ input :input1, :integer
61
+ task :step1 => :integer do |i| i end
62
+
63
+ dep :step1
64
+ input :input2, :integer, "Integer", 3
65
+ task :step2 => :integer do |i| i * step(:step1).load end
66
+ end
67
+
68
+ assert_equal 6, wf.job(:step2, :input1 => 2, :input2 => 3).run
69
+
70
+ step1_job = wf.job(:step1, :input1 => 6)
71
+ assert_equal 18, wf.job(:step2, :input1 => 2, "TaskInputs#step1" => step1_job).run
72
+
73
+ assert_equal 18, wf.job(:step2, :input1 => 2, "TaskInputs#step1" => step1_job).run
74
+
75
+ assert_equal 18, wf.job(:step2, "TaskInputs#step1" => step1_job).run
76
+ end
77
+
78
+ def test_input_dep
79
+ wf = Workflow.annonymous_workflow "TaskInputs" do
80
+ input :v1, :integer
81
+ input :v2, :integer
82
+ task :sum => :integer do |v1,v2|
83
+ v1 + v2
84
+ end
85
+
86
+ input :input1, :integer
87
+ task :step1 => :integer do |i| i end
88
+
89
+ input :input2, :integer
90
+ task :step2 => :integer do |i| i end
91
+
92
+ dep :step1, :input1 => 2
93
+ dep :step2, :input2 => 3
94
+ dep :sum, :v1 => :step1, :v2 => :step2
95
+ task :my_sum => :integer do
96
+ dependencies.last.load
97
+ end
98
+
99
+ dep :my_sum
100
+ task :double => :integer do
101
+ step(:my_sum).load * 2
102
+ end
103
+ end
104
+
105
+ job = wf.job(:my_sum)
106
+ assert_equal 5, job.run
107
+ assert_equal Task::DEFAULT_NAME, job.name
108
+
109
+ job = wf.job(:double)
110
+ assert_equal Task::DEFAULT_NAME, job.name
111
+
112
+ step1 = wf.job(:step1, :input1 => 3)
113
+ job = wf.job(:double, "TaskInputs#step1" => step1)
114
+ assert_equal 12, job.run
115
+ assert_not_equal Task::DEFAULT_NAME, job.name
116
+
117
+ step1 = wf.job(:step1, :input1 => 4)
118
+ job = wf.job(:double, "TaskInputs#step1" => step1)
119
+ assert_equal 14, job.run
120
+ assert_not_equal Task::DEFAULT_NAME, job.name
121
+ end
122
+
123
+ def test_input_dep_override
124
+ wf = Workflow.annonymous_workflow "TaskInputs" do
125
+ input :v1, :integer
126
+ input :v2, :integer
127
+ task :sum => :integer do |v1,v2|
128
+ v1 + v2
129
+ end
130
+
131
+ input :input1, :integer
132
+ task :step1 => :integer do |i| i end
133
+
134
+ input :input2, :integer
135
+ task :step2 => :integer do |i| i end
136
+
137
+ dep :step1
138
+ dep :step2
139
+ task :my_sum => :integer do
140
+ dependencies.inject(0){|acc,d| acc += d.load }
141
+ end
142
+ end
143
+
144
+ step2 = wf.job(:step2, :input2 => 4)
145
+ job = wf.job(:my_sum, :input1 => 2, :input2 => 3, "TaskInputs#step2"=> step2)
146
+ assert_equal 6, job.exec
147
+
148
+ job = wf.job(:my_sum, :input1 => 2, :input2 => 3)
149
+ assert_equal 5, job.run
150
+
151
+ TmpFile.with_file(4) do |file|
152
+ job = wf.job(:my_sum, :input1 => 2, :input2 => 3, "TaskInputs#step2"=> file)
153
+ assert_equal 6, job.run
154
+ assert_not_equal Task::DEFAULT_NAME, job.name
155
+ end
156
+ end
157
+
158
+ def test_input_rename
159
+ wf = Workflow.annonymous_workflow "TaskInputs" do
160
+ input :v1, :integer
161
+ input :v2, :integer
162
+ task :sum => :integer do |v1,v2|
163
+ v1 + v2
164
+ end
165
+
166
+ input :vv1, :integer
167
+ input :vv2, :integer
168
+ dep :sum, :v1 => :vv1, :v2 => :vv2
169
+ task :my_sum => :integer do
170
+ dependencies.last.load
171
+ end
172
+ end
173
+
174
+ Log.severity = 0
175
+ job = wf.job(:my_sum, :vv1 => 2, :vv2 => 3)
176
+ assert_equal 5, job.run
177
+ end
178
+ end
179
+
@@ -0,0 +1,35 @@
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
+ self.name = "UsageWorkflow"
10
+
11
+ self.title = "Workflow to test documentation"
12
+ self.description = "Use this workflow to test if the documentation is correctly presented."
13
+
14
+ desc "Desc"
15
+ input :array, :array, "Array"
16
+ task :step1 => :string do
17
+ end
18
+
19
+ dep :step1
20
+ desc "Desc2"
21
+ input :float, :float, "Float"
22
+ task :step2 => :string do
23
+ end
24
+ end
25
+
26
+
27
+ def test_workflow_usage
28
+ assert_match "test if the documentation", UsageWorkflow.usage
29
+ end
30
+
31
+ def test_task_usage
32
+ assert_match "Desc2", UsageWorkflow.tasks[:step2].usage
33
+ end
34
+ end
35
+
@@ -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: 2.0.0
4
+ version: 5.2.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: 2023-03-30 00:00:00.000000000 Z
11
+ date: 2023-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -98,6 +98,9 @@ files:
98
98
  - VERSION
99
99
  - bin/scout
100
100
  - lib/scout-gear.rb
101
+ - lib/scout.rb
102
+ - lib/scout/cmd.rb
103
+ - lib/scout/concurrent_stream.rb
101
104
  - lib/scout/exceptions.rb
102
105
  - lib/scout/indiferent_hash.rb
103
106
  - lib/scout/indiferent_hash/case_insensitive.rb
@@ -111,10 +114,30 @@ files:
111
114
  - lib/scout/log/progress/util.rb
112
115
  - lib/scout/meta_extension.rb
113
116
  - lib/scout/misc.rb
117
+ - lib/scout/misc/digest.rb
118
+ - lib/scout/misc/filesystem.rb
114
119
  - lib/scout/misc/format.rb
120
+ - lib/scout/misc/insist.rb
121
+ - lib/scout/misc/monitor.rb
122
+ - lib/scout/open.rb
123
+ - lib/scout/open/lock.rb
124
+ - lib/scout/open/remote.rb
125
+ - lib/scout/open/stream.rb
126
+ - lib/scout/open/util.rb
115
127
  - lib/scout/path.rb
116
128
  - lib/scout/path/find.rb
129
+ - lib/scout/path/tmpfile.rb
117
130
  - lib/scout/path/util.rb
131
+ - lib/scout/persist.rb
132
+ - lib/scout/persist/open.rb
133
+ - lib/scout/persist/path.rb
134
+ - lib/scout/persist/serialize.rb
135
+ - lib/scout/resource.rb
136
+ - lib/scout/resource/path.rb
137
+ - lib/scout/resource/produce.rb
138
+ - lib/scout/resource/produce/rake.rb
139
+ - lib/scout/resource/scout.rb
140
+ - lib/scout/resource/util.rb
118
141
  - lib/scout/simple_opt.rb
119
142
  - lib/scout/simple_opt/accessor.rb
120
143
  - lib/scout/simple_opt/doc.rb
@@ -122,22 +145,71 @@ files:
122
145
  - lib/scout/simple_opt/parse.rb
123
146
  - lib/scout/simple_opt/setup.rb
124
147
  - lib/scout/tmpfile.rb
148
+ - lib/scout/workflow.rb
149
+ - lib/scout/workflow/definition.rb
150
+ - lib/scout/workflow/documentation.rb
151
+ - lib/scout/workflow/step.rb
152
+ - lib/scout/workflow/step/info.rb
153
+ - lib/scout/workflow/step/load.rb
154
+ - lib/scout/workflow/task.rb
155
+ - lib/scout/workflow/task/inputs.rb
156
+ - lib/scout/workflow/usage.rb
157
+ - lib/scout/workflow/util.rb
158
+ - lib/workflow-scout.rb
125
159
  - scout-gear.gemspec
160
+ - scout_commands/alias
161
+ - scout_commands/find
162
+ - scout_commands/glob
163
+ - scout_commands/rbbt
164
+ - scout_commands/workflow/info
165
+ - scout_commands/workflow/list
166
+ - scout_commands/workflow/task
167
+ - scout_commands/workflow/task_old
126
168
  - test/scout/indiferent_hash/test_case_insensitive.rb
127
169
  - test/scout/indiferent_hash/test_options.rb
128
170
  - test/scout/log/test_progress.rb
171
+ - test/scout/misc/test_digest.rb
172
+ - test/scout/misc/test_filesystem.rb
173
+ - test/scout/misc/test_insist.rb
174
+ - test/scout/open/test_lock.rb
175
+ - test/scout/open/test_remote.rb
176
+ - test/scout/open/test_stream.rb
177
+ - test/scout/open/test_util.rb
129
178
  - test/scout/path/test_find.rb
130
179
  - test/scout/path/test_util.rb
180
+ - test/scout/persist/test_open.rb
181
+ - test/scout/persist/test_path.rb
182
+ - test/scout/persist/test_serialize.rb
183
+ - test/scout/resource/test_path.rb
184
+ - test/scout/resource/test_produce.rb
185
+ - test/scout/resource/test_util.rb
186
+ - test/scout/simple_opt/test_doc.rb
131
187
  - test/scout/simple_opt/test_get.rb
132
188
  - test/scout/simple_opt/test_parse.rb
133
189
  - test/scout/simple_opt/test_setup.rb
190
+ - test/scout/test_cmd.rb
191
+ - test/scout/test_concurrent_stream.rb
134
192
  - test/scout/test_indiferent_hash.rb
135
193
  - test/scout/test_log.rb
136
194
  - test/scout/test_meta_extension.rb
137
195
  - test/scout/test_misc.rb
196
+ - test/scout/test_open.rb
138
197
  - test/scout/test_path.rb
198
+ - test/scout/test_persist.rb
199
+ - test/scout/test_resource.rb
139
200
  - test/scout/test_tmpfile.rb
201
+ - test/scout/test_workflow.rb
202
+ - test/scout/workflow/step/test_info.rb
203
+ - test/scout/workflow/step/test_load.rb
204
+ - test/scout/workflow/task/test_inputs.rb
205
+ - test/scout/workflow/test_definition.rb
206
+ - test/scout/workflow/test_documentation.rb
207
+ - test/scout/workflow/test_step.rb
208
+ - test/scout/workflow/test_task.rb
209
+ - test/scout/workflow/test_usage.rb
210
+ - test/scout/workflow/test_util.rb
140
211
  - test/test_helper.rb
212
+ - test/test_scout-gear.rb
141
213
  homepage: http://github.com/mikisvaz/scout-gear
142
214
  licenses:
143
215
  - MIT
@@ -157,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
229
  - !ruby/object:Gem::Version
158
230
  version: '0'
159
231
  requirements: []
160
- rubygems_version: 3.4.6
232
+ rubygems_version: 3.4.11
161
233
  signing_key:
162
234
  specification_version: 4
163
235
  summary: basic gear for scouts