def test_run_ex_1_realistic(): # given global this_dir, logging_conf_fpath sim_conf_fpath = 'test_sets/ex_1_full/run_realistic.ini' exp_log_fpath = 'test_sets/ex_1_full/exp_log_realistic.txt' floader = fl.FileLoader() # when os.chdir(this_dir) sf.setup_logging(logging_conf_fpath) cs.run(sim_conf_fpath, floader) # then assert sf.compare_files_by_line('log.txt', exp_log_fpath, False) # tear down shutil.rmtree( os.path.join(this_dir, os.path.normpath('test_sets/ex_1_full/res_realistic'))) os.remove( os.path.join(this_dir, os.path.normpath('test_sets/useless/useless_1.tsv')))
def test_run_ex_3_uniform(): # given global this_dir, logging_conf_fpath sim_conf_fpath = 'test_sets/ex_3_max_matching/run_uniform.ini' exp_log_fpath = 'test_sets/ex_3_max_matching/exp_log_uniform.txt' floader = fl.FileLoader() # when os.chdir(this_dir) sf.setup_logging(logging_conf_fpath) cs.run(sim_conf_fpath, floader) # then assert sf.compare_files_by_line('log.txt', exp_log_fpath, False) # tear down shutil.rmtree( os.path.join( this_dir, os.path.normpath('test_sets/ex_3_max_matching/res_uniform'))) os.remove( os.path.join(this_dir, os.path.normpath('test_sets/useless/useless_3.tsv')))
# name of the independent variable of the simulation indep_var_name = batch_conf['indep_var_name'] logger.info('indep_var_name = {}'.format(indep_var_name)) # values of the independent value of the simulation indep_var_vals = pick_conf_values(batch_conf, 'indep_var_vals') logger.info('indep_var_vals = {}'.format(indep_var_vals)) # seeds used to execute multiple tests on the same network instance seeds = pick_conf_values(batch_conf, 'seeds') logger.info('seeds = {}'.format(seeds)) sim_cnt = len(base_configs) * len(indep_var_vals) * (last_instance - first_instance) * len(seeds) cur_sim_num = 0 floader = fl.FileLoader() for sim_group in range(0, len(base_configs)): run_num_by_inst = {} # number of simulations we ran for each instance i paths = base_configs[sim_group]['paths'] run_options = base_configs[sim_group]['run_opts'] group_results_dir = os.path.normpath(paths['results_dir']) sf.ensure_dir_exists(group_results_dir) misc = base_configs[sim_group]['misc'] misc['sim_group'] = sim_group paths['batch_conf_fpath'] = batch_conf_fpath safe_nodes_opts = None if 'safe_nodes_opts' in base_configs[sim_group]: safe_nodes_opts = base_configs[sim_group]['safe_nodes_opts'] changing_options = base_configs[sim_group][indep_var_section]