Class: CodeRunner::Merged
- Inherits:
-
CodeRunner
- Object
- CodeRunner
- CodeRunner::Merged
- Includes:
- Enumerable
- Defined in:
- lib/coderunner/merged_code_runner.rb
Overview
This class allows the analysis of multiple root folders as if they were one. For every normal runner (instance of CodeRunner) that is added to the merged runner (instance of CodeRunner::Merged), the runs of that normal runner are added to the merged run_list. Normal runner function such as CodeRunner#graphkit() can then be called.
In order to keep the run_list unique, the runs from each component runner are not added to the merged runner directly: instead they are wrapped in a container of class Run::Merged which behaves like a standard run object except that it redefines the id to be [runner_index, id]. Thus, within the merged runner, the id of run 43 from the third runner to be added to the merged runner is [2,43].
Constant Summary
Constants inherited from CodeRunner
CLASS_OPTIONS, CLF, CLF_BOOLS, CLF_INVERSE_BOOLS, CLF_TO_LONG, CLF_TO_SHORT_COPTS, CODE_COMMAND_OPTIONS, CODE_OPTIONS, CODE_RUNNER_VERSION, COMMANDS, COMMANDS_WITH_HELP, COMMAND_FOLDER, COMMAND_LINE_FLAGS_WITH_HELP, CONFIG_FILE, CONFIG_FOLDER, DEFAULT_COMMAND_OPTIONS, DEFAULT_RUNNER_OPTIONS, FOLDER_DEFAULTS, GLOBAL_BINDING, GLOBAL_OPTIONS, GraphKit, LONG_COMMAND_LINE_FLAGS, LONG_COMMAND_LINE_OPTIONS, LONG_TO_SHORT, NECESSARY_RUN_CLASS_PROPERTIES, NECESSARY_RUN_CODE_METHODS, NECESSARY_RUN_SYSTEM_METHODS, PERMITTED_STATI, SCRIPT_FOLDER, SETUP_RUN_CLASSES, SUBMIT_OPTIONS, SYS, SYSTEM_MODULE
Instance Attribute Summary collapse
-
#runners ⇒ Object
readonly
Iterates over the runners contained within the merged runner.
Attributes inherited from CodeRunner
#cache, #cmaxes, #cmins, #code, #combined_ids, #combined_run_list, #component_ids, #component_run_list, #current_request, #current_status, #defaults_file, #executable, #ids, #max_id, #maxes, #mins, #modlet, #print_out_size, #requests, #root_folder, #run_class, #run_list, #start_id
Instance Method Summary collapse
-
#add_runner(runner) ⇒ Object
Merge an additional runner.
- #each ⇒ Object
-
#initialize(*runners) ⇒ Merged
constructor
Create a new merged runner.
-
#merge_method(meth, *args, &block) ⇒ Object
Call a method on each runner and combine the results according to the block.
-
#merged_runner_info(run) ⇒ Object
A string prepended to each line of the status output for merged runners…
-
#save_large_cache ⇒ Object
Do nothing.
-
#submit(*args) ⇒ Object
Raises an error.
-
#update(*args) ⇒ Object
Iterate over each of the merged runners, updating them.
Methods inherited from CodeRunner
#add_component_run, #alter_ids, available_defaults_files, available_modlets, #axiskit, cancel, #cancel_job, change_run_id, code_command, #code_run_environment, code_runner_execute, concat, #continue_in_new_folder, continue_in_new_folder, #create_archive, delete, #destroy, differences_between, directory, dumb_film, #dup, #executable_location, #executable_name, execute, fetch_runner, film, #film_graphkit, film_graphkit_frame_array, #film_run_graphkit, #filter, #filtered_ids, #generate_combined_ids, generate_cubecalc, generate_documentation, #get_all_root_folder_contents, #get_max, #get_min, #get_run_class, get_run_class_name, #get_run_class_name, get_submit_runner, #gets, gets, global_options, #graphkit, #graphkit_from_lists, #graphkit_from_lists_with_frame_array, graphkit_multiple_runners, graphkit_multiple_runners_with_frame_array, #graphkit_shorthand, #increment_max_id, interactive_mode, #is_in_repo?, #job_identifier, launcher_directory, load_file, #make_film_from_lists, make_film_multiple_runners, make_film_multiple_runners_old, manual, #marshalled_variables, #merge, netcdf_plot, #new_run, old_get_run_class_name, #p, #parameter_scan, parameter_scan, plot_graph, #print, #print_out, print_queue_status, process_command_line_option, process_command_options, process_root_folder, #puts, #rcp, read_default_command_options, #read_defaults, #read_folder_defaults, #readout, readout, #readout_cols, recheck, #recheck_filtered_runs, #recheck_incomplete_runs, reference, repair_marshal_run_class_not_found_error, #respond_to_requests, resubmit, run_class, run_command, #run_graphkit, #run_graphkit_shorthand, run_script, runner, runner_eval, #runs, #save_all, scan, #server_dump, server_dump, set_class_defaults, set_default_command_options_from_command_line, set_runner_defaults, #set_start_id, #setup_run_class, setup_run_class, show_values_of, #similar_runs, #simple_scan, #sort_runs, start_launcher, status, status_loop, status_loop_running, status_with_comments, submit, submit_command, #sweep_graphkits, update_runners, #write_data, write_graph, write_report
Constructor Details
#initialize(*runners) ⇒ Merged
Create a new merged runner. runners
is an array of standard runners (i.e. instances of CodeRunner).
37 38 39 40 41 42 43 44 45 |
# File 'lib/coderunner/merged_code_runner.rb', line 37 def initialize(*runners) @runners = [] r = runners[0] r.instance_variables.each do |v| instance_variable_set(v, r.instance_variable_get(v)) end @run_list = {} runners.each{|runner| add_runner(runner)} end |
Instance Attribute Details
#runners ⇒ Object (readonly)
Iterates over the runners contained within the merged runner. E.g.
merged_runner.each{|runner| p runner.root_folder}
26 27 28 |
# File 'lib/coderunner/merged_code_runner.rb', line 26 def runners @runners end |
Instance Method Details
#add_runner(runner) ⇒ Object
Merge an additional runner.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/coderunner/merged_code_runner.rb', line 63 def add_runner(runner) index = @runners.size @runners.push runner runner.run_list.each do |id, run| #raise "Duplicate ids: #{id}" if @run_list[id] merged_run = Run::Merged.new(index, run) @run_list[merged_run.id] = merged_run end @ids = @run_list.keys end |
#each ⇒ Object
27 28 29 |
# File 'lib/coderunner/merged_code_runner.rb', line 27 def each @runners.each{|r| yield(r)} end |
#merge_method(meth, *args, &block) ⇒ Object
Call a method on each runner and combine the results according to the block. E.g.
string_of_root_folders = merged_runner.merge_method(:root_folder){|string, folder| string << "," << folder}
77 78 79 80 |
# File 'lib/coderunner/merged_code_runner.rb', line 77 def merge_method(meth, *args, &block) results = @runners.map{|r| r.send(meth, *args)} return results.inject{|o,n| yield(o,n)} end |
#merged_runner_info(run) ⇒ Object
A string prepended to each line of the status output for merged runners… see CodeRunner#print_out
54 55 56 57 58 |
# File 'lib/coderunner/merged_code_runner.rb', line 54 def merged_runner_info(run) #run.id.inspect + " : " run.id[0].to_s + "," #"" end |
#save_large_cache ⇒ Object
Do nothing
60 61 |
# File 'lib/coderunner/merged_code_runner.rb', line 60 def save_large_cache end |
#submit(*args) ⇒ Object
Raises an error. At the present time, submitting from a merged runner has no defined behaviour and is not implemented.
49 50 51 |
# File 'lib/coderunner/merged_code_runner.rb', line 49 def submit(*args) raise "Submitting from a merged runner is currently not supported" end |
#update(*args) ⇒ Object
Iterate over each of the merged runners, updating them.
31 32 33 |
# File 'lib/coderunner/merged_code_runner.rb', line 31 def update(*args) each{|r| r.update(*args)} end |