Class: EvaluatorTemplate

Inherits:
Object
  • Object
show all
Includes:
LoggedClass
Defined in:
lib/evaluator_template.rb

Constant Summary

Constants included from LoggedClass

LoggedClass::LoggedClasses

Instance Method Summary collapse

Methods included from LoggedClass

#debug, #error, #fatal, generate_outputter_config, included, #info, #warn

Instance Method Details

#get_evaluator(algo_name, folder_compile, folder_eval, host_group_compile, host_group_eval, storage, versions, standard_flags) ⇒ Object

Creates an Evaluator based on this template.

Parameters:

  • algo_name (String)

    Name of the algorithm. This is used for the generation of the name of the jobs.

  • folder_compile (String)

    Initial working directory of the compile commandline.

  • folder_eval (String)

    Initial working directory of the evaluation commandline.

  • versions (Object)

    For this parameter see the explaination in the class description.

  • standard_flags (String)

    For this parameter see the explaination in the class description.

  • storage (String)

    SCP-Target string that represents a transport storage between compile and eval host.

  • host_group_compile (String)

    The host group for the compilation jobs.

  • host_group_eval (String)

    The host group for the evaluation jobs.


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/evaluator_template.rb', line 41

def get_evaluator(algo_name, folder_compile, folder_eval,
                  host_group_compile, host_group_eval,
                  storage, versions, standard_flags)
  result_transformator = lambda do |meta_result|
    meta_result.map! do |result_array|
      result_array.map!(&:wait_for_completion)
    end
  end

  Evaluator.new algo_name, folder_compile, folder_eval,
    @compile_line, @eval_line,
    versions, standard_flags, storage,
    host_group_compile, host_group_eval,
    @compile_output_parser, @eval_output_parser, result_transformator
end

#read_from_file(filename) ⇒ Object

Reads an EvaluatorTemplate from a file. After reading the template from a file you can create instances using #get_evaluator. For the file format see the adoption documentation.

Parameters:

  • filename (String)

    The name of the file to be read from.

See Also:

  • Adoption documentation}.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/evaluator_template.rb', line 13

def read_from_file(filename)
  debug "reading Evaluator Template from file #{filename}"
  doc = REXML::Document.new open(filename)

  doc.elements.each("evaluator") do |elem|
    @compile_line, @eval_line = [%w{compile upload},
                                 %w{download run}].map do |names|
      generate_line_lambda_from_tree(elem, *names)
    end

    eval_output_parser = elem.elements["eval-output-parser"] || nil
    compile_output_parser = elem.elements["compile-output-parser"] || nil
    @eval_output_parser = eval_output_parser.nil? ? nil :
      generate_output_parser(eval_output_parser.text)
    @compile_output_parser = compile_output_parser.nil? ? nil :
      generate_output_parser(compile_output_parser.text)
  end
end