示例#1
0
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
示例#2
0
def run_more(simfolder):
    """ let the user make more runs on current config,
        in addition to the given data

        :param string simfolder: relative path to simfolder
        :returns: True if successful, False otherwise
    """
    simfolder = simfolder.strip('/')
    conf = utils.get_combined_conf(simfolder)

    print('''
[StoSim] Let's make {} more run(s)! Please tell me on which configurations.\n
Enter any parameter values you want to narrow down to, nothing otherwise."
'''.format(conf.getint('control', 'runs')))
    sel_params = {}
    for o in conf.options('params'):
        selected = False
        params = [p.strip() for p in conf.get('params', o).split(',')]
        if len(params) == 1:
            print("<{}> has only one value:".format(o))
            print(params[0])
            continue
        while not selected:
            choice = []
            print("<{}> ? (out of [{}])".format(o, conf.get('params', o)))
            for selection in input().split(','):
                selected = True
                if selection == "":
                    pass
                elif selection in params:
                    choice.append(selection)
                else:
                    print("Sorry, {} is not a valid value.".format(selection))
                    selected = False
        if len(choice) > 0:
            sel_params[o] = choice
        else:
            print("No restriction chosen.")
    print("You selected: {}. Do this? [Y|n]\n"\
          "(Remember that configuration and code should still be the same!)"\
                .format(str(sel_params)))
    if input().lower() in ["", "y"]:
        prepare_folders_and_jobs(simfolder, limit_to=sel_params, more=True)
        return run(simfolder)
    return False