nera 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.6.0
2
+ * 1 major enhancement:
3
+ * Implemented a new API functions.
4
+ * an API function is renamed.
5
+ * 2 bug fixes:
6
+
1
7
  == 0.5.2
2
8
  * 1 major enhancement:
3
9
  * 2 bug fixes:
data/lib/nera/nera_cui.rb CHANGED
@@ -180,7 +180,7 @@ HEADER
180
180
  when "return to simulator layer"
181
181
  return :simulator_layer
182
182
  when "create a new parameter set"
183
- plist = plc.list_of_parameters( @parameter_id)
183
+ plist = plc.get_parameter( @parameter_id)
184
184
  new_param_hash = Dialog::set_multiple_values( plist, "Input the new parameter set")
185
185
  f = plc.create_a_new_parameter_set( new_param_hash)
186
186
  if f
@@ -30,6 +30,10 @@ module NERA
30
30
  return @db_folders.path_to_job_layer
31
31
  end
32
32
 
33
+ def not_finished_list
34
+ @job_records.list_all
35
+ end
36
+
33
37
  def not_finished_list_in_csv
34
38
  list = @job_records.list_all
35
39
  header = @job_records.keys.dup
@@ -58,6 +58,10 @@ module NERA
58
58
  end
59
59
 
60
60
  public
61
+ def parameters_list
62
+ @param_records.list_all
63
+ end
64
+
61
65
  def parameters_list_in_csv
62
66
  l_active = @param_records.list_active
63
67
  header = @param_records.keys.dup
@@ -108,7 +112,7 @@ module NERA
108
112
  return found_ids
109
113
  end
110
114
 
111
- def list_of_parameters( param_id = nil)
115
+ def get_parameter( param_id = nil)
112
116
  param_list = []
113
117
  @sim_class::Parameters.each do |elem| param_list << elem.dup end
114
118
  if param_id
@@ -119,6 +123,7 @@ module NERA
119
123
  end
120
124
  return param_list
121
125
  end
126
+ alias :list_of_parameters :get_parameter
122
127
 
123
128
  def path_to_param_layer
124
129
  return @db_folders.path_to_parameter_layer( @sim_class)
@@ -153,6 +153,42 @@ module NERA
153
153
  @db.find_by_id( id)
154
154
  end
155
155
 
156
+ # method to find similar parameter sets.
157
+ # argument ( parameter_id to compare, parameter name)
158
+ # return the array having arrays of [ found_id, values of the parameter].
159
+ # example:
160
+ # param_recs.find_similar_parameter_sets( 3, :L)
161
+ # # => [ [1,18],[2,22],[10,128] ]
162
+ # For this case, param_id 1,2,3,10 have the same parameters except for :L.
163
+ # :L for param_id 1, 2, 10 are 18, 22, and 128, respectively.
164
+ #
165
+ # If the parameter set specified by the first argument <param_id> is not found,
166
+ # nil is returned.
167
+ #
168
+ # If the simulator does not have the parameter specified by the second argument <param>,
169
+ # nil is returned.
170
+ #
171
+ # If a similar parameter is not found, [] is returned.
172
+ def find_similar_parameter_sets( param_id, param_key)
173
+ return nil unless @sim_class::Parameters.any? do |prm| prm[0] == param_key end
174
+ found = find_by_id( param_id.to_i)
175
+ return nil unless found
176
+ match = {}
177
+ @sim_class::Parameters.each do |prm|
178
+ next if prm[0] == param_key
179
+ match[ prm[0] ] = prm[2]
180
+ match[ prm[0] ] = found[ prm[0] ] if found.has_key?( prm[0] )
181
+ end
182
+ list = @db.find_all do |r|
183
+ next if r[:id] == param_id
184
+ match.all? do |k, val| r[k] == val end
185
+ end
186
+
187
+ a = list.to_a.map do |rec| [ rec[:id], rec[param_key] ] end
188
+ sorted = a.sort_by do |elem| elem[1] end
189
+ return sorted
190
+ end
191
+
156
192
  def update_to_state_active( id)
157
193
  raise ArgumentError unless id.is_a?(Integer)
158
194
  found = @db.find_by_id( id)
@@ -61,6 +61,10 @@ module NERA
61
61
  def path_to_run_layer
62
62
  return @db_folders.path_to_run_layer( @sim_instance.class, @param_id)
63
63
  end
64
+
65
+ def all_runs_list
66
+ return @run_records.list_all
67
+ end
64
68
 
65
69
  def all_runs_list_in_csv
66
70
  list = @run_records.list_all
@@ -170,6 +174,10 @@ module NERA
170
174
  return destroyed_jobids
171
175
  end
172
176
 
177
+ def find_similar_parameter_sets(parameter_key)
178
+ @param_records.find_similar_parameter_sets( @param_id, parameter_key)
179
+ end
180
+
173
181
  def analysis_methods
174
182
  found = @sim_instance.public_methods.find_all do |meth|
175
183
  meth =~ /^analyze_/
data/lib/nera.rb CHANGED
@@ -22,5 +22,5 @@ require 'nera_simulator_records'
22
22
  require 'nera_remote_connector'
23
23
 
24
24
  module NERA
25
- VERSION = '0.5.2'
25
+ VERSION = '0.6.0'
26
26
  end
@@ -32,6 +32,55 @@ class TC_NERA_JOB_LAYER_CONTROLLER < Test::Unit::TestCase
32
32
  def test_path_to_job_layer
33
33
  assert_equal( @dbf.path_to_job_layer, @jlc.path_to_job_layer)
34
34
  end
35
+
36
+ def test_not_finished_list
37
+ l = @jlc.not_finished_list
38
+ assert_equal( 3, l.size)
39
+ assert_equal( 1, l[0][:id])
40
+ assert_equal( :created, l[0][:state])
41
+ assert_equal( "Ising", l[0][:simulator])
42
+ assert_equal( 1, l[0][:parameter_id])
43
+ assert_equal( 1, l[0][:run_id])
44
+ assert_equal( 1, l[0][:number_of_runs])
45
+ assert( l[0].has_key?(:created_at) )
46
+ assert( l[0].has_key?(:updated_at) )
47
+ assert_equal( 2, l[1][:id])
48
+ assert_equal( :created, l[1][:state])
49
+ assert_equal( "Ising", l[1][:simulator])
50
+ assert_equal( 1, l[1][:parameter_id])
51
+ assert_equal( 2, l[1][:run_id])
52
+ assert_equal( 1, l[1][:number_of_runs])
53
+ assert( l[1].has_key?(:created_at) )
54
+ assert( l[1].has_key?(:updated_at) )
55
+ assert_equal( 3, l[2][:id])
56
+ assert_equal( :created, l[2][:state])
57
+ assert_equal( "Ising", l[2][:simulator])
58
+ assert_equal( 1, l[2][:parameter_id])
59
+ assert_equal( 3, l[2][:run_id])
60
+ assert_equal( 1, l[2][:number_of_runs])
61
+ assert( l[2].has_key?(:created_at) )
62
+ assert( l[2].has_key?(:updated_at) )
63
+
64
+ f = @jlc.cancel_jobs( [2])
65
+ l = @jlc.not_finished_list
66
+ assert_equal( 2, l.size)
67
+ assert_equal( 1, l[0][:id])
68
+ assert_equal( :created, l[0][:state])
69
+ assert_equal( "Ising", l[0][:simulator])
70
+ assert_equal( 1, l[0][:parameter_id])
71
+ assert_equal( 1, l[0][:run_id])
72
+ assert_equal( 1, l[0][:number_of_runs])
73
+ assert( l[0].has_key?(:created_at) )
74
+ assert( l[0].has_key?(:updated_at) )
75
+ assert_equal( 3, l[1][:id])
76
+ assert_equal( :created, l[1][:state])
77
+ assert_equal( "Ising", l[1][:simulator])
78
+ assert_equal( 1, l[1][:parameter_id])
79
+ assert_equal( 3, l[1][:run_id])
80
+ assert_equal( 1, l[1][:number_of_runs])
81
+ assert( l[1].has_key?(:created_at) )
82
+ assert( l[1].has_key?(:updated_at) )
83
+ end
35
84
 
36
85
  def test_not_finished_list_in_csv
37
86
  h, l = @jlc.not_finished_list_in_csv
@@ -81,6 +81,21 @@ class TC_NERA_PARAM_LAYER_CONTROLLER < Test::Unit::TestCase
81
81
  assert( loaded[0].has_key?( :num_finished_runs) ) # format is converted when reverted
82
82
  assert( loaded[0].has_key?( :num_all_runs) )
83
83
  end
84
+
85
+ def test_parameter_sets_list
86
+ l = @plc.parameters_list
87
+ assert_equal( [], l)
88
+ l << {:id => 1}
89
+ l = @plc.parameters_list
90
+ assert_equal( [], l)
91
+ f = @plc.create_a_new_parameter_set( {:L => 96, :K => 0.25, :tmax => 128} )
92
+ l = @plc.parameters_list
93
+ assert_equal( 1, l.size)
94
+ assert_equal( 1, l[0][:id])
95
+ assert_equal( 96, l[0][:L])
96
+ assert_equal( 0.25, l[0][:K])
97
+ assert_equal( 128, l[0][:tmax])
98
+ end
84
99
 
85
100
  def test_parameters_list_in_csv
86
101
  header, list = @plc.parameters_list_in_csv
@@ -145,8 +160,8 @@ class TC_NERA_PARAM_LAYER_CONTROLLER < Test::Unit::TestCase
145
160
  assert_nil( @plc.find_ids_by_parameter_hash( {:L => 999}))
146
161
  end
147
162
 
148
- def test_list_of_parameters
149
- p1 = @plc.list_of_parameters
163
+ def test_get_parameter
164
+ p1 = @plc.get_parameter
150
165
  p2 = [ [:L, Integer, 32],
151
166
  [:K, Float, 0.223],
152
167
  [:tmax, Integer, 512]
@@ -154,14 +169,14 @@ class TC_NERA_PARAM_LAYER_CONTROLLER < Test::Unit::TestCase
154
169
  assert_equal( p2, p1)
155
170
 
156
171
  add_three
157
- p3 = @plc.list_of_parameters(2)
172
+ p3 = @plc.get_parameter(2)
158
173
  p4 = [ [:L, Integer, 64],
159
174
  [:K, Float, 0.02],
160
175
  [:tmax, Integer, 2]
161
176
  ]
162
177
  assert_equal( p4, p3)
163
178
 
164
- p5 = @plc.list_of_parameters(5)
179
+ p5 = @plc.get_parameter(5)
165
180
  pp p5
166
181
  assert_equal( p2, p5)
167
182
  end
@@ -228,6 +228,19 @@ class TC_NERA_PARAM_RECS < Test::Unit::TestCase
228
228
  @db.find_by_id("3")
229
229
  }
230
230
  end
231
+
232
+ def test_find_similar_parameter_sets
233
+ add_three
234
+ assert_nil( @db.find_similar_parameter_sets( 0, :L) )
235
+ assert_nil( @db.find_similar_parameter_sets( 1, :unknown) )
236
+ assert_nil( @db.find_similar_parameter_sets( 4, :tmax) )
237
+ assert_equal( [ [1, 32] ] , @db.find_similar_parameter_sets( 2, :L) )
238
+ assert_equal( [] , @db.find_similar_parameter_sets( 3, :L) )
239
+
240
+ p4 = { :L => 16, :K => 0.22, :tmax => 512 }
241
+ @db.add(p4)
242
+ assert_equal( [ [4,16],[1,32] ] , @db.find_similar_parameter_sets(2, :L) )
243
+ end
231
244
 
232
245
  def test_update_state
233
246
  add_three
@@ -46,6 +46,16 @@ class TC_NERA_RUN_LAYER_CONTROLLER < Test::Unit::TestCase
46
46
  assert_equal( @rlc.path_to_run_layer, @dbf.path_to_run_layer(Ising,1) )
47
47
  end
48
48
 
49
+ def test_all_runs_list
50
+ l = @rlc.all_runs_list
51
+ assert_equal( [], l)
52
+ @rlc.create_jobs( 2, 3)
53
+ l = @rlc.all_runs_list
54
+ assert_equal( 6, l.size)
55
+ assert( l.all? do |rec| rec.is_a?(Hash) end )
56
+ assert( l.all? do |rec| rec[:state]==:not_finished end )
57
+ end
58
+
49
59
  def test_all_runs_list_in_csv
50
60
  header, list = @rlc.all_runs_list_in_csv
51
61
  str = "id, state, created_at, job_id, seed, start_at, finish_at, included_at, real_time, user_time, host_name, omp_threads, mpi_processes"
@@ -187,6 +197,12 @@ class TC_NERA_RUN_LAYER_CONTROLLER < Test::Unit::TestCase
187
197
  assert_equal( 1, l.size)
188
198
  end
189
199
 
200
+ def test_find_similar_parameter_sets
201
+ assert_equal( [], @rlc.find_similar_parameter_sets( :L))
202
+ assert_equal( [], @rlc.find_similar_parameter_sets( :K))
203
+ assert_nil( @rlc.find_similar_parameter_sets( :unknown))
204
+ end
205
+
190
206
  def test_analyze
191
207
  logp = @db_folder+'/Tables/logfile.txt'
192
208
  s1 = File.open(logp,'r').readlines.size
data/website/index.html CHANGED
@@ -34,7 +34,7 @@
34
34
  <div class="sidebar">
35
35
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/nera"; return false'>
36
36
  <p>Get Version</p>
37
- <a href="http://rubyforge.org/projects/nera" class="numbers">0.5.2</a>
37
+ <a href="http://rubyforge.org/projects/nera" class="numbers">0.6.0</a>
38
38
  </div>
39
39
  </div>
40
40
  <h2>What</h2>
@@ -34,7 +34,7 @@
34
34
  <div class="sidebar">
35
35
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/nera"; return false'>
36
36
  <p>Get Version</p>
37
- <a href="http://rubyforge.org/projects/nera" class="numbers">0.5.2</a>
37
+ <a href="http://rubyforge.org/projects/nera" class="numbers">0.6.0</a>
38
38
  </div>
39
39
  </div>
40
40
  <p>The database created by nera is a hierarchical database which consists of three layers.<br />
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yohsuke Murase
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-30 00:00:00 +09:00
12
+ date: 2010-01-06 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency