coderunner 0.12.14 → 0.12.15

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.12.14
1
+ 0.12.15
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "coderunner"
8
- s.version = "0.12.14"
8
+ s.version = "0.12.15"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Edmund Highcock"]
12
- s.date = "2013-07-26"
12
+ s.date = "2013-07-29"
13
13
  s.description = "CodeRunner is a framework for the automated running and analysis of simulations. It automatically generates any necessary input files, organises the output data and analyses it. Because it is a modular system, it can easily be customised to work with any system and any simulation code. One of its greatest strengths is that it is independent of any one simulation code; thus it can easily plot and compare the data from different codes."
14
14
  s.email = "edmundhighcock@sourceforge.net"
15
15
  s.executables = ["coderunner"]
@@ -71,7 +71,6 @@ Gem::Specification.new do |s|
71
71
  "lib/cubecalccrmod/defaults_files/sleep_defaults.rb",
72
72
  "lib/cubecalccrmod/empty.rb",
73
73
  "lib/cubecalccrmod/sleep.rb",
74
- "test/cubecalc.cc",
75
74
  "test/fortran_namelist.in",
76
75
  "test/helper.rb",
77
76
  "test/old_test.rb",
@@ -206,7 +206,8 @@ EOF
206
206
  ["execute", "ex", 1, 'Run (at the top level) the fragment of Ruby code given.', ['Ruby fragment'], []],
207
207
  ['film', "fm", 0, 'Create a film of the specified graphkits.', [], [:F, :G, :g, :U, :N, :j, :f]],
208
208
  ["generate_modlet_from_input_file", "gm", 1, 'Deprecated', [], []],
209
- ["generate_documentation", "rdoc", 1, 'Create automatic documentation using the rdoc tool', [], []],
209
+ ["generate_cubecalc", "gencc", 0, 'Generate the file cubecalc.cc, the source code for the coderunner test program.', [], []],
210
+ ["generate_documentation", "rdoc", 1, 'Create automatic documentation using the rdoc tool (deprecated, use the command line tool ri for getting help, or see rubygems.org/gems/coderunner).', [], []],
210
211
  ["interactive_mode", "im", 0, 'Launch an interactive terminal. Any command line flags specified set the defaults for the session.', [], [:U, :N, :j, :q]],
211
212
  ["load_file", "ld", 1, 'Load a Ruby script file using the CodeRunner framework.', ['script file'], []],
212
213
  ['manual', 'man', 0, 'Print out command line manual', [], []],
@@ -249,11 +249,75 @@ EOF
249
249
 
250
250
  end
251
251
 
252
+
253
+ def self.generate_cubecalc(copts={})
254
+ #return
255
+ File.open('cubecalc.cc', 'w') do |file|
256
+ file.puts <<EOF
257
+ #include <stdio.h>
258
+ #include <iostream>
259
+ #include <cstdlib>
260
+ #include <fstream>
261
+ #include <cstring>
262
+ #include <ctime>
263
+ using namespace std;
264
+
265
+ int main(int argc, char* argv[]){
266
+ string line;
267
+ cout << "Starting..." << endl;
268
+
269
+ int calculate_sides = atoi(argv[1]); //Should the program calculate the area of the sides of the cube?
270
+ cout << calculate_sides << endl;
271
+
272
+ char* input_file_name = argv[2]; //Get the input file name from the command line
273
+ cout << input_file_name << endl;
274
+
275
+ if (argc > 3){ //It has been told to sleep for a time
276
+ bool cont = true;
277
+ time_t start_t;
278
+ time(&start_t);
279
+ while (cont){
280
+ time_t new_t;
281
+ time(&new_t);
282
+ cont = (new_t < (start_t + atoi(argv[3]) * 1.0));
283
+ }
284
+ }
285
+
286
+ ifstream edges_file(input_file_name); //Read the edges from the input file
287
+ float* edges = new float[3];
288
+ int j = 0;
289
+ while (edges_file >> edges[j++]){
290
+ cout << edges[j-1] << endl;
291
+ }
292
+
293
+
294
+ FILE* output = fopen("results.txt", "w"); //Write the volume to the output file
295
+ fprintf(output, "Volume was %f", edges[0] * edges[1] * edges[2]);
296
+ fclose(output);
297
+
298
+ if (calculate_sides == 1){ //If it has been told to calculate the sides
299
+ cout << "calculating sides" << endl;
300
+ FILE* sides = fopen("sides.txt", "w");
301
+ for(int i=0; i<3; i++){
302
+ cout << "Side " << i << ": " << edges[(i%3)] * edges[((i+1)%3)] << endl;
303
+ fprintf(sides, "The area of side %d is %f\\n", i, edges[i%3] * edges[(i+1)%3]);
304
+ }
305
+ fclose(sides);
306
+ }
307
+ }
308
+
309
+
310
+
311
+ EOF
312
+
313
+ end
314
+ end
252
315
  def self.launcher_directory
253
316
  ENV['HOME'] + "/.coderunner/to_launch/#{ENV['CODE_RUNNER_LAUNCHER']}"
254
317
  end
255
318
  def self.start_launcher(refresh, max_queue, copts={})
256
- raise "Raise refresh is #{refresh}: it must be >= 1" if refresh.to_i < 1
319
+ #eputs "Starting launcher!"
320
+ raise "Raise refresh is #{refresh}: it must be >= 0.1" if refresh < 0.1
257
321
  raise "Raise max_queue is #{max_queue}: it must be >= 5" if max_queue.to_i < 5
258
322
  #raise "Launcher already running" if %x[ps -e -o cmd].split("\n").grep(/coderunner\s+launch/).size > 0
259
323
  require 'thread'
@@ -280,7 +344,7 @@ EOF
280
344
  end
281
345
  end
282
346
 
283
- Dir.chdir(tl) do
347
+ #Dir.chdir(tl) do
284
348
  ppid = $$
285
349
  loop do
286
350
  sleep refresh.to_i while processes.size >= max_queue.to_i
@@ -288,9 +352,10 @@ EOF
288
352
  Dir.entries(tl).grep(/(^.*)\.start/).each do |file|
289
353
  file =~ (/(^.*)\.start/)
290
354
  id = $1
291
- command = File.read file
355
+ command = File.read tl + '/' + file
292
356
  pid = fork do
293
357
  processes.each do |wpid|
358
+ # Make sure all previously submitted jobs have finished.
294
359
  sleep refresh.to_i while %x[ps -e -o pid,ppid].split("\n").grep(Regexp.new("^\\s*#{wpid}\\s+#{ppid}")).size > 0
295
360
  end
296
361
  exec(command)
@@ -298,15 +363,15 @@ EOF
298
363
  `cp #{tl}/queue_status.txt #{tl}/queue_status2.txt; ps > #{tl}/queue_status.txt`
299
364
  mutex.synchronize{processes.push pid}
300
365
 
301
- File.open(id + '.pid', 'w'){|file| file.puts pid}
302
- FileUtils.rm(file)
366
+ File.open(tl + '/' + id + '.pid', 'w'){|file| file.puts pid}
367
+ FileUtils.rm(tl + '/' + file)
303
368
 
304
369
  Thread.new{Process.wait pid; mutex.synchronize{processes.delete pid}}
305
370
  end
306
371
  # processes.each{|pid| Process.wait pid}
307
372
  sleep refresh.to_i
308
373
  end
309
- end
374
+ #end
310
375
  end
311
376
 
312
377
 
@@ -473,6 +538,8 @@ EOF
473
538
  # exit
474
539
  end
475
540
  runner.submit(runs, nprocs: copts[:n], version: copts[:v], skip: copts[:k], job_chain: copts[:J], no_update_before_submit: copts[:no_update_before_submit])
541
+ #puts "Got here"
542
+ #exit(0)
476
543
  end
477
544
  def self.resubmit(copts = {})
478
545
  # process_copts(copts)
@@ -1088,8 +1088,8 @@ Conditions contain a single = sign: #{conditions}
1088
1088
  sleep rand
1089
1089
  end
1090
1090
  # old_trap = trap(0)
1091
- old_trap0 = trap(0){eputs "Aborted Submit!"; File.delete("#@root_folder/submitting"); exit!}
1092
- old_trap2 = trap(2){eputs "Aborted Submit!"; File.delete("#@root_folder/submitting") if FileTest.exist? "#@root_folder/submitting"; trap(2, "DEFAULT"); trap(0, "DEFAULT"); Process.kill(2, 0)}
1091
+ #old_trap0 = trap(0){eputs "Aborted Submit (0)!"; File.delete("#@root_folder/submitting"); exit!}
1092
+ old_trap2 = trap(2){eputs "Aborted Submit (2)!"; File.delete("#@root_folder/submitting") if FileTest.exist? "#@root_folder/submitting"; trap(2, "DEFAULT"); trap(0, "DEFAULT"); Process.kill(2, 0)}
1093
1093
  # File.open("submitting", "w"){|file| file.puts ""}
1094
1094
  FileUtils.touch("submitting")
1095
1095
  unless options[:no_update_before_submit]
@@ -1191,7 +1191,7 @@ Conditions contain a single = sign: #{conditions}
1191
1191
  @write_status_dots = wsd
1192
1192
  save_large_cache
1193
1193
  File.delete("submitting")
1194
- trap(0, old_trap0)
1194
+ #trap(0, old_trap0)
1195
1195
  trap(2, old_trap2)
1196
1196
 
1197
1197
 
@@ -23,6 +23,7 @@ $ruby_command = "#{RbConfig::CONFIG['bindir']}/#{RbConfig::CONFIG['ruby_install_
23
23
  class TestSubmission < Test::Unit::TestCase
24
24
  def setup
25
25
  string = $cpp_command + ' ../cubecalc.cc -o cubecalc'
26
+ Dir.chdir('test'){CodeRunner.generate_cubecalc}
26
27
  FileUtils.makedirs('test/submission_results')
27
28
  Dir.chdir('test/submission_results'){assert_system string}
28
29
  CodeRunner.setup_run_class('cubecalc', modlet: 'sleep')
@@ -41,11 +42,12 @@ class TestSubmission < Test::Unit::TestCase
41
42
  end
42
43
  def test_status_loop
43
44
  unless ENV['SHORT_TEST']
44
- ENV['CODE_RUNNER_LAUNCHER'] = '4'
45
- @thread = Thread.new{CodeRunner.start_launcher(0.2,10)}
45
+ ENV['CODE_RUNNER_LAUNCHER'] = '42323490qw4q4432407Q2342U3'
46
+ @thread = Thread.new{CodeRunner.start_launcher(0.5,10)}
47
+ sleep 0.1 while not FileTest.exist?(CodeRunner.launcher_directory)
46
48
  CodeRunner.submit(Y: 'test/submission_results', C: 'cubecalc', m: 'sleep', X: Dir.pwd + '/test/submission_results/cubecalc', p: '{sleep_time: 2}')
47
49
  CodeRunner.status_loop(Y: 'test/submission_results')
48
- @thread.kill
50
+ #@thread.kill # This is commented out because it causes a Heisenbug... the kill signal can get trapped and cause the deletion of the 'submitting' lock file. This line is unnecessary because the thread will die when the program exits
49
51
  ENV.delete('CODE_RUNNER_LAUNCHER')
50
52
  end
51
53
  end
@@ -57,11 +59,12 @@ class TestSubmission < Test::Unit::TestCase
57
59
  runner.print_out(0)
58
60
  assert_equal(6.0, runner.run_list[1].volume)
59
61
  end
60
- #def test_command_line_submission
61
- #assert_system("#{$ruby_command} -I lib/ lib/coderunner.rb submit -C cubecalc -m sleep -D sleep -X #{Dir.pwd}/test/cubecalc -Y test/submission_results")
62
- #end
62
+ def test_command_line_submission
63
+ assert_system("#{$ruby_command} -I lib/ lib/coderunner.rb submit -C cubecalc -m sleep -D sleep -X #{Dir.pwd}/test/submission_results/cubecalc -Y test/submission_results")
64
+ end
63
65
  def teardown
64
66
  FileUtils.rm_r('test/submission_results')
67
+ FileUtils.rm_r('test/cubecalc.cc')
65
68
  end
66
69
  end
67
70
 
@@ -77,6 +80,7 @@ class TestCodeRunner < Test::Unit::TestCase
77
80
  def setup
78
81
  FileUtils.makedirs('test/results')
79
82
  string = $cpp_command + ' ../cubecalc.cc -o cubecalc'
83
+ Dir.chdir('test'){CodeRunner.generate_cubecalc}
80
84
  Dir.chdir('test/results'){assert_system string}
81
85
  CodeRunner.submit(Y: tfolder, C: 'cubecalc', m: 'empty', X: Dir.pwd + '/test/results/cubecalc', T: true)
82
86
  # exit
@@ -88,6 +92,7 @@ class TestCodeRunner < Test::Unit::TestCase
88
92
 
89
93
  def teardown
90
94
  FileUtils.rm_r('test/results')
95
+ FileUtils.rm('test/cubecalc.cc')
91
96
  end
92
97
 
93
98
  def tfolder
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coderunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.14
4
+ version: 0.12.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-26 00:00:00.000000000 Z
12
+ date: 2013-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphkit
@@ -238,7 +238,6 @@ files:
238
238
  - lib/cubecalccrmod/defaults_files/sleep_defaults.rb
239
239
  - lib/cubecalccrmod/empty.rb
240
240
  - lib/cubecalccrmod/sleep.rb
241
- - test/cubecalc.cc
242
241
  - test/fortran_namelist.in
243
242
  - test/helper.rb
244
243
  - test/old_test.rb
@@ -1,52 +0,0 @@
1
- #include <stdio.h>
2
- #include <iostream>
3
- #include <cstdlib>
4
- #include <fstream>
5
- #include <cstring>
6
- #include <ctime>
7
- using namespace std;
8
-
9
- int main(int argc, char* argv[]){
10
- string line;
11
- cout << "Starting..." << endl;
12
-
13
- int calculate_sides = atoi(argv[1]); //Should the program calculate the area of the sides of the cube?
14
- cout << calculate_sides << endl;
15
-
16
- char* input_file_name = argv[2]; //Get the input file name from the command line
17
- cout << input_file_name << endl;
18
-
19
- if (argc > 3){ //It has been told to sleep for a time
20
- bool cont = true;
21
- time_t start_t;
22
- time(&start_t);
23
- while (cont){
24
- time_t new_t;
25
- time(&new_t);
26
- cont = (new_t < (start_t + atoi(argv[3]) * 1.0));
27
- }
28
- }
29
-
30
- ifstream edges_file(input_file_name); //Read the edges from the input file
31
- float* edges = new float[3];
32
- int j = 0;
33
- while (edges_file >> edges[j++]){
34
- cout << edges[j-1] << endl;
35
- }
36
-
37
-
38
- FILE* output = fopen("results.txt", "w"); //Write the volume to the output file
39
- fprintf(output, "Volume was %f", edges[0] * edges[1] * edges[2]);
40
- fclose(output);
41
-
42
- if (calculate_sides == 1){ //If it has been told to calculate the sides
43
- cout << "calculating sides" << endl;
44
- FILE* sides = fopen("sides.txt", "w");
45
- for(int i=0; i<3; i++){
46
- cout << "Side " << i << ": " << edges[(i%3)] * edges[((i+1)%3)] << endl;
47
- fprintf(sides, "The area of side %d is %f\n", i, edges[i%3] * edges[(i+1)%3]);
48
- }
49
- fclose(sides);
50
- }
51
- }
52
-