def run_in_project( main, project_dir_source, project_dir, event_name, config_path): playground_dir = get_playground_dir() with chdir(playground_dir): if os.path.exists(project_dir): shutil.rmtree(project_dir) put_test_data(project_dir_source + '/', project_dir) with chdir(project_dir): link_test_data( 'events/%s/' % event_name, 'data/events/%s/' % event_name) env = Environment([config_path, event_name]) conf = env.get_config() store_ids = conf.get_elements('target_groups[:].store_id') for store_id in store_ids: store_path = 'gf_stores/%s/' % store_id if not os.path.exists(store_path): link_test_data(store_path) problem_name = env.get_problem().name rundir_path = expand_template( conf.rundir_template, dict(problem_name=problem_name)) return main(env, rundir_path)
def get_rundir_paths(config_path, event_names): env = Environment([config_path] + event_names) conf = env.get_config() rundir_paths = [] for event_name in event_names: env.set_current_event_name(event_name) problem_name = env.get_problem().name rundir_paths.append(expand_template( conf.rundir_template, dict(problem_name=problem_name))) return rundir_paths
def run_example(project_name, config_path, quick_config_path, event_name): project_dir = project_name if os.path.exists(project_dir): shutil.rmtree(project_dir) grond('init', project_name, project_dir) with chdir(project_dir): assert os.path.isdir('config') common.link_test_data('events/%s/' % event_name, 'data/events/%s/' % event_name) env = Environment([config_path, event_name]) conf = env.get_config() store_ids = conf.get_elements('target_groups[:].store_id') for store_id in store_ids: store_path = 'gf_stores/%s/' % store_id if not os.path.exists(store_path): common.link_test_data(store_path) problem_name = env.get_problem().name rundir_path = expand_template(conf.rundir_template, dict(problem_name=problem_name)) grond('check', config_path, event_name, '--save-stations-used=used_stations.txt') sorted(s.station for s in model.load_stations('used_stations.txt')) mod_conf = conf.clone() mod_conf.set_elements('analyser_configs[:].niterations', 100) mod_conf.set_elements('optimiser_config.sampler_phases[:].niterations', 100) mod_conf.set_elements('optimiser_config.nbootstrap', 10) mod_conf.set_basepath(conf.get_basepath()) config.write_config(mod_conf, quick_config_path) grond('go', quick_config_path, event_name) grond('harvest', '--force', '--export-fits=best,mean', rundir_path) grond('report', rundir_path)