class CodeRunner::Script

This is a module which can be used for submitting arbitrary scripts on supercomputers using the CodeRunner framework (see coderunner.sourceforge.net and coderunner on rubygems.org). It comes preinstalled with CodeRunner.

An example paints a thousand words: here is how to use it from the command line to submit a ruby script:

coderunner sub -W 60 -n 1x32 -C script -X '/usr/bin/env ruby' \
        -p '{file_name: "my_script.rb", arguments: "my command line args", \
                replace_tokens: {"TOKEN" => "replace"}'

The parameter replace_tokens takes a hash of {string => string} which will be used to modify the text in the script via

text.gsub!(Regexp.new(Regexp.escape("TOKEN")), replace)

Symbols may be used instead of strings

Public Instance Methods

generate_input_file() click to toggle source
# File lib/scriptcrmod.rb, line 75
def generate_input_file

        if @file_name
                files = @file_name.kind_of?(Array) ? @file_name : [@file_name] 
                files.each do |file|
                        ep ['Copying:', rcp.runner.root_folder + '/' + file, @directory + '/' + File.basename(file)]
                        #FileUtils.cp(rcp.runner.root_folder + '/' + file, @directory + '/' + File.basename(file))
                        text = File.read(rcp.runner.root_folder + '/' + file)
                        if @replace_tokens
                                @replace_tokens.each do |token, replace_str|
                                        text.gsub!(Regexp.new('\b' + Regexp.escape(token) + '\b'), replace_str.to_s)
                                end
                        end
                        File.open(@directory + '/' + File.basename(file), 'w'){|file| file.puts text}
                end
        else
                eputs 'Running without a script file...'
        end
end
generate_phantom_runs() click to toggle source

end

# File lib/scriptcrmod.rb, line 109
def generate_phantom_runs
end
graphkit(name, options) click to toggle source
# File lib/scriptcrmod.rb, line 112
def graphkit(name, options)
        case name
        when 'empty'
        else
                raise 'Unknown graph'
        end
end
parameter_string() click to toggle source
# File lib/scriptcrmod.rb, line 70
def parameter_string
        file = @file_name.kind_of?(Array) ? @file_name[0] : @file_name
        return sprintf("%s %s", file, @arguments.to_s)
end
parameter_transition(run) click to toggle source

@run_class.variables.keys

# File lib/scriptcrmod.rb, line 95
def parameter_transition(run)
end
print_out_line() click to toggle source
process_directory_code_specific() click to toggle source
# File lib/scriptcrmod.rb, line 54
def process_directory_code_specific
        if @running
                @status ||= :Incomplete
        else
                @status = :Complete
        end
        eval(File.read('script_outputs.rb')) if FileTest.exist? 'script_outputs.rb'
end
run_command() click to toggle source

Override whatever is in the system module

# File lib/scriptcrmod.rb, line 99
def run_command
        eputs "Warning: preamble does not end in a new line" unless !preamble or preamble =~ /\n\s*\Z/
        "#{preamble} #{executable_location}/#{executable_name} #{parameter_string}"
end