coderunner 0.14.24 → 0.15.0

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: 8e1deca0aeb33a5da186b2c08c94945d7561cdf4
4
- data.tar.gz: f97f58aba34eea4c3221d16ad88316a28b93e241
3
+ metadata.gz: 417fc5c2741343dc39e1f783601b939db54b3c10
4
+ data.tar.gz: 0334eb08f867cbcb0ea42b622bdf66ab9bb8053c
5
5
  SHA512:
6
- metadata.gz: 3db503c9c435107ade3384de8f9364e645ae84e4363ff28f33b3df831014991ad1511fadd082d67eb108ec5aba4158ac65ae50826d0a6c20f3dc86d9efac4066
7
- data.tar.gz: 71f72f4d1324706d49e10e7a2dbda39b90efd5b6c79518127aef12dd6d86437fc9d721a51366d13763dec467e44f15ed04a913ebc48ece427045aea65163d753
6
+ metadata.gz: 03e5bc3450880af1c5c824949aa560566199dcee38ac1cb26b279281276d20d2c6ff1c8da6ebb74dace1825c45d89e14cd0aa7cbdd702e9934837305354ff4de
7
+ data.tar.gz: ac261b9512c9cdf629e033e9bd0d367f3f08d47cc9d57e4ee32a206d3d6a701b5eb8f7dfac6b23ed7634f74b72f09b95d4c225959425de71ea1e627d92b135b2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.14.24
1
+ 0.15.0
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.14.24 ruby lib
5
+ # stub: coderunner 0.15.0 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.14.24"
10
+ s.version = "0.15.0"
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 = "2014-10-10"
15
+ s.date = "2014-10-14"
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"]
data/lib/coderunner.rb CHANGED
@@ -165,7 +165,7 @@ class CodeRunner
165
165
  ["--wall-mins", "-W", GetoptLong::REQUIRED_ARGUMENT, %[Specify the wall clock limit in minutes.]],
166
166
  ["--write-options", "-w", GetoptLong::REQUIRED_ARGUMENT, %[Use when plotting graphs. A hash of custom options which are applied to the graphkit just before plotting it; for example: -w '{xlabel: 'X Axis Quantity, log_axis: 'y'}']],
167
167
  ["--executable", "-X", GetoptLong::REQUIRED_ARGUMENT, %[Specify the location of the executable of the simulation code. It only needs to be specified once in any folder, unless it needs to be changed.]],
168
- ["--other-folder", "-Y", GetoptLong::REQUIRED_ARGUMENT, %[Run CodeRunner in a different folder. On a local machine 'coderunner st -Y some/other/folder' is identical to 'cd some/other/folder; coderunner st -Y'. However, this flag can also be used for remote folders using RemoteCodeRunner (as long as CodeRunner is installed on the remote machine). e.g. -Y username@machine.location:path/to/folder.]],
168
+ ["--other-folder", "-Y", GetoptLong::REQUIRED_ARGUMENT, %[Run CodeRunner in a different folder. On a local machine 'coderunner st -Y some/other/folder' is identical to 'cd some/other/folder; coderunner st -Y'. However, this flag can also be used for remote folders using RemoteCodeRunner (as long as CodeRunner is installed on the remote machine). e.g. -Y username@machine.location:path/to/folder. If this option is specified multiple times, a merged runner will be created from the set of specified folders.]],
169
169
  ["--supplementary-options", "-y", GetoptLong::REQUIRED_ARGUMENT],
170
170
  ["--server", "-Z", GetoptLong::REQUIRED_ARGUMENT, %[Technical use only]],
171
171
  ["--log", "-z", GetoptLong::NO_ARGUMENT, %[Switch logging on (currently not working very well (05/2010)).]] # :nodoc:
@@ -282,6 +282,16 @@ EOF
282
282
  copts[:G].push arg
283
283
  when "--run-graph"
284
284
  copts[:g].push arg
285
+ when "--other-folder"
286
+ if copts[:Y]
287
+ if copts[:Y].kind_of? String
288
+ copts[:Y] = [copts[:Y], arg]
289
+ else
290
+ copts[:Y].push arg
291
+ end
292
+ else
293
+ copts[:Y] = arg
294
+ end
285
295
  # when "--cancel"
286
296
  # copts[:K] = arg.to_i
287
297
  when "--multiple-processes"
@@ -614,7 +614,7 @@ EOF
614
614
  # raise "something is already submitting" if FileTest.exist? "submitting"
615
615
  runs = []
616
616
  raise "Parameters must be an array of inspected hashes" unless copts[:p].kind_of? Array
617
- Dir.chdir(copts[:Y]) do
617
+ Dir.chdir(runner.root_folder) do
618
618
 
619
619
  copts[:p].push nil if copts[:p] == []
620
620
  # ep copts[:p]; exit
@@ -636,7 +636,7 @@ EOF
636
636
  # raise "something is already submitting" if FileTest.exist? "submitting"
637
637
  runs = []
638
638
  raise "Parameters must be an array of inspected hashes" unless copts[:p].kind_of? Array
639
- Dir.chdir(copts[:Y]) do
639
+ Dir.chdir(runner.root_folder) do
640
640
  runs = runner.filtered_ids.map do |id|
641
641
  eputs id
642
642
  run = runner.run_list[id].dup
@@ -795,7 +795,22 @@ EOF
795
795
  copts[:h] = :real
796
796
  end
797
797
 
798
+ # ep Log.log_file
799
+ #copts[:code_copts].each{|k,v| CODE_OPTIONS[k] = v} if copts[:code_copts]
800
+ copts.keys.map{|k| k.to_s}.grep(/_options$/).map{|k| k.to_sym}.each do |k|
801
+ CODE_OPTIONS[k.to_s.sub('_options','').to_sym] = copts[k]
802
+ end
803
+
804
+
805
+ end
806
+
807
+ # Analyse copts[:Y], the choice of the root folder for the runner, and make appropriate
808
+ # modifications to the command options for running remotely, etc.
809
+ def self.process_root_folder(copts)
798
810
  copts[:Y] ||= DEFAULT_COMMAND_OPTIONS[:Y] if DEFAULT_COMMAND_OPTIONS[:Y]
811
+ if copts[:Y] and copts[:Y].kind_of? Array
812
+ eputs "Warning: ignoring additional folders... selecting folder: #{copts[:Y]=copts[:Y][0]}"
813
+ end
799
814
  if copts[:Y] and copts[:Y] =~ /:/
800
815
  set_class_defaults(copts)
801
816
  copts[:running_remotely] = true
@@ -806,13 +821,6 @@ EOF
806
821
  # ep DEFAULT_RUNNER_OPTIONS
807
822
  end
808
823
  end
809
- # ep Log.log_file
810
- #copts[:code_copts].each{|k,v| CODE_OPTIONS[k] = v} if copts[:code_copts]
811
- copts.keys.map{|k| k.to_s}.grep(/_options$/).map{|k| k.to_sym}.each do |k|
812
- CODE_OPTIONS[k.to_s.sub('_options','').to_sym] = copts[k]
813
- end
814
-
815
-
816
824
  end
817
825
 
818
826
  CODE_OPTIONS={}
@@ -821,7 +829,10 @@ EOF
821
829
 
822
830
  def self.fetch_runner(copts={})
823
831
  # ep copts
832
+ #read_default_command_options(copts)
833
+ process_command_options(copts)
824
834
  # If copts(:Y) is an array of locations, return a merged runner of those locations
835
+ #copts[:Y] ||= DEFAULT_COMMAND_OPTIONS[:Y] if DEFAULT_COMMAND_OPTIONS[:Y]
825
836
  if copts[:Y].kind_of? Array
826
837
  runners = copts[:Y].map do |location|
827
838
  new_copts = copts.dup.absorb(Y: location)
@@ -829,7 +840,7 @@ EOF
829
840
  end
830
841
  return Merged.new(*runners)
831
842
  end
832
- process_command_options(copts)
843
+ process_root_folder(copts)
833
844
  #ep copts
834
845
  @runners ||= {}
835
846
  runner = nil
@@ -633,8 +633,14 @@ EOF
633
633
  end)
634
634
  end
635
635
 
636
+ # Returns an empty string. A hook for CodeRunner::Merged
637
+ def merged_runner_info(run)
638
+ ""
639
+ end
640
+
636
641
  # Print out a summary of all the runs in the root folder, formatted in nice pretty colours. Since this is often called in a loop, if called twice without any arguments it will erase the first printout. To stop this happening set rewind to 0. If the command is being issued not in a terminal, so that CodeRunner cannot determine the size of the terminal, the second argument must be passed as an array of [rows, columns].
637
642
 
643
+
638
644
  def print_out(rewind = nil, options={}) # terminal_size = [rows, cols]
639
645
  rewind ||= @print_out_size
640
646
  terminal_size = options[:terminal_size]
@@ -680,6 +686,8 @@ EOF
680
686
  #@split_point = @new_split_point
681
687
  eprint j%2==0 ? j%4==0 ? cyan : green : dc
682
688
  line = options[:with_comments] ? @run.comment_line : @run.print_out_line.chomp
689
+ # if this is not a merged runner, merged_runner_info is an empty string
690
+ line = merged_runner_info(@run) + line
683
691
  eprint line
684
692
  eputs cln
685
693
  # puts (line.size / Terminal.terminal_size[1]).class
@@ -8,11 +8,27 @@ class CodeRunner
8
8
  send(meth, *args)
9
9
  end
10
10
 
11
+ # This class allows the analysis of multiple root folders as if they were
12
+ # one. For every normal runner (instance of CodeRunner) that is added to the merged runner
13
+ # (instance of CodeRunner::Merged), the runs of that normal runner are added to the merged
14
+ # run_list. Normal runner function such as CodeRunner#graphkit() can then be called.
15
+ #
16
+ # In order to keep the run_list unique, the runs from each component runner are not added
17
+ # to the merged runner directly: instead they are wrapped in a container of class Run::Merged
18
+ # which behaves like a standard run object except that it redefines the id to be [runner_index, id].
19
+ # Thus, within the merged runner, the id of run 43 from the third runner to be added to the merged
20
+ # runner is [2,43].
21
+ #
11
22
  class Merged < CodeRunner
23
+ # Iterates over the runners contained within the merged runner.
24
+ # E.g.
25
+ # merged_runner.each{|runner| p runner.root_folder}
12
26
  def each
13
27
  @runners.each{|r| yield(r)}
14
28
  end
15
29
  include Enumerable
30
+ # Create a new merged runner. <tt>runners</tt> is an array of standard runners
31
+ # (i.e. instances of CodeRunner).
16
32
  def initialize(*runners)
17
33
  @runners = []
18
34
  r = runners[0]
@@ -22,14 +38,34 @@ class CodeRunner
22
38
  @run_list = {}
23
39
  runners.each{|runner| add_runner(runner)}
24
40
  end
41
+ # Raises an error. At the present time, submitting
42
+ # from a merged runner has no defined behaviour and
43
+ # is not implemented.
44
+ def submit(*args)
45
+ raise "Submitting from a merged runner is currently not supported"
46
+ end
47
+ # A string prepended to each line of the status output for merged
48
+ # runners... see CodeRunner#print_out
49
+ def merged_runner_info(run)
50
+ #run.id.inspect + " : "
51
+ run.id[0].to_s + ","
52
+ #""
53
+ end
54
+ # Merge an additional runner.
25
55
  def add_runner(runner)
56
+ index = @runners.size
26
57
  @runners.push runner
27
58
  runner.run_list.each do |id, run|
28
59
  #raise "Duplicate ids: #{id}" if @run_list[id]
29
- @run_list[id] = run
60
+ merged_run = Run::Merged.new(index, run)
61
+ @run_list[merged_run.id] = merged_run
30
62
  end
31
63
  @ids = @run_list.keys
32
64
  end
65
+ # Call a method on each runner and combine the results according to
66
+ # the block.
67
+ # E.g.
68
+ # string_of_root_folders = merged_runner.merge_method(:root_folder){|string, folder| string << "," << folder}
33
69
  def merge_method(meth, *args, &block)
34
70
  results = @runners.map{|r| r.send(meth, *args)}
35
71
  return results.inject{|o,n| yield(o,n)}
@@ -37,4 +73,27 @@ class CodeRunner
37
73
 
38
74
 
39
75
  end
76
+ # This is a container for run objects for use in a merged runner.
77
+ # Basically its job is to route all methods to the run it contains,
78
+ # except for the id method, which is redefined.
79
+ #
80
+ # Instead of being a number, the id of the run is now an array of two
81
+ # numbers, of which the second is the id of the run contained, but the
82
+ # first is the index of the runner which the run corresponds to.
83
+ #
84
+ # Thus, within a merged runner (an instance of CodeRunner::Merged), each
85
+ # run has a unique id, and the merged runner can treat the Run::Merged objects
86
+ # exactly as if they were simply Run objects.
87
+ class Run::Merged
88
+ attr_reader :run
89
+ attr_accessor :id
90
+ def initialize(runner_index, run)
91
+ @runner_index = runner_index
92
+ @run = run
93
+ @id = [@runner_index, @run.id]
94
+ end
95
+ def method_missing(meth, *args)
96
+ @run.send(meth, *args)
97
+ end
98
+ end
40
99
  end
@@ -1,6 +1,6 @@
1
1
  class RemoteCodeRunner < CodeRunner
2
2
  (CodeRunner.instance_methods - (Object.instance_methods + Log.instance_methods)).each do |meth|
3
- next if [:sort_runs, :print_out, :filter, :similar_runs, :get_max, :get_min, :generate_combined_ids, :setup_run_class, :get_run_class_name, :readout, :graphkit_from_lists, :graphkit, :graphkit_shorthand, :run_graphkit_shorthand, :axiskit, :filtered_ids, :filtered_run_list, :make_film_from_lists, :sweep_graphkits, :cache].include? meth
3
+ next if [:sort_runs, :print_out, :filter, :similar_runs, :get_max, :get_min, :generate_combined_ids, :setup_run_class, :get_run_class_name, :readout, :graphkit_from_lists, :graphkit, :graphkit_shorthand, :run_graphkit_shorthand, :axiskit, :filtered_ids, :filtered_run_list, :make_film_from_lists, :sweep_graphkits, :cache, :merged_runner_info].include? meth
4
4
  next if CodeRunner::DEFAULT_RUNNER_OPTIONS.keys.include? meth
5
5
  next if CodeRunner::DEFAULT_RUNNER_OPTIONS.keys.map{|meth| (meth.to_s + '=').to_sym}.include? meth
6
6
 
@@ -203,9 +203,16 @@ class TestCodeRunner < Test::Unit::TestCase
203
203
  @runner3 = CodeRunner.new(tfolder2).update
204
204
  assert_nothing_raised{@mrunner = CodeRunner::Merged.new(@runner, @runner3)}
205
205
  @mrunner.print_out(0)
206
+ #STDIN.gets
206
207
  assert_equal(@runner.run_list.size + 1, @mrunner.run_list.size)
207
208
  @mrunner2 = @runner.merge(@runner3)
208
209
  assert_equal(@mrunner2.run_list.keys, @mrunner.run_list.keys)
210
+ assert_nothing_raised{@mrunner.add_runner(@runner)}
211
+ assert_equal(CodeRunner::Run::Merged, @mrunner.run_list[[2, 6]].class)
212
+ assert_equal(6, @mrunner.run_list[[2, 6]].run.id)
213
+ assert_system("#$coderunner_command st -Y #{tfolder} -Y #{tfolder2}")
214
+ assert_raise(RuntimeError){@mrunner.submit}
215
+ #STDIN.gets
209
216
  FileUtils.rm_r tfolder2
210
217
  end
211
218
 
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.14.24
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edmund Highcock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-10 00:00:00.000000000 Z
11
+ date: 2014-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphkit