Method: CodeRunner::Run.check_and_update

Defined in:
lib/coderunner/run.rb

.check_and_updateObject

ALL = [] READOUT_LIST = [] CODE = nil



831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
# File 'lib/coderunner/run.rb', line 831

def self.check_and_update
    Log.logf(:check_and_update)

#   
    finish_setting_up_class
#         ep self.to_s, constants, self.ancestors

#     raise CRFatal.new("Code not defined (#{CODE.inspect}) in class #{self.to_s}") unless CODE and CODE.class == String and CODE =~ /\S/  


    NECESSARY_RUN_SYSTEM_METHODS.each do |method|
      raise CRFatal.new("#{method} not defined in #{SYS}_system_runner.rb") unless instance_methods.include?(method)
    end

    NECESSARY_RUN_CODE_METHODS.each do |method|
      raise CRFatal.new("#{method} not defined in #{self.class}_code_runner.rb") unless instance_methods.include?(method)
    end
  
    
    NECESSARY_RUN_CLASS_PROPERTIES.each do |v,class_list|
#       raise CRFatal.new("#{v} not defined") unless rcp[v]
      raise CRFatal.new("#{v} not defined correctly: class is #{rcp[v].class} instead of one of #{class_list.to_s}") unless class_list.include? rcp[v].class
    end
    
    @readout_list = (rcp.variables+rcp.results) unless rcp.readout_list?

    raise "

Please add the line 

-----------------------------------------------------------
@code_module_folder = folder = File.dirname(File.expand_path(__FILE__)) # i.e. the directory this file is in
---------------------------------------------------------

to your code module.
    
    " unless rcp.code_module_folder?

#     (variables+results).each{|v| const_get(:READOUT_LIST).push v} unless READOUT_LIST.size > 0

    #if rcp.variables_0_5_0
      #rcp.variables_0_5_0.dup.each do |par, info| #for backwards compatibility only
        #rcp.variables_0_5_0[par] = info[0] if info.class == Array
      #end
    #end





#     Log.log(:@@variables0, @@variables[0])

    @run_info = rcp.run_info || [] # Run info can optionally be defined in the code module.
#     ep @run_info
    @run_info = rcp.run_info + ([:preamble, :job_no, :running, :id, :status, :sys, :is_component, :naming_pars, :run_name, :resubmit_id, :real_id, :component_runs, :parameter_hash, :parameter_hash_string, :output_file, :error_file, :extra_files, :code_run_environment] + SUBMIT_OPTIONS) #.each{|v| RUN_INFO.push v} unless RUN_INFO.include? :job_no
    @all = (rcp.variables + rcp.results + rcp.run_info) #.each{|v| ALL.push v}
#     ep "GOT HERE"
    (@all + [:directory, :run_name, :modlet, :relative_directory]).each{|var| send(:attr_accessor, var)}
    #eputs "Checking and updating"
    @user_defaults_location = ENV['HOME'] + "/.coderunner/#{rcp.code}crmod/defaults_files"
    #eputs ' user_defaults_location', rcp.user_defaults_location
    define_method(:output_file) do 
      return @output_file if @output_file
      @output_file = super()
    end
    define_method(:error_file) do 
      return @error_file if @error_file
      @error_file = super()
    end

    Dir.chdir(SCRIPT_FOLDER + "/system_modules") do 
    @system_run_classes ||=   
      Dir.entries(Dir.pwd).find_all{|file| file =~ /^[^\.].+\.rb$/}.inject([]) do |arr, file|
        #p Dir.pwd
        #p 'required', file, Dir.pwd
        require Dir.pwd + '/' + file
#         p CodeRunner.constants
        sys = file.sub(/\.rb$/, '')
        arr.push(add_a_child_class("#{sys.variable_to_class_name}Run"))
        arr[-1].send(:include, CodeRunner.const_get(sys.variable_to_class_name))
        arr
      end
    end

    
end