coderunner 0.11.2 → 0.11.3
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/Gemfile +1 -0
- data/VERSION +1 -1
- data/coderunner.gemspec +14 -1
- data/lib/coderunner.rb +15 -15
- data/lib/coderunner/feedback.rb +92 -0
- data/lib/coderunner/instance_methods.rb +1 -1
- data/lib/coderunner/long_regexen.rb +3 -2
- data/lib/coderunner/remote_code_runner.rb +284 -0
- data/lib/coderunner/run.rb +24 -24
- data/lib/coderunner/test.rb +35 -0
- data/lib/coderunner/version.rb +27 -0
- data/lib/cubecalccrmod.rb +106 -0
- data/lib/cubecalccrmod/cubecalc_defaults.rb +6 -0
- data/lib/cubecalccrmod/default_modlets/empty.rb +8 -0
- data/lib/cubecalccrmod/default_modlets/empty_defaults.rb +6 -0
- data/lib/cubecalccrmod/defaults_files/sleep_defaults.rb +6 -0
- data/lib/cubecalccrmod/my_modlets/sleep.rb +14 -0
- metadata +28 -2
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.11.
|
1
|
+
0.11.3
|
data/coderunner.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "coderunner"
|
8
|
-
s.version = "0.11.
|
8
|
+
s.version = "0.11.3"
|
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"]
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
"lib/code_runner_extension.rb",
|
36
36
|
"lib/coderunner.rb",
|
37
37
|
"lib/coderunner/class_methods.rb",
|
38
|
+
"lib/coderunner/feedback.rb",
|
38
39
|
"lib/coderunner/fortran_namelist.rb",
|
39
40
|
"lib/coderunner/graphs_and_films.rb",
|
40
41
|
"lib/coderunner/heuristic_run_methods.rb",
|
@@ -42,6 +43,7 @@ Gem::Specification.new do |s|
|
|
42
43
|
"lib/coderunner/interactive_methods.rb",
|
43
44
|
"lib/coderunner/long_regexen.rb",
|
44
45
|
"lib/coderunner/merged_code_runner.rb",
|
46
|
+
"lib/coderunner/remote_code_runner.rb",
|
45
47
|
"lib/coderunner/run.rb",
|
46
48
|
"lib/coderunner/system_modules/franklin.rb",
|
47
49
|
"lib/coderunner/system_modules/generic_linux.rb",
|
@@ -53,6 +55,14 @@ Gem::Specification.new do |s|
|
|
53
55
|
"lib/coderunner/system_modules/moab.rb",
|
54
56
|
"lib/coderunner/system_modules/new_hydra.rb",
|
55
57
|
"lib/coderunner/system_modules/slurm.rb",
|
58
|
+
"lib/coderunner/test.rb",
|
59
|
+
"lib/coderunner/version.rb",
|
60
|
+
"lib/cubecalccrmod.rb",
|
61
|
+
"lib/cubecalccrmod/cubecalc_defaults.rb",
|
62
|
+
"lib/cubecalccrmod/default_modlets/empty.rb",
|
63
|
+
"lib/cubecalccrmod/default_modlets/empty_defaults.rb",
|
64
|
+
"lib/cubecalccrmod/defaults_files/sleep_defaults.rb",
|
65
|
+
"lib/cubecalccrmod/my_modlets/sleep.rb",
|
56
66
|
"test/helper.rb",
|
57
67
|
"test/test_coderunner.rb"
|
58
68
|
]
|
@@ -68,6 +78,7 @@ Gem::Specification.new do |s|
|
|
68
78
|
|
69
79
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
70
80
|
s.add_runtime_dependency(%q<graphkit>, [">= 0.2.0"])
|
81
|
+
s.add_runtime_dependency(%q<parallelpipes>, [">= 1.0.0"])
|
71
82
|
s.add_runtime_dependency(%q<rubyhacks>, [">= 0.1.0"])
|
72
83
|
s.add_runtime_dependency(%q<gsl>, [">= 1.12.0"])
|
73
84
|
s.add_runtime_dependency(%q<ruby-netcdf>, [">= 0.6.6"])
|
@@ -77,6 +88,7 @@ Gem::Specification.new do |s|
|
|
77
88
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
78
89
|
else
|
79
90
|
s.add_dependency(%q<graphkit>, [">= 0.2.0"])
|
91
|
+
s.add_dependency(%q<parallelpipes>, [">= 1.0.0"])
|
80
92
|
s.add_dependency(%q<rubyhacks>, [">= 0.1.0"])
|
81
93
|
s.add_dependency(%q<gsl>, [">= 1.12.0"])
|
82
94
|
s.add_dependency(%q<ruby-netcdf>, [">= 0.6.6"])
|
@@ -87,6 +99,7 @@ Gem::Specification.new do |s|
|
|
87
99
|
end
|
88
100
|
else
|
89
101
|
s.add_dependency(%q<graphkit>, [">= 0.2.0"])
|
102
|
+
s.add_dependency(%q<parallelpipes>, [">= 1.0.0"])
|
90
103
|
s.add_dependency(%q<rubyhacks>, [">= 0.1.0"])
|
91
104
|
s.add_dependency(%q<gsl>, [">= 1.12.0"])
|
92
105
|
s.add_dependency(%q<ruby-netcdf>, [">= 0.6.6"])
|
data/lib/coderunner.rb
CHANGED
@@ -7,10 +7,13 @@ end
|
|
7
7
|
|
8
8
|
# Basic class setup
|
9
9
|
|
10
|
+
require 'rubygems'
|
11
|
+
require "rubyhacks"
|
10
12
|
class CodeRunner
|
11
13
|
|
12
14
|
COMMAND_FOLDER = Dir.pwd
|
13
15
|
SCRIPT_FOLDER = File.dirname(File.expand_path(__FILE__)) + '/coderunner' #i.e. where this script is
|
16
|
+
|
14
17
|
if ENV['CODE_RUNNER_OPTIONS']
|
15
18
|
GLOBAL_OPTIONS = eval(ENV['CODE_RUNNER_OPTIONS']) # global options are set by the environment but some can be changed.
|
16
19
|
else
|
@@ -18,7 +21,6 @@ class CodeRunner
|
|
18
21
|
end
|
19
22
|
SYS = (GLOBAL_OPTIONS[:system] or ENV['CODE_RUNNER_SYSTEM'] or ENV['SYSTEM'] or "generic_linux")
|
20
23
|
require SCRIPT_FOLDER + "/system_modules/#{SYS}.rb"
|
21
|
-
require SCRIPT_FOLDER + "/box_of_tricks.rb"
|
22
24
|
SYSTEM_MODULE = const_get(SYS.variable_to_class_name)
|
23
25
|
include SYSTEM_MODULE
|
24
26
|
class << self
|
@@ -56,7 +58,7 @@ $stderr.print 'Loading libraries...' unless $has_put_startup_message_for_code_ru
|
|
56
58
|
#read this if you are puzzled by
|
57
59
|
# some non-standard use of ruby
|
58
60
|
################################
|
59
|
-
require CodeRunner::SCRIPT_FOLDER + "/box_of_tricks.rb"
|
61
|
+
#require CodeRunner::SCRIPT_FOLDER + "/box_of_tricks.rb"
|
60
62
|
################################
|
61
63
|
|
62
64
|
require "getoptlong"
|
@@ -64,7 +66,7 @@ require "thread"
|
|
64
66
|
require "fileutils"
|
65
67
|
require "drb"
|
66
68
|
require "test/unit/assertions"
|
67
|
-
require
|
69
|
+
require 'parallelpipes'
|
68
70
|
require 'find'
|
69
71
|
|
70
72
|
begin
|
@@ -81,10 +83,7 @@ rescue LoadError
|
|
81
83
|
end
|
82
84
|
|
83
85
|
#require CodeRunner::SCRIPT_FOLDER + "/gnuplot.rb"
|
84
|
-
|
85
|
-
load CodeRunner::SCRIPT_FOLDER + "/graphkit_gnuplot2.rb"
|
86
|
-
load CodeRunner::SCRIPT_FOLDER + "/graphkit_vtk_legacy.rb"
|
87
|
-
load CodeRunner::SCRIPT_FOLDER + "/graphkit_mathematica.rb"
|
86
|
+
require "graphkit"
|
88
87
|
CodeRunner::GraphKit = GraphKit # Backwards compatibility
|
89
88
|
|
90
89
|
# load 'gnuplot'
|
@@ -92,20 +91,20 @@ load CodeRunner::SCRIPT_FOLDER + "/feedback.rb"
|
|
92
91
|
eprint '.' unless $has_put_startup_message_for_code_runner
|
93
92
|
load CodeRunner::SCRIPT_FOLDER + "/test.rb"
|
94
93
|
eprint '.' unless $has_put_startup_message_for_code_runner
|
95
|
-
load CodeRunner::SCRIPT_FOLDER + "/input_file_generator.rb"
|
96
|
-
eprint '.' unless $has_put_startup_message_for_code_runner
|
94
|
+
#load CodeRunner::SCRIPT_FOLDER + "/input_file_generator.rb"
|
95
|
+
#eprint '.' unless $has_put_startup_message_for_code_runner
|
97
96
|
load CodeRunner::SCRIPT_FOLDER + "/long_regexen.rb"
|
98
97
|
eprint '.' unless $has_put_startup_message_for_code_runner
|
99
98
|
load CodeRunner::SCRIPT_FOLDER + "/version.rb"
|
100
99
|
eprint '.' unless $has_put_startup_message_for_code_runner
|
101
100
|
load CodeRunner::SCRIPT_FOLDER + "/heuristic_run_methods.rb"
|
102
101
|
eprint '.' unless $has_put_startup_message_for_code_runner
|
103
|
-
load CodeRunner::SCRIPT_FOLDER + "/code_runner_version.rb"
|
104
|
-
eprint '.' unless $has_put_startup_message_for_code_runner
|
102
|
+
#load CodeRunner::SCRIPT_FOLDER + "/code_runner_version.rb"
|
103
|
+
#eprint '.' unless $has_put_startup_message_for_code_runner
|
105
104
|
load CodeRunner::SCRIPT_FOLDER + "/fortran_namelist.rb"
|
106
105
|
eprint '.' unless $has_put_startup_message_for_code_runner
|
107
106
|
|
108
|
-
|
107
|
+
CodeRunner::CODE_RUNNER_VERSION = Version.new(Gem.loaded_specs['coderunner'].version.to_s)
|
109
108
|
|
110
109
|
CodeRunner::GLOBAL_BINDING = binding
|
111
110
|
|
@@ -166,9 +165,10 @@ class CodeRunner
|
|
166
165
|
|
167
166
|
CLF = COMMAND_LINE_FLAGS = COMMAND_LINE_FLAGS_WITH_HELP.map{|arr| arr.slice(0..2)}
|
168
167
|
|
169
|
-
CODE_COMMAND_OPTIONS =
|
170
|
-
|
171
|
-
|
168
|
+
CODE_COMMAND_OPTIONS = [] # NEEDS FIXING!!!!
|
169
|
+
#(Dir.entries(SCRIPT_FOLDER + "/code_modules/") - [".", "..", ".svn"]).map do |d|
|
170
|
+
#["--#{d}-options", "", GetoptLong::REQUIRED_ARGUMENT, %[A hash of options for the #{d} code module]]
|
171
|
+
#end
|
172
172
|
|
173
173
|
LONG_COMMAND_LINE_OPTIONS = [
|
174
174
|
["--replace-existing", "", GetoptLong::NO_ARGUMENT, %[Use with resubmit: causes each resubmitted run to replace the run being resubmitted.]],
|
@@ -0,0 +1,92 @@
|
|
1
|
+
class Feedback
|
2
|
+
|
3
|
+
def gets #No reading from the command line thank you very much!
|
4
|
+
$stdin.gets
|
5
|
+
end
|
6
|
+
def self.gets
|
7
|
+
$stdin.gets
|
8
|
+
end
|
9
|
+
|
10
|
+
def Feedback.get_custom(question, regexp)
|
11
|
+
#NB regex is submitted as a string
|
12
|
+
puts question
|
13
|
+
cont = true
|
14
|
+
while cont
|
15
|
+
puts "---Please enter an answer of the form " + regexp
|
16
|
+
answer = gets.to_s
|
17
|
+
if answer =~ Regexp.new(regexp)
|
18
|
+
cont = false
|
19
|
+
else
|
20
|
+
puts "Incorrect form"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
return answer.chomp
|
24
|
+
end
|
25
|
+
|
26
|
+
def Feedback.get_boolean(question)
|
27
|
+
puts question
|
28
|
+
cont = true
|
29
|
+
while cont
|
30
|
+
puts "---Please enter y or n"
|
31
|
+
answer = gets
|
32
|
+
if answer =~ /^n$/i
|
33
|
+
cont = false
|
34
|
+
bool = false
|
35
|
+
elsif answer =~ /^y$/i
|
36
|
+
cont = false
|
37
|
+
bool = true
|
38
|
+
else
|
39
|
+
puts "Incorrect selection: #{answer.inspect}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
return bool
|
43
|
+
end
|
44
|
+
|
45
|
+
def Feedback.get_float(question)
|
46
|
+
puts question
|
47
|
+
cont = true
|
48
|
+
while cont
|
49
|
+
puts "---Please enter an answer of the form ^-?\\d[.e-\\d]*$"
|
50
|
+
answer = gets
|
51
|
+
if answer =~ /^-?\d[\d\.e-]*$/
|
52
|
+
cont = false
|
53
|
+
else
|
54
|
+
puts "Incorrect selection: #{answer.inspect}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
return answer.to_f
|
58
|
+
end
|
59
|
+
|
60
|
+
def Feedback.get_choice(question, choice)
|
61
|
+
case choice
|
62
|
+
when Hash
|
63
|
+
puts question
|
64
|
+
cont = true
|
65
|
+
old_choice = choice; choice = {}
|
66
|
+
old_choice.each do |key,value|
|
67
|
+
choice[key.to_s] = old_choice[key]
|
68
|
+
end
|
69
|
+
while cont
|
70
|
+
puts "Please select your choice (case sensitive)"
|
71
|
+
choice.each do |key,value|
|
72
|
+
puts key.to_s + ": " + value.to_s
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
answer = gets.chomp
|
77
|
+
if choice[answer]
|
78
|
+
cont = false
|
79
|
+
answer = choice[answer]
|
80
|
+
else
|
81
|
+
puts "Incorrect Selection: #{answer.inspect} - Please try again"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
when Array
|
85
|
+
hash = {}
|
86
|
+
choice.each_with_index{|choice,i| hash[i] = choice}
|
87
|
+
answer = self.get_choice(question, hash)
|
88
|
+
end
|
89
|
+
return answer
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -1733,7 +1733,7 @@ end
|
|
1733
1733
|
"/merged_code_runner.rb",
|
1734
1734
|
'/run.rb',
|
1735
1735
|
'/heuristic_run_methods.rb',
|
1736
|
-
'/run_backwards_compatibility.rb'
|
1736
|
+
#'/run_backwards_compatibility.rb'
|
1737
1737
|
].each do |file|
|
1738
1738
|
file = CodeRunner::SCRIPT_FOLDER + file
|
1739
1739
|
require file
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# $script_folder = File.dirname(File.expand_path(__FILE__))
|
2
|
-
require File.dirname(File.expand_path(__FILE__)) + "/box_of_tricks.rb"
|
2
|
+
#require File.dirname(File.expand_path(__FILE__)) + "/box_of_tricks.rb"
|
3
|
+
require 'rubyhacks'
|
3
4
|
|
4
5
|
module LongRegexen
|
5
6
|
|
@@ -198,4 +199,4 @@ if $0 == __FILE__
|
|
198
199
|
puts "t= 0.2000000000E+03 aky= 1.40 akx= -0.02 om= " =~ LongRegexen::FLOAT
|
199
200
|
puts "asd"
|
200
201
|
puts " -9.81730399614593e+38; // phi(2,33,43,2)" =~ Regexp.new("^\\s*?#{LongRegexen::FLOAT.verbatim}.*?\\sphi\\(\\d,(?<theta>\\d+),(?<kx>\\d+)")
|
201
|
-
end
|
202
|
+
end
|
@@ -0,0 +1,284 @@
|
|
1
|
+
class RemoteCodeRunner < CodeRunner
|
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
|
4
|
+
next if CodeRunner::DEFAULT_RUNNER_OPTIONS.keys.include? meth
|
5
|
+
next if CodeRunner::DEFAULT_RUNNER_OPTIONS.keys.map{|meth| (meth.to_s + '=').to_sym}.include? meth
|
6
|
+
|
7
|
+
undef_method meth
|
8
|
+
end
|
9
|
+
# class << self
|
10
|
+
# undef_method :graphkit_multiple_runners_from_frame_array
|
11
|
+
# def method_missing(method, *args)
|
12
|
+
# raise "Not a CodeRunner class method #{method}" unless (CodeRunner.methods + [:puts]).include? method
|
13
|
+
# if method.to_s =~ /=$/
|
14
|
+
# raise NoMethodError.new("unknown set method: #{method}")
|
15
|
+
# # @attributes[method] = args[0]
|
16
|
+
# # return
|
17
|
+
# end
|
18
|
+
# data = retrieve(method, *args)
|
19
|
+
# if method.to_s =~ /graphkit/
|
20
|
+
# return Marshal.load(data)
|
21
|
+
# else
|
22
|
+
# puts data
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
|
27
|
+
attr_accessor :combined_ids, :phantom_ids, :ids, :combined_run_list, :phantom_run_list, :run_list, :remote_cache, :libraries
|
28
|
+
|
29
|
+
# include Log
|
30
|
+
# puts instance_methods; exit
|
31
|
+
# SHOULD_NOT_BE_CALLED = :add_phantom
|
32
|
+
class << self
|
33
|
+
aliold :new
|
34
|
+
def new(host, folder, copts = {})
|
35
|
+
if host.length == 0
|
36
|
+
# p 'hello'
|
37
|
+
# copts[:Y] = folder
|
38
|
+
# copts[:no_print_out] = true
|
39
|
+
# copts[:no_update] = true
|
40
|
+
# return go(copts)
|
41
|
+
folder.sub!(/~/, ENV['HOME'])
|
42
|
+
# Dir.chdir(folder){read_defaults(copts)}
|
43
|
+
# p copts
|
44
|
+
return CodeRunner.new(folder, copts)
|
45
|
+
end
|
46
|
+
if copts[:cache]
|
47
|
+
if copts[:cache] == :auto and FileTest.exists? cache_file(host, folder)
|
48
|
+
begin
|
49
|
+
runner = Marshal.load(File.read(cache_file(host, folder)))
|
50
|
+
rescue TypeError, ArgumentError => err
|
51
|
+
eputs err
|
52
|
+
eputs data [0..100] if err.class == TypeError
|
53
|
+
raise err unless err.message =~ /undefined class/
|
54
|
+
repair_marshal_run_class_not_found_error(err)
|
55
|
+
retry
|
56
|
+
end
|
57
|
+
runner.remote_cache = copts[:cache]
|
58
|
+
runner.libraries ||= []
|
59
|
+
return runner
|
60
|
+
else
|
61
|
+
runner = old_new(host, folder, copts)
|
62
|
+
runner.update
|
63
|
+
runner.remote_cache = copts[:cache]
|
64
|
+
unless FileTest.exist? cache_folder(host, folder)
|
65
|
+
FileUtils.makedirs cache_folder(host, folder)
|
66
|
+
end
|
67
|
+
File.open(cache_file(host, folder), 'w') do |file|
|
68
|
+
file.puts Marshal.dump(runner)
|
69
|
+
end
|
70
|
+
return runner
|
71
|
+
end
|
72
|
+
else
|
73
|
+
return old_new(host, folder, copts)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
def cache_folder(host, folder)
|
78
|
+
RUNNER_CACHE + "/#{host}/#{folder.gsub(/\//, '_')}"
|
79
|
+
end
|
80
|
+
def cache_file(host, folder)
|
81
|
+
cache_folder(host, folder) + '/runner.msl'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
DISPLAY_REMOTE_INVOCATION = false
|
86
|
+
|
87
|
+
RUNNER_CACHE = ENV['HOME'] + '/.remote_code_runner_cache'
|
88
|
+
|
89
|
+
def initialize(host, folder, copts = {})
|
90
|
+
@folder = folder
|
91
|
+
@host = host
|
92
|
+
#eputs "setting libraries"
|
93
|
+
@libraries = []
|
94
|
+
if host.length == 1
|
95
|
+
unless Object.constants.include? HostManager.to_s.to_sym
|
96
|
+
raise CRFatal.new("Host manager not available")
|
97
|
+
end
|
98
|
+
HostManager.phoenix($default_host_manager_store) do |host_manager|
|
99
|
+
# @user_name = host_manager.hosts[host].user_name
|
100
|
+
# @host = host_manager.hosts[host].host
|
101
|
+
# @port = host_manager.hosts[host].port
|
102
|
+
@ssh_command = host_manager.hosts[host].ssh
|
103
|
+
end
|
104
|
+
else
|
105
|
+
# @user_name, @host = host.split(/@/)
|
106
|
+
@ssh_command = "ssh " + host
|
107
|
+
end
|
108
|
+
# @coderunner_location = coderunner_location
|
109
|
+
@attributes = {}
|
110
|
+
process_copts(copts)
|
111
|
+
end
|
112
|
+
def process_copts(copts)
|
113
|
+
@copts = copts.dup
|
114
|
+
@copts[:g] = @copts[:G] = []
|
115
|
+
# @copts[:f] = nil
|
116
|
+
@copts[:Y] = @copts[:w] = @copts[:r] = @copts[:e] = nil
|
117
|
+
@copts.delete(:E)
|
118
|
+
end
|
119
|
+
def method_missing(method, *args)
|
120
|
+
raise "Not a CodeRunner method #{method}" unless (CodeRunner.instance_methods + [:puts]).include? method
|
121
|
+
# ep method; STDIN.gets
|
122
|
+
|
123
|
+
if method.to_s =~ /=$/
|
124
|
+
raise NoMethodError.new("unknown set method: #{method}")
|
125
|
+
# @attributes[method] = args[0]
|
126
|
+
# return
|
127
|
+
end
|
128
|
+
data = retrieve_method(method, *args)
|
129
|
+
if method.to_s =~ /graphkit/
|
130
|
+
# puts Marshal.load(data).pretty_inspect
|
131
|
+
unless data
|
132
|
+
raise "Error: No data was returned from remote server when calling '#{method}'"
|
133
|
+
end
|
134
|
+
#return Marshal.load(data)
|
135
|
+
return data
|
136
|
+
else
|
137
|
+
puts data
|
138
|
+
end
|
139
|
+
end
|
140
|
+
def retrieve_method(method, *args)
|
141
|
+
eputs "Calling Remote Method: #{method}"
|
142
|
+
retrieve("#{method.to_s}(*#{args.inspect})")
|
143
|
+
end
|
144
|
+
def retrieve(string)
|
145
|
+
#ep '@host', @host, '@remote_cache', @remote_cache
|
146
|
+
cachename = self.class.cache_folder(@host, @folder) + '/' + string.gsub(/[\/:\\\[\]\(\)]/, '.')
|
147
|
+
if @remote_cache == :auto and FileTest.exist?(cachename)
|
148
|
+
return eval(File.read(cachename))
|
149
|
+
end
|
150
|
+
string = @libraries.map{|lib| "require #{lib}"}.join(";") + ";" + string
|
151
|
+
|
152
|
+
eputs "Connecting to server using '#{@ssh_command}'..."
|
153
|
+
eputs "Loading folder #{@folder}..."
|
154
|
+
# eval =
|
155
|
+
# > /dev/null 2> /dev/null > /dev/null 2> /dev/null
|
156
|
+
shell_script = <<EOF
|
157
|
+
cd #@folder
|
158
|
+
export ROWS=#{Terminal.terminal_size[0]}
|
159
|
+
export COLS=#{Terminal.terminal_size[1]}
|
160
|
+
source /etc/bashrc /etc/profile > /dev/null 2> /dev/null
|
161
|
+
source ~/.bashrc ~/.bash_login ~/.bash_profile ~/.profile > /dev/null 2> /dev/null
|
162
|
+
if [ "$CODE_RUNNER_COMMAND" ]
|
163
|
+
then
|
164
|
+
$CODE_RUNNER_COMMAND runner_eval #{string.inspect} -Z #{@copts.inspect.inspect}
|
165
|
+
else
|
166
|
+
coderunner runner_eval #{string.inspect} -Z #{@copts.inspect.inspect}
|
167
|
+
fi
|
168
|
+
|
169
|
+
EOF
|
170
|
+
# coderunner runner_eval #{"#{method.to_s}(*#{args.inspect})".inspect} -Z #{@copts.inspect.inspect}
|
171
|
+
|
172
|
+
eputs shell_script if DISPLAY_REMOTE_INVOCATION
|
173
|
+
data = %x[#@ssh_command '#{shell_script}']
|
174
|
+
# ep data
|
175
|
+
eputs "\nDisconnecting from server..."
|
176
|
+
eprint "Extracting data..."
|
177
|
+
data_arr = []
|
178
|
+
in_dump = false
|
179
|
+
i = 0
|
180
|
+
loop do
|
181
|
+
|
182
|
+
if i>=80 #data.size
|
183
|
+
break
|
184
|
+
|
185
|
+
else #if data[i-1] == "E" and data[i-2] == "_"
|
186
|
+
# ep data[i...(i + "code_runner_server_dump_start_E".size)], '.....'
|
187
|
+
# ep data[(-"code_runner_server_dump_end_E\n".size-i+1)..-i] if in_dump
|
188
|
+
|
189
|
+
# string = data[0...i]
|
190
|
+
# p string
|
191
|
+
if !in_dump and data[i...(i + "code_runner_server_dump_start_E".size)] == "code_runner_server_dump_start_E" # =~ /.*Begin Output\n\Z/
|
192
|
+
# ep "IN DUMP"
|
193
|
+
data = data[(i + "code_runner_server_dump_start_E".size)..-1]
|
194
|
+
in_dump = true
|
195
|
+
i = 0
|
196
|
+
elsif in_dump and data[(-"code_runner_server_dump_end_E\n".size-i+1)..-i] == "code_runner_server_dump_end_E\n" #
|
197
|
+
data_arr.push data[0...(data.size - ("code_runner_server_dump_end_E\n".size+i-1))]
|
198
|
+
# ep "OUT DUMP"
|
199
|
+
# ep data_arr
|
200
|
+
# data = data[0...-(-"code_runner_server_dump_end_E".size-i)]
|
201
|
+
in_dump = false
|
202
|
+
# i = 1
|
203
|
+
break
|
204
|
+
end
|
205
|
+
end
|
206
|
+
i+=1
|
207
|
+
end
|
208
|
+
|
209
|
+
eputs "done"
|
210
|
+
# ep data_arr; exit
|
211
|
+
|
212
|
+
|
213
|
+
begin
|
214
|
+
case data_arr.size
|
215
|
+
when 0
|
216
|
+
output = nil
|
217
|
+
when 1
|
218
|
+
output = Marshal.load(data_arr[0])
|
219
|
+
else
|
220
|
+
output = data_arr.map{|str| Marshal.load(str)}
|
221
|
+
end
|
222
|
+
rescue TypeError, ArgumentError => err
|
223
|
+
eputs err
|
224
|
+
eputs data[0..100] if err.class == TypeError
|
225
|
+
raise err unless err.message =~ /undefined class/
|
226
|
+
self.class.repair_marshal_run_class_not_found_error(err)
|
227
|
+
#NB this means that all code_names have to contain only lowercase letters:
|
228
|
+
# code, modlet = err.message.scan(/CodeRunner\:\:([A-Z][a-z0-9]+)([A-Z][\w]+)?Run/)[0]
|
229
|
+
# ep code, modlet
|
230
|
+
# modlet.gsub!(/\B([A-Z])/, '_\1') if modlet
|
231
|
+
# modlet = modlet.downcase if modlet
|
232
|
+
# @run_class = CodeRunner.setup_run_class(code.downcase, modlet: modlet)
|
233
|
+
retry
|
234
|
+
end
|
235
|
+
|
236
|
+
if [:refresh, :auto].include? @remote_cache
|
237
|
+
eputs "Writing Cache"
|
238
|
+
File.open(cachename, 'w'){|file| file.puts(output.inspect)}
|
239
|
+
end
|
240
|
+
return output
|
241
|
+
|
242
|
+
end
|
243
|
+
def update
|
244
|
+
# ep '@server1', @server
|
245
|
+
|
246
|
+
instance_vars = retrieve_method(:marshalled_variables) #.sub(/\A\s*/, '')
|
247
|
+
#begin
|
248
|
+
#instance_vars = Marshal.load(data)
|
249
|
+
#rescue TypeError, ArgumentError => err
|
250
|
+
#eputs err
|
251
|
+
#eputs data [0..100] if err.class == TypeError
|
252
|
+
#raise err unless err.message =~ /undefined class/
|
253
|
+
#self.class.repair_marshal_run_class_not_found_error(err)
|
254
|
+
##NB this means that all code_names have to contain only lowercase letters:
|
255
|
+
## code, modlet = err.message.scan(/CodeRunner\:\:([A-Z][a-z0-9]+)([A-Z][\w]+)?Run/)[0]
|
256
|
+
## ep code, modlet
|
257
|
+
## modlet.gsub!(/\B([A-Z])/, '_\1') if modlet
|
258
|
+
## modlet = modlet.downcase if modlet
|
259
|
+
## @run_class = CodeRunner.setup_run_class(code.downcase, modlet: modlet)
|
260
|
+
#retry
|
261
|
+
#end
|
262
|
+
# ep @run_class.executable
|
263
|
+
instance_vars[:@run_list].values.each{|run| run.runner=self}
|
264
|
+
# class_vars.each do |var, val|
|
265
|
+
# # raise 'found it ' + var.to_s if val.class == CodeRunner
|
266
|
+
# next if [:@@global_binding, :@@server, :SCRIPT_FOLDER, :@@sys].include? var
|
267
|
+
# self.class.class_variable_set(var, val)
|
268
|
+
# end
|
269
|
+
instance_vars.each do |var, val|
|
270
|
+
# puts val.class
|
271
|
+
# raise 'found it ' + var.to_s if val.class == CodeRunner
|
272
|
+
next if [:@server, :@sys].include? var
|
273
|
+
instance_variable_set(var, val)
|
274
|
+
end
|
275
|
+
# @run_class.executable = instance_vars[:@executable]
|
276
|
+
|
277
|
+
# ep @run_class.executable
|
278
|
+
# ep '@sort', @sort
|
279
|
+
sort_runs
|
280
|
+
# ep '@server', @server
|
281
|
+
return self
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
data/lib/coderunner/run.rb
CHANGED
@@ -231,24 +231,24 @@ def process_directory
|
|
231
231
|
# p @directory
|
232
232
|
@readme = nil
|
233
233
|
|
234
|
-
if @code_runner_version < Version.new('0.5.1')
|
235
|
-
begin
|
236
|
-
update_from_version_0_5_0_and_lower
|
237
|
-
rescue Errno::ENOENT => err # No code runner files were found
|
238
|
-
unless @runner.heuristic_analysis
|
239
|
-
puts err
|
240
|
-
raise CRFatal.new("No code runner files found: suggest using heuristic analysis (flag -H if you are using the code_runner script)")
|
241
|
-
end
|
242
|
-
unless @runner.current_request == :traverse_directories
|
243
|
-
|
244
|
-
raise CRMild.new("can't begin heuristic analysis until there has been a sweep over all directories") # this will get rescued
|
245
|
-
end
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
run_heuristic_analysis
|
250
|
-
end
|
251
|
-
end
|
234
|
+
#if @code_runner_version < Version.new('0.5.1')
|
235
|
+
#begin
|
236
|
+
#update_from_version_0_5_0_and_lower
|
237
|
+
#rescue Errno::ENOENT => err # No code runner files were found
|
238
|
+
#unless @runner.heuristic_analysis
|
239
|
+
#puts err
|
240
|
+
#raise CRFatal.new("No code runner files found: suggest using heuristic analysis (flag -H if you are using the code_runner script)")
|
241
|
+
#end
|
242
|
+
#unless @runner.current_request == :traverse_directories
|
243
|
+
#@runner.requests.push :traverse_directories unless @runner.requests.include? :traverse_directories
|
244
|
+
#raise CRMild.new("can't begin heuristic analysis until there has been a sweep over all directories") # this will get rescued
|
245
|
+
#end
|
246
|
+
#@runner.increment_max_id
|
247
|
+
#@id = @runner.max_id
|
248
|
+
#@job_no = -1
|
249
|
+
#run_heuristic_analysis
|
250
|
+
#end
|
251
|
+
#end
|
252
252
|
|
253
253
|
|
254
254
|
read_info
|
@@ -442,7 +442,7 @@ end
|
|
442
442
|
def update_submission_parameters(parameters, start_from_defaults=true)
|
443
443
|
logf(:update_submission_parameters)
|
444
444
|
if start_from_defaults
|
445
|
-
upgrade_defaults_from_0_5_0 if self.class.constants.include? :DEFAULTS_FILE_NAME_0_5_0
|
445
|
+
#upgrade_defaults_from_0_5_0 if self.class.constants.include? :DEFAULTS_FILE_NAME_0_5_0
|
446
446
|
main_defaults_file = "#{defaults_location}/#{defaults_file_name}"
|
447
447
|
main_defaults_file_text = File.read(main_defaults_file)
|
448
448
|
evaluate_defaults_file(main_defaults_file)
|
@@ -753,11 +753,11 @@ def self.check_and_update
|
|
753
753
|
@readout_list = (rcp.variables+rcp.results) unless rcp.readout_list
|
754
754
|
# (variables+results).each{|v| const_get(:READOUT_LIST).push v} unless READOUT_LIST.size > 0
|
755
755
|
|
756
|
-
if rcp.variables_0_5_0
|
757
|
-
rcp.variables_0_5_0.dup.each do |par, info| #for backwards compatibility only
|
758
|
-
rcp.variables_0_5_0[par] = info[0] if info.class == Array
|
759
|
-
end
|
760
|
-
end
|
756
|
+
#if rcp.variables_0_5_0
|
757
|
+
#rcp.variables_0_5_0.dup.each do |par, info| #for backwards compatibility only
|
758
|
+
#rcp.variables_0_5_0[par] = info[0] if info.class == Array
|
759
|
+
#end
|
760
|
+
#end
|
761
761
|
|
762
762
|
|
763
763
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Tst
|
2
|
+
def self.check(name, obj, test_string, expected_results, error_class)
|
3
|
+
value = obj.instance_eval test_string
|
4
|
+
unless (expected_results.class == Array ? expected_results.include?(value) : value == expected_results)
|
5
|
+
message = "\n==============================\n"
|
6
|
+
message += "= Test Failed =\n"
|
7
|
+
message += "==============================\n\n"
|
8
|
+
message += "Object Description: #{name}\n"
|
9
|
+
message += "Object Value: #{obj.inspect}\n"
|
10
|
+
message += "Test: #{test_string.inspect}\n"
|
11
|
+
message += "Expected Result: #{expected_results}\n"
|
12
|
+
message += "Actual Result: #{value.inspect}"
|
13
|
+
message += "\n\n==============================="
|
14
|
+
raise error_class.new(message)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class TestProc < Proc
|
19
|
+
alias :test :call
|
20
|
+
end
|
21
|
+
class MakeProc < Proc
|
22
|
+
alias :with_result :call
|
23
|
+
end
|
24
|
+
|
25
|
+
#MakeProcs - used for making tests
|
26
|
+
KIND_OF = MakeProc.new{|*klasses| TestProc.new{|obj, name=""| check(name, obj, klasses.inject(""){|str, klass| str << " or self.kind_of? #{klass.to_s}"}.sub(/^ or /, '') , true, TypeError)}}
|
27
|
+
VALUE = MakeProc.new{|*values| TestProc.new{|obj, name=""| check(name, obj, "self", values, ArgumentError)}}
|
28
|
+
|
29
|
+
#Some predefined tests
|
30
|
+
FLOAT = KIND_OF.with_result(Float, Integer)
|
31
|
+
FLOAT_STRICT = KIND_OF.with_result(Float)
|
32
|
+
INT= INTEGER = KIND_OF.with_result(Integer)
|
33
|
+
STRING = KIND_OF.with_result(String)
|
34
|
+
FORTRAN_BOOL = VALUE.with_result(*String::FORTRAN_BOOLS)
|
35
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Version
|
2
|
+
include Comparable
|
3
|
+
|
4
|
+
attr_reader :major, :feature_group, :feature, :bugfix
|
5
|
+
|
6
|
+
def initialize(version="")
|
7
|
+
v = version.split(".")
|
8
|
+
@major = v[0].to_i
|
9
|
+
@feature_group = v[1] ? v[1].to_i : 0
|
10
|
+
@feature = v[2] ? v[2].to_i : 0
|
11
|
+
@bugfix = v[2] ? v[3].to_i : 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def <=>(other)
|
15
|
+
return @major <=> other.major if ((@major <=> other.major) != 0)
|
16
|
+
return @feature_group <=> other.feature_group if ((@feature_group <=> other.feature_group) != 0)
|
17
|
+
return @feature <=> other.feature if ((@feature <=> other.feature) != 0)
|
18
|
+
return @bugfix <=> other.bugfix
|
19
|
+
end
|
20
|
+
def self.sort
|
21
|
+
self.sort!{|a,b| a <=> b}
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
@major.to_s + "." + @feature_group.to_s + "." + @feature.to_s + "." + @bugfix.to_s
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
class CodeRunner
|
2
|
+
class Cubecalc < Run
|
3
|
+
|
4
|
+
# @code = 'cubecalc'
|
5
|
+
|
6
|
+
@variables = [:calculate_sides, :width, :height, :depth, :area]
|
7
|
+
|
8
|
+
@naming_pars = [:width]
|
9
|
+
|
10
|
+
@results = [:volume, :sides]
|
11
|
+
|
12
|
+
# e.g. number of iterations
|
13
|
+
|
14
|
+
@run_info = [:phantom_run_description]
|
15
|
+
|
16
|
+
# @@executable_name = 'cubecalc'
|
17
|
+
|
18
|
+
@code_long = "Cube Volume Calculator"
|
19
|
+
|
20
|
+
@excluded_sub_folders = []
|
21
|
+
|
22
|
+
@defaults_file_name = "cubecalc_defaults.rb"
|
23
|
+
|
24
|
+
@modlet_required = true
|
25
|
+
|
26
|
+
@uses_mpi = false
|
27
|
+
|
28
|
+
def process_directory_code_specific
|
29
|
+
if @running
|
30
|
+
@status = :Incomplete
|
31
|
+
else
|
32
|
+
if FileTest.exist? 'results.txt'
|
33
|
+
@status = :Complete
|
34
|
+
@volume = File.readlines('results.txt')[0].scan(LongRegexen::FLOAT)[0][0].to_f
|
35
|
+
else
|
36
|
+
@status = :Failed
|
37
|
+
end
|
38
|
+
@sides = []
|
39
|
+
if FileTest.exist? 'sides.txt'
|
40
|
+
File.read('sides.txt').scan(Regexp.new("is\\s*" + LongRegexen::FLOAT.verbatim + "$")){@sides.push $~[:float].to_f}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def print_out_line
|
46
|
+
if @is_phantom
|
47
|
+
if @phantom_run_description == :area
|
48
|
+
return sprintf("%d:%d %30s %10s %f %s", @id, @job_no, @run_name, @status, (@volume or 0.0), @area.to_s)
|
49
|
+
else
|
50
|
+
raise 'there is only one phantom_run_description at the moment'
|
51
|
+
end
|
52
|
+
else
|
53
|
+
return sprintf("%d:%d %30s %10s %f %s", @id, @job_no, @run_name, @status, (@volume or 0.0), @sides.to_s)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def parameter_string
|
58
|
+
return sprintf("%d %s", @calculate_sides, 'edges.txt')
|
59
|
+
end
|
60
|
+
|
61
|
+
def generate_input_file
|
62
|
+
File.open('edges.txt', 'w') do |file|
|
63
|
+
file.puts @width
|
64
|
+
file.puts @height
|
65
|
+
file.puts @depth
|
66
|
+
end
|
67
|
+
end
|
68
|
+
# @run_class.variables.keys[0]
|
69
|
+
def parameter_transition(run)
|
70
|
+
end
|
71
|
+
|
72
|
+
def executable_location
|
73
|
+
@runner.script_folder + '/test_suite'
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
def generate_phantom_runs
|
78
|
+
return unless @sides
|
79
|
+
@sides.each do |area|
|
80
|
+
# puts 'creating phantom: ' + @run_name
|
81
|
+
phantom = create_phantom
|
82
|
+
phantom.area = area
|
83
|
+
phantom.phantom_run_description = :area
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def graphkit(name, options)
|
88
|
+
case name
|
89
|
+
when /sides/
|
90
|
+
# x = AxisKit.autocreate({data: ["'width'", "'depth'", "'height'"], name: 'Properties'})
|
91
|
+
x = GraphKit::AxisKit.autocreate({data: sides, title: "Areas of the Sides: #@run_name"})
|
92
|
+
# x.range = [0, x.data.max]
|
93
|
+
kit = GraphKit.autocreate({x: x})
|
94
|
+
kit.style = 'data histograms'
|
95
|
+
kit.file_name = 'inputs'
|
96
|
+
# kit.with = 'histogram clustered'
|
97
|
+
return kit
|
98
|
+
else
|
99
|
+
raise 'Unknown graph'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CodeRunner
|
2
|
+
class Cubecalc
|
3
|
+
class Sleep < Cubecalc
|
4
|
+
|
5
|
+
@variables = [:calculate_sides, :width, :height, :depth, :sleep_time]
|
6
|
+
|
7
|
+
def parameter_string
|
8
|
+
return sprintf("%d %s %d", @calculate_sides, 'edges.txt', @sleep_time)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
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.11.
|
4
|
+
version: 0.11.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.2.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: parallelpipes
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.0.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.0.0
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: rubyhacks
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,6 +186,7 @@ files:
|
|
170
186
|
- lib/code_runner_extension.rb
|
171
187
|
- lib/coderunner.rb
|
172
188
|
- lib/coderunner/class_methods.rb
|
189
|
+
- lib/coderunner/feedback.rb
|
173
190
|
- lib/coderunner/fortran_namelist.rb
|
174
191
|
- lib/coderunner/graphs_and_films.rb
|
175
192
|
- lib/coderunner/heuristic_run_methods.rb
|
@@ -177,6 +194,7 @@ files:
|
|
177
194
|
- lib/coderunner/interactive_methods.rb
|
178
195
|
- lib/coderunner/long_regexen.rb
|
179
196
|
- lib/coderunner/merged_code_runner.rb
|
197
|
+
- lib/coderunner/remote_code_runner.rb
|
180
198
|
- lib/coderunner/run.rb
|
181
199
|
- lib/coderunner/system_modules/franklin.rb
|
182
200
|
- lib/coderunner/system_modules/generic_linux.rb
|
@@ -188,6 +206,14 @@ files:
|
|
188
206
|
- lib/coderunner/system_modules/moab.rb
|
189
207
|
- lib/coderunner/system_modules/new_hydra.rb
|
190
208
|
- lib/coderunner/system_modules/slurm.rb
|
209
|
+
- lib/coderunner/test.rb
|
210
|
+
- lib/coderunner/version.rb
|
211
|
+
- lib/cubecalccrmod.rb
|
212
|
+
- lib/cubecalccrmod/cubecalc_defaults.rb
|
213
|
+
- lib/cubecalccrmod/default_modlets/empty.rb
|
214
|
+
- lib/cubecalccrmod/default_modlets/empty_defaults.rb
|
215
|
+
- lib/cubecalccrmod/defaults_files/sleep_defaults.rb
|
216
|
+
- lib/cubecalccrmod/my_modlets/sleep.rb
|
191
217
|
- test/helper.rb
|
192
218
|
- test/test_coderunner.rb
|
193
219
|
homepage: http://coderunner.sourceforge.net
|
@@ -205,7 +231,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
231
|
version: '0'
|
206
232
|
segments:
|
207
233
|
- 0
|
208
|
-
hash: -
|
234
|
+
hash: -4238312090004986134
|
209
235
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
236
|
none: false
|
211
237
|
requirements:
|