def list_data(simfolder): """ List the number of runs that have been made per configuration. :param string simfolder: relative path to simfolder :returns: True if successful, False otherwise """ print("[StoSim] The configurations and number of runs made so far:\n") for sim in utils.get_subsimulation_names(utils.get_main_conf(simfolder)): print("Simulation: {}".format(sim)) # get a list w/ relevant params from first-found config file # they should be the same data_dirs = os.listdir("%s/data" % simfolder) sim_dirs = [d for d in data_dirs if d.startswith("sim{}".format(sim))] if len(sim_dirs) == 0: print("No runs found for simulation {}\n".format(sim)) continue conf = utils.get_combined_conf(simfolder) params = conf.options('params') charlen = 1 + sum([len(p) + 6 for p in params]) + 9 print('-' * charlen) print("|"), for p in params: print(" {} |".format(p)), print("| runs |") print('-' * charlen) # now show how much we have in each relevant dir for d in sim_dirs: print("|"), for p in params: v = d.split("_{}".format(p))[1].split("_")[0] print(" {}|".format(v.ljust(len(p) + 2))), print("| {} |".format(str(utils.runs_in_folder(simfolder, d)).rjust(4))) print('-' * charlen) return True
def prepare_folders_and_jobs(simfolder, limit_to={}, more=False): """ ensure that data and job directories exist, create jobs. limit_to can contain parameter settings we want to limit ourselves to (this is in case we add more data) :param string simfolder: relative path to simfolder :param dict limit_to: key-value pairs that narrow down the dataset, when empty (default) all possible configs are run :param boolean more: when True, new data will simply be added """ if not osp.exists("%s/data" % simfolder): os.mkdir('%s/data' % simfolder) if osp.exists("%s/jobs" % simfolder): rmtree('%s/jobs' % simfolder) os.mkdir('%s/jobs' % simfolder) conf = utils.get_main_conf(simfolder) create_jobs(conf, simfolder, limit_to=limit_to, more=more)