coderunner 0.17.1 → 0.17.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6cd7f8afa58069ccdb34e72bff14f922bfa53fb5
4
- data.tar.gz: 69f7b07f3dc1008a50a9a630ff006f9f07523276
3
+ metadata.gz: 2b0abf9dd6e6a60db107f9cb90b1ec2a01da16f3
4
+ data.tar.gz: 3b748ca1afafeed0d546b6b95701190959291599
5
5
  SHA512:
6
- metadata.gz: 48f307830a8d73ef708cb809ae98191dbe73fb754e3aa520b198c3455ded9d03a8cc2b322d79feecaeb61c09e6c9d52da21b7caf268896d5e043f6ef4cd815b0
7
- data.tar.gz: d01ff9e906cf760fa0596621fa947fc5aa9979ffa150872d4482738df20ca6f8076a6092870f9670824a8abfcfae8e455e3598797150bde4ae0cec568b44b6c6
6
+ metadata.gz: 49075a788f4bffdf23202df136f2319f298674991d8b8b899b9de6ebaeb6ebb3bcc15fe9833ec0f59bf3089532bd60b0458c37bd5b7475b8f49eee1bbb8dd197
7
+ data.tar.gz: ebe2c25bd99beda5fa353abcbb3e1ede19ff7a27cf2e6aa89dc4487f0eab095a19760ad8e66d75bb04a3de0f84c79837730f2571035924e7bf7bb1e5dc5fe651
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.17.1
1
+ 0.17.2
data/coderunner.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: coderunner 0.17.1 ruby lib
5
+ # stub: coderunner 0.17.2 ruby lib
6
6
  # stub: ext/extconf.rb
7
7
 
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "coderunner"
10
- s.version = "0.17.1"
10
+ s.version = "0.17.2"
11
11
 
12
12
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
13
  s.require_paths = ["lib"]
14
14
  s.authors = ["Edmund Highcock"]
15
- s.date = "2015-08-16"
15
+ s.date = "2015-09-04"
16
16
  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."
17
17
  s.email = "edmundhighcock@sourceforge.net"
18
18
  s.executables = ["coderunner", "coderunnerrepo"]
@@ -99,7 +99,7 @@ Gem::Specification.new do |s|
99
99
  s.licenses = ["GPLv3"]
100
100
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
101
101
  s.rubyforge_project = "coderunner"
102
- s.rubygems_version = "2.4.8"
102
+ s.rubygems_version = "2.2.2"
103
103
  s.summary = "A framework for the automated running and analysis of simulations."
104
104
 
105
105
  if s.respond_to? :specification_version then
data/lib/coderunner.rb CHANGED
@@ -203,6 +203,7 @@ EOF
203
203
  ["available_defaults_files", "avd", 0, 'List the defaults files for the code module.', [], [:C]],
204
204
  ["cancel", "can", 1, 'Cancel the specified job.', ['id'], [:U]],
205
205
  ["code_command", "cc", 1, 'Call a class method of the run class. Effectively this will call run_class.class_eval(command). See documentation for whichever code module is in use.', ['command'], []],
206
+ ["concat", "concat", 1, 'Concatenates NetCDF output files together. File is output in the CR root directory.', ['output file'], [:j, :f, :U, :N]],
206
207
  ["continue_in_new_folder", "cnf", 1, 'Make a new folder in the parent directory and copy all coderunner configuration files to that folder. If options j or f are specified, copy all matching runs to that new folder.', ['folder'], [:j, :f, :U, :N]],
207
208
  ["code_runner_execute", "crex", 1, 'Run (within the CodeRunner class) the fragment of Ruby code given.', ['Ruby fragment'], []],
208
209
  ["delete", "del", 0, 'Permanently erase all filtered runs.', [], [:j, :F, :U, :N]],
@@ -18,7 +18,6 @@ class CodeRunner
18
18
  end
19
19
 
20
20
  # List the available modlets for the given code (copts[:C] or -C on the command line).
21
-
22
21
  def self.available_modlets(copts={})
23
22
  process_command_options(copts)
24
23
  puts "\nAvailable modlets for #{copts[:C]}:"
@@ -37,7 +36,6 @@ class CodeRunner
37
36
  end
38
37
 
39
38
  # List the available defaults files for the given code (copts[:C] or -C on the command line).
40
-
41
39
  def self.available_defaults_files(copts={})
42
40
  process_command_options(copts)
43
41
  entries = []
@@ -61,8 +59,9 @@ class CodeRunner
61
59
  end
62
60
  end
63
61
 
64
- # Cancel the job with the given id. The user is asked interactively for confirmation and whether they would like to delete the folder for that job as well.
65
-
62
+ # Cancel the job with the given id. The user is asked interactively for
63
+ # confirmation and whether they would like to delete the folder for that job
64
+ # as well.
66
65
  def self.cancel(id, copts={})
67
66
  runner = fetch_runner(copts)
68
67
  runner.cancel_job(id.to_i)
@@ -78,6 +77,29 @@ class CodeRunner
78
77
  runner.continue_in_new_folder(folder, options)
79
78
  end
80
79
 
80
+ # Method which concatenates NetCDF output files
81
+ def self.concat(name, copts={})
82
+ begin
83
+ require "numru/netcdf"
84
+ rescue LoadError
85
+ eputs "Error: No Ruby NetCDF library (was it installed correctly?): "\
86
+ "concatenation for netcdf files not possible."
87
+ return
88
+ end
89
+
90
+ runner = fetch_runner(copts)
91
+ runs = runner.filtered_ids.map{|id| runner.combined_run_list[id]}
92
+
93
+ concat_string = 'ncrcat '
94
+ runs.each do |r|
95
+ concat_string += r.directory + '/' + r.run_name + '.out.nc '
96
+ end
97
+
98
+ concat_string += runner.root_folder + '/' + name
99
+
100
+ exec "#{concat_string}"
101
+ end
102
+
81
103
  # This section defines the report report writing function in. The latex header is defined in run.rb. It is a run method and can be redefined in a particular CRMOD.
82
104
  # The function is simply called as follows:
83
105
  #
@@ -110,11 +132,13 @@ class CodeRunner
110
132
  \\begin{itemize}
111
133
  EOF
112
134
 
113
- #Need to call some methods here which reads the graphs we want from gs2crmod, generates the graphs
114
- #then generates the latex code to display graphs.
135
+ # Need to call some methods here which reads the graphs we want
136
+ # from gs2crmod, generates the graphs then generates the latex code
137
+ # to display graphs.
115
138
  latex_code = r.latex_graphs.inject("") do |tmp_latex_code, (kit, latexstring)|
116
139
  kit.gnuplot_write(kit.file_name) #write the graph
117
- tmp_latex_code += "\\item " + latexstring + " \n\n\\newfig{#{kit.file_name}}"
140
+ tmp_latex_code += "\\item " + latexstring +
141
+ " \n\n\\newfig{#{kit.file_name}}"
118
142
  tmp_latex_code += "\n\n"
119
143
  tmp_latex_code
120
144
  end
@@ -135,6 +159,7 @@ class CodeRunner
135
159
  runner = fetch_runner(copts)
136
160
  runner.destroy
137
161
  end
162
+
138
163
  def self.differences_between(copts = {})
139
164
  runner = fetch_runner(copts)
140
165
  runs = runner.filtered_ids.map{|id| runner.combined_run_list[id]}
@@ -180,14 +205,8 @@ class CodeRunner
180
205
  kit.gnuplot(eval: string_to_eval)
181
206
  sleep(copts[:F][:fr] ? 1.0/copts[:F][:fr] : 0.1)
182
207
  end
183
- end
184
- # def self.executable_name # :nodoc:
185
- # ""
186
- # end
187
- #
188
- # def self.rcp # :nodoc:
189
- # @rcp ||= KitHash.new
190
- # end
208
+ end
209
+
191
210
  def self.netcdf_plot(netcdf_file, vars, indices, copts={})
192
211
  process_command_options(copts)
193
212
  begin
@@ -214,8 +233,6 @@ class CodeRunner
214
233
  kit.close
215
234
  end
216
235
 
217
-
218
-
219
236
  def self.print_queue_status(copts={})
220
237
  begin
221
238
  eputs queue_status
@@ -227,10 +244,6 @@ class CodeRunner
227
244
  end
228
245
  end
229
246
 
230
-
231
-
232
-
233
-
234
247
  def self.reference(class_or_method, copts={})
235
248
  code_folders = Dir.recursive_entries(SCRIPT_FOLDER + '/code_modules').grep(/\/ri$/).map{|fold| ['-d', fold]}.flatten
236
249
  # ep code_folders
@@ -251,11 +264,11 @@ class CodeRunner
251
264
  # trap(1){}
252
265
  end
253
266
 
254
-
255
267
  def self.directory(id, copts={})
256
268
  runner = fetch_runner(copts)
257
269
  puts runner.run_list[id.to_i].directory
258
270
  end
271
+
259
272
  def self.film(copts={})
260
273
  runner = fetch_runner(copts)
261
274
  copts[:F][:graphkit_modify] = copts[:w]
@@ -309,7 +322,6 @@ EOF
309
322
 
310
323
  end
311
324
 
312
-
313
325
  def self.generate_cubecalc(copts={})
314
326
  #return
315
327
  File.open('cubecalc.cc', 'w') do |file|
@@ -372,9 +384,11 @@ EOF
372
384
 
373
385
  end
374
386
  end
387
+
375
388
  def self.launcher_directory
376
389
  ENV['HOME'] + "/.coderunner/to_launch/#{ENV['CODE_RUNNER_LAUNCHER']}"
377
390
  end
391
+
378
392
  def self.start_launcher(refresh, max_queue, copts={})
379
393
  #eputs "Starting launcher!"
380
394
  raise "Raise refresh is #{refresh}: it must be >= 0.1" if refresh.to_f < 0.1
@@ -477,15 +491,16 @@ EOF
477
491
 
478
492
  end
479
493
 
480
-
481
494
  def self.code_runner_execute(ruby_fragment, copts={})
482
495
  #eval(ruby_fragment, GLOBAL_BINDING)
483
496
  eval(ruby_fragment)
484
497
  end
498
+
485
499
  def self.execute(ruby_fragment, copts={})
486
500
  eval(ruby_fragment, GLOBAL_BINDING)
487
501
  #eval(ruby_fragment)
488
502
  end
503
+
489
504
  def self.load_file(files, copts={})
490
505
  process_command_options(copts)
491
506
  # begin
@@ -519,6 +534,7 @@ EOF
519
534
  @@psppipe.finish
520
535
  @@psppipe = nil
521
536
  end
537
+
522
538
  def self.plot_graph(copts = {})
523
539
  # process_copts(copts)
524
540
  runner = fetch_runner(copts)
@@ -530,17 +546,18 @@ EOF
530
546
  gets
531
547
  kit.close
532
548
  end
549
+
533
550
  def self.readout(copts={})
534
- # process_copts(copts)
535
551
  runner = fetch_runner(copts)
536
552
  puts runner.readout
537
553
  end
554
+
538
555
  def self.recheck(id, copts={})
539
- # process_copts(copts)
540
556
  runner = fetch_runner(copts)
541
557
  runner.run_list[copts[:R]].recheck
542
558
  runner.respond_to_requests
543
559
  end
560
+
544
561
  def self.run_class(copts={})
545
562
  process_command_options(copts)
546
563
  copts[:no_update] = true
@@ -557,12 +574,14 @@ EOF
557
574
 
558
575
  return setup_run_class(copts[:C], modlet: copts[:m])
559
576
  end
577
+
560
578
  def self.code_command(string, copts = {})
561
579
  run_class(copts).class_eval(string)
562
580
 
563
581
  # runner = fetch_runner(copts)
564
582
  # runner.run_class.class_eval(string)
565
583
  end
584
+
566
585
  def self.run_command(string, copts={})
567
586
  # process_copts(copts)
568
587
  runner = fetch_runner(copts)
@@ -606,6 +625,7 @@ EOF
606
625
  # Process.waitall
607
626
  runner.respond_to_requests
608
627
  end
628
+
609
629
  def self.runner_eval(string, copts = {})
610
630
  # process_copts(copts)
611
631
  runner = fetch_runner(copts)
@@ -621,11 +641,13 @@ EOF
621
641
  end
622
642
 
623
643
  end
644
+
624
645
  def self.scan(scan_string, copts={})
625
646
  # process_copts(copts)
626
647
  runner = fetch_runner(copts)
627
648
  runner.simple_scan(scan_string, nprocs: copts[:n], version: copts[:v], skip: copts[:k], parameters: copts[:p][0])
628
649
  end
650
+
629
651
  def self.submit(copts = {})
630
652
  # process_copts(copts)
631
653
  runner = get_submit_runner(copts)
@@ -648,6 +670,7 @@ EOF
648
670
  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])
649
671
  #exit(0)
650
672
  end
673
+
651
674
  # Fetch a runner appropriate for submitting simulations. In
652
675
  # all usual cases this is just the default runner for the command
653
676
  # but where several folders have been specified and we are dealing
@@ -665,10 +688,9 @@ EOF
665
688
  end
666
689
  end
667
690
  end
691
+
668
692
  def self.resubmit(copts = {})
669
693
  runner = get_submit_runner(copts)
670
- # process_copts(copts)
671
- # raise "something is already submitting" if FileTest.exist? "submitting"
672
694
  runs = []
673
695
  raise "Parameters must be an array of inspected hashes" unless copts[:p].kind_of? Array
674
696
  Dir.chdir(runner.root_folder) do
@@ -688,12 +710,12 @@ EOF
688
710
  run
689
711
  end
690
712
  end
691
- #throw(:here)
692
713
 
693
714
  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], replace_existing: copts[:replace_existing], smart_resubmit_name: copts[:smart_resubmit_name], rerun: copts[:rerun])
694
715
  end
695
716
 
696
- # This method allows the straightforward submission of a single command using the batch queue on any system.
717
+ # This method allows the straightforward submission of a single command using
718
+ # the batch queue on any system.
697
719
  def self.submit_command(jid, comm, copts={})
698
720
  process_command_options(copts)
699
721
  submitter = Object.new
@@ -717,25 +739,27 @@ EOF
717
739
  submitter.execute
718
740
  end
719
741
 
720
-
721
-
722
742
  def self.readout(copts={})
723
743
  runner = fetch_runner(copts)
724
744
  runner.readout
725
745
  end
746
+
726
747
  def self.show_values_of(expression, copts={})
727
748
  runner = fetch_runner(copts)
728
749
  p runner.filtered_ids.map{|id| runner.combined_run_list[id].instance_eval(expression)}.uniq.sort
729
750
  end
751
+
730
752
  def self.status_with_comments(copts={})
731
753
  copts[:with_comments] = true
732
754
  status(copts)
733
755
  end
756
+
734
757
  def self.status(copts={})
735
758
  # process_copts(copts)
736
759
  runner = fetch_runner(copts)
737
760
  runner.print_out(0, with_comments: copts[:with_comments]) unless copts[:interactive_start] or copts[:Z] or copts[:no_print_out]
738
761
  end
762
+
739
763
  def self.status_loop(copts={})
740
764
  # process_copts(copts)
741
765
  runner = fetch_runner(copts)
@@ -758,6 +782,7 @@ EOF
758
782
  #ep "end sleep"
759
783
  end
760
784
  end
785
+
761
786
  def self.status_loop_running(copts={})
762
787
  copts[:f] = "@running"
763
788
  runner = fetch_runner(copts)
@@ -766,6 +791,7 @@ EOF
766
791
  copts[:j] = nil
767
792
  status_loop(copts)
768
793
  end
794
+
769
795
  def self.status_loop(copts={})
770
796
  # process_copts(copts)
771
797
  runner = fetch_runner(copts)
@@ -788,6 +814,7 @@ EOF
788
814
  #ep "end sleep"
789
815
  end
790
816
  end
817
+
791
818
  def self.write_graph(name, copts={})
792
819
  # process_copts(copts)
793
820
  runner = fetch_runner(copts)
@@ -808,11 +835,13 @@ EOF
808
835
  raise "kit doesn't have a file_name and no filename specified; can't write graph" unless name or (kit.file_name.class == String and kit.file_name =~ /\S/)
809
836
  Dir.chdir(COMMAND_FOLDER){kit.gnuplot_write((name or kit.file_name), {eval: copts[:w]})}
810
837
  end
838
+
811
839
  def self.read_default_command_options(copts)
812
840
  DEFAULT_COMMAND_OPTIONS.each do |key, value|
813
841
  copts[key] ||= value
814
842
  end
815
843
  end
844
+
816
845
  def self.process_command_options(copts)
817
846
  if copts[:true]
818
847
  copts[:true].to_s.split(//).each do |letter|
@@ -869,8 +898,8 @@ EOF
869
898
 
870
899
  end
871
900
 
872
- # Analyse copts[:Y], the choice of the root folder for the runner, and make appropriate
873
- # modifications to the command options for running remotely, etc.
901
+ # Analyse copts[:Y], the choice of the root folder for the runner, and make
902
+ # appropriate modifications to the command options for running remotely, etc.
874
903
  def self.process_root_folder(copts)
875
904
  copts[:Y] ||= DEFAULT_COMMAND_OPTIONS[:Y] if DEFAULT_COMMAND_OPTIONS[:Y]
876
905
  if copts[:Y] and copts[:Y].kind_of? Array
@@ -890,8 +919,8 @@ EOF
890
919
 
891
920
  CODE_OPTIONS={}
892
921
 
893
- # Retrieve the runner with the folder (and possibly server) given in copts[:Y]. If no runner has been loaded for that folder, load one.
894
-
922
+ # Retrieve the runner with the folder (and possibly server) given in
923
+ # copts[:Y]. If no runner has been loaded for that folder, load one.
895
924
  def self.fetch_runner(copts={})
896
925
  # ep copts
897
926
  #read_default_command_options(copts)
@@ -943,20 +972,19 @@ EOF
943
972
  return runner
944
973
  # @r.read_defaults
945
974
  end
975
+
946
976
  def self.update_runners
947
977
  @runners ||= {}
948
978
  @runners.each{|runner| runner.update}
949
979
  end
950
980
 
951
-
952
981
  def self.runner
953
982
  @runners ||={}
954
983
  @runners.values[0]
955
984
  end
956
985
 
957
-
958
- def self.manual(copts={})
959
- help = <<EOF
986
+ def self.manual(copts={})
987
+ help = <<EOF
960
988
 
961
989
 
962
990
  -------------CodeRunner Manual---------------
@@ -1018,12 +1046,4 @@ EOF
1018
1046
  help.paginate
1019
1047
  end
1020
1048
 
1021
-
1022
-
1023
-
1024
-
1025
1049
  end
1026
-
1027
-
1028
-
1029
-
data/test/helper.rb CHANGED
@@ -16,6 +16,3 @@ require 'coderunner'
16
16
  require 'cubecalccrmod'
17
17
  require 'cubecalccrmod/sleep'
18
18
 
19
-
20
- #class Test::Unit::TestCase
21
- #end
@@ -3,8 +3,6 @@ require 'helper'
3
3
  require 'rbconfig'
4
4
  CodeRunner::RemoteCodeRunner::DISPLAY_REMOTE_INVOCATION = true
5
5
 
6
-
7
-
8
6
  module MiniTest::Assertions
9
7
  def assert_system(string)
10
8
  assert(system(string), "System Command: '#{string}'")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coderunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edmund Highcock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-16 00:00:00.000000000 Z
11
+ date: 2015-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphkit
@@ -286,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
286
  version: '0'
287
287
  requirements: []
288
288
  rubyforge_project: coderunner
289
- rubygems_version: 2.4.8
289
+ rubygems_version: 2.2.2
290
290
  signing_key:
291
291
  specification_version: 4
292
292
  summary: A framework for the automated running and analysis of simulations.