laborantin 0.0.10 → 0.0.12

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.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
3
3
 
4
4
  spec = Gem::Specification.new do |s|
5
5
  s.name = 'laborantin'
6
- s.version = '0.0.10'
6
+ s.version = '0.0.12'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.summary = "A measurement batch facilitator"
9
9
 
data/bin/labor CHANGED
@@ -9,12 +9,24 @@ require 'find'
9
9
  require 'erb'
10
10
  require 'yaml'
11
11
  require 'net/ftp'
12
+ require 'logger'
12
13
 
13
14
  class Command
14
15
  attr_accessor :name, :description, :parser, :block, :options, :args
15
16
 
16
17
  @@all = []
17
18
 
19
+ def find_and_require(dir, filter=[])
20
+ Find.find(dir) do |f|
21
+ test = if filter.empty?
22
+ File.extname(f) == '.rb'
23
+ else
24
+ filter.include? File.basename(f)
25
+ end
26
+ require f if test
27
+ end
28
+ end
29
+
18
30
  def initialize(name, description='')
19
31
  @@all << self
20
32
  @name = name
@@ -66,9 +78,9 @@ Command.new('create', 'prepares a dir for laborantin measurements') do |c|
66
78
  c.options[:environments] = []
67
79
  c.options[:force] = false
68
80
  c.opts do |o|
69
- o.on('-s', '--scenarii=OPTIONAL', 'scenarii to build, comma separated', Array) {|c.options[:scenarii]|}
70
- o.on('-e', '--environments=OPTIONAL', 'environments to prepare, comma separated', Array) {|c.options[:environments]|}
71
- o.on_tail('-f', '--force', 'force overwrite') {|c.options[:force]|}
81
+ o.on('-s', '--scenarii=OPTIONAL', 'scenarii to build, comma separated', Array) {|val| c.options[:scenarii] = val}
82
+ o.on('-e', '--environments=OPTIONAL', 'environments to prepare, comma separated', Array) {|val| c.options[:environments] = val}
83
+ o.on_tail('-f', '--force', 'force overwrite') {|val| c.options[:force] = val}
72
84
  o.on_tail('-h', '--help', 'shows this help and exit') {puts o; exit}
73
85
  end
74
86
 
@@ -136,14 +148,19 @@ end
136
148
  # Describe
137
149
 
138
150
  Command.new('describe', "describes a laborantin's work") do |c|
151
+ c.options[:environments] = []
152
+ c.options[:scenarii] = []
139
153
  c.opts do |o|
154
+ o.on('-s', '--scenarii=OPTIONAL', 'scenarii to build, comma separated', Array) {|val| c.options[:scenarii] = val}
155
+ o.on('-e', '--environments=OPTIONAL', 'environments to prepare, comma separated', Array) {|val| c.options[:environments] = val}
140
156
  o.on_tail('-h', '--help', 'shows this help and exit') {puts o; exit}
141
157
  end
142
158
  c.execute do
143
159
  FileUtils.cd(args.first || '.')
144
- Find.find('environments', 'scenarii') do |f|
145
- require f if File.extname(f) == '.rb'
146
- end
160
+ loaded_envs = c.options[:environments].map{|e| "#{e}.rb"}
161
+ loaded_scii = c.options[:scenarii].map{|e| "#{e}.rb"}
162
+ find_and_require('environments', loaded_envs)
163
+ find_and_require('scenarii', loaded_scii)
147
164
 
148
165
  Laborantin::Environment.all.each {|e| p e}
149
166
  Laborantin::Scenario.all.each {|s| p s}
@@ -153,14 +170,21 @@ end
153
170
  # Scan
154
171
 
155
172
  Command.new('scan', "scan a laborantin's dir for results") do |c|
173
+ c.options[:filter] = ''
174
+ c.options[:environments] = []
175
+ c.options[:scenarii] = []
156
176
  c.opts do |o|
177
+ o.on('-s', '--scenarii=OPTIONAL', 'scenarii to build, comma separated', Array) {|val| c.options[:scenarii] = val}
178
+ o.on('-e', '--environments=OPTIONAL', 'environments to prepare, comma separated', Array) {|val| c.options[:environments] = val}
179
+ o.on('-p', '--parameters=OPTIONAL', 'filter parameters (ruby hash format)', String) {|val| c.options[:filter] = val}
157
180
  o.on_tail('-h', '--help', 'shows this help and exit') {puts o; exit}
158
181
  end
159
182
  c.execute do
160
183
  FileUtils.cd(args.first || '.')
161
- Find.find('environments', 'scenarii') do |f|
162
- require f if File.extname(f) == '.rb'
163
- end
184
+ loaded_envs = c.options[:environments].map{|e| "#{e}.rb"}
185
+ loaded_scii = c.options[:scenarii].map{|e| "#{e}.rb"}
186
+ find_and_require('environments', loaded_envs)
187
+ find_and_require('scenarii', loaded_scii)
164
188
 
165
189
  envs = Laborantin::Environment.scan_resdir('results')
166
190
 
@@ -177,6 +201,70 @@ Command.new('scan', "scan a laborantin's dir for results") do |c|
177
201
  end
178
202
  end
179
203
 
204
+ # Find
205
+
206
+ Command.new('find', "find the results dir for a set of params/env") do |c|
207
+ c.options[:filter] = ''
208
+ c.options[:environments] = []
209
+ c.options[:scenarii] = []
210
+ c.opts do |o|
211
+ o.on('-s', '--scenarii=OPTIONAL', 'scenarii to build, comma separated', Array) {|val| c.options[:scenarii] = val}
212
+ o.on('-e', '--environments=OPTIONAL', 'environments to prepare, comma separated', Array) {|val| c.options[:environments] = val}
213
+ o.on('-p', '--parameters=OPTIONAL', 'filter parameters (ruby hash format)', String) {|val| c.options[:filter] = val}
214
+ o.on_tail('-h', '--help', 'shows this help and exit') {puts o; exit}
215
+ end
216
+ c.execute do
217
+
218
+ FileUtils.cd(args.first || '.')
219
+ loaded_envs = c.options[:environments].map{|e| "#{e}.rb"}
220
+ loaded_scii = c.options[:scenarii].map{|e| "#{e}.rb"}
221
+ find_and_require('environments', loaded_envs)
222
+ find_and_require('scenarii', loaded_scii)
223
+
224
+ envs = Laborantin::Environment.scan_resdir('results')
225
+
226
+ params = eval @options[:filter] unless @options[:filter].empty?
227
+ params.each_key{|k| params[k] = [params[k]].flatten} if params
228
+ params ||= {}
229
+
230
+ scs = envs.map{|env| env.populate }.flatten
231
+
232
+ scs.each do |sc|
233
+ to_filter = params.keys.find{|k| not params[k].include?(sc.params[k])}
234
+ unless to_filter
235
+ puts sc.rundir
236
+ puts sc.params.inspect
237
+ end
238
+ end
239
+ end
240
+ end
241
+
242
+ # Replay
243
+
244
+ Command.new('replay', 'scan existing runs, keep their raw results but rebuild all the products') do |c|
245
+ c.opts do |o|
246
+ o.on_tail('-h', '--help', 'shows this help and exit') {puts o; exit}
247
+ end
248
+ c.execute do
249
+ FileUtils.cd(args.first || '.')
250
+ Find.find('environments', 'scenarii') do |f|
251
+ require f if File.extname(f) == '.rb'
252
+ end
253
+
254
+ envs = Laborantin::Environment.scan_resdir('results')
255
+ envs.each{|env| env.loggers << Logger.new(STDOUT)}
256
+
257
+ scs = envs.map{|env| env.populate }.flatten
258
+
259
+ puts "Replaying everything"
260
+
261
+ scs.each do |sc|
262
+ sc.environment.log "Replaying products #{sc.params.inspect}"
263
+ sc.analyze!
264
+ end
265
+ end
266
+ end
267
+
180
268
  # Run
181
269
 
182
270
  Command.new('run', 'actually perform measurements') do |c|
@@ -184,9 +272,9 @@ Command.new('run', 'actually perform measurements') do |c|
184
272
  c.options[:environments] = []
185
273
  c.options[:filter] = ''
186
274
  c.opts do |o|
187
- o.on('-s', '--scenarii=OPTIONAL', 'scenarii to build, comma separated', Array) {|c.options[:scenarii]|}
188
- o.on('-e', '--environments=OPTIONAL', 'environments to prepare, comma separated', Array) {|c.options[:environments]|}
189
- o.on('-p', '--parameters=OPTIONAL', 'filter parameters (ruby hash format)', String) {|c.options[:filter]|}
275
+ o.on('-s', '--scenarii=OPTIONAL', 'scenarii to build, comma separated', Array) {|val| c.options[:scenarii] = val}
276
+ o.on('-e', '--environments=OPTIONAL', 'environments to prepare, comma separated', Array) {|val| c.options[:environments] = val}
277
+ o.on('-p', '--parameters=OPTIONAL', 'filter parameters (ruby hash format)', String) {|val| c.options[:filter] = val}
190
278
  o.on_tail('-h', '--help', 'shows this help and exit') {puts o; exit}
191
279
  end
192
280
  c.execute do
@@ -235,6 +323,9 @@ Command.new('run', 'actually perform measurements') do |c|
235
323
  end
236
324
  end
237
325
 
326
+ # Run missing
327
+ # TODO scan existing params + filter
328
+
238
329
  # FTP
239
330
 
240
331
  Command.new('ftp-up', 'upload results via FTP') do |c|
data/lib/laborantin.rb CHANGED
@@ -28,7 +28,7 @@ require File.join(File.dirname(__FILE__), 'laborantin', 'core', 'environment')
28
28
  require File.join(File.dirname(__FILE__), 'laborantin', 'core', 'monkey_patches')
29
29
 
30
30
  module Laborantin
31
- VERSION = '0.0.10'
31
+ VERSION = '0.0.12'
32
32
  AUTHORS = ['Lucas Di Cioccio']
33
33
  WEBSITE = 'http://dicioccio.fr'
34
34
  LICENSE = 'GNU GPL version 3'
@@ -57,7 +57,8 @@ module Laborantin
57
57
  scenar = scklass.new(env)
58
58
  scs << scenar
59
59
  scenar.rundir = File.join(scklass.scenardir(env), r)
60
- YAML.load_file(File.join(scenar.rundir, 'config.yaml'))
60
+ tst, params = YAML.load_file(File.join(scenar.rundir, 'config.yaml'))
61
+ scenar.params = params
61
62
  end
62
63
  end
63
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laborantin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Di Cioccio Lucas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-28 00:00:00 +02:00
12
+ date: 2009-09-15 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15