def run_scenarios(scenario_dir=SCENARIO_DIR, current_string=CURRENT_STRING, extension='.py', files=None): """ Run all of the the scenario's in the scenario_dir. parameters: scenario_dir: The path to the directory of scenarios current_string: Used in the timing file name extension: The last three characters of the scenario files. Bad hack to represent the file extension of the scenarios. Currently .py or par. Write timings and svn info to a file. """ timings = {} delimiter = ',' ofile = 'imp_test_performance.asc' fd = open(ofile, 'a') fd.write("version" + delimiter + "last_check_in_date" + delimiter + "modification_status" + delimiter + "scenario_file" + delimiter + "scenario_time" + "\n") files = par_files(scenario_dir, extension=extension, files=files) output_dirs = [] for file in files: pull_path = join(scenario_dir, file) eqrm_flags = parse_in_parameters.create_parameter_data(pull_path) output_dirs.append(join(eqrm_flags['output_dir'])) print "Running scenario", file # Initial time and memory t0 = time.clock() # Run the scenario analysis.main(pull_path, parallel_finalise=False) # Run post-processing (if needed) if eqrm_flags['save_motion']: postprocessing.generate_motion_csv(eqrm_flags['output_dir'], eqrm_flags['site_tag'], soil_amp=False) if eqrm_flags['use_amplification']: postprocessing.generate_motion_csv(eqrm_flags['output_dir'], eqrm_flags['site_tag'], soil_amp=True) root, ext = splitext(file) time_taken_sec = (time.clock() - t0) timings[root] = time_taken_sec version, date, modified = get_version() fd.write(str(version) + delimiter + str(date) + delimiter + str(modified) + delimiter + str(file) + delimiter + str(time_taken_sec) + "\n") fd.close() timings = Scenario_times(timings, current_string=current_string) return timings, output_dirs
def __init__(self): # This is a hack to get the version based on the eqrm_code dir current_dir = os.getcwd() os.chdir('..') #os.chdir('eqrm_code') self.version, date, modified = get_version() os.chdir(current_dir) self.host = platform.uname()[1] parallel = Parallel() self.node_number = str(parallel.rank)
def log_svn(level=logging.INFO): version, date, modified = get_version() svn_dic = {SVNVERSION_J:version, SVNDATE_J:date, SVNMODIFIED_J: modified} log_json(svn_dic, level)