예제 #1
0
def consolidate_experiments_with_options(exp_dict, sim_dict, batch_name=None):
    # if batch name exists, always save experiments
    if batch_name is None:
        return exp_dict, sim_dict

    batch = DataStore.get_batch_by_name(batch_name)
    if batch:
        batch_exp_id_list = batch.get_experiment_ids()
        batch_sim_id_list = batch.get_simulation_ids()

        exp_diff = not compare_two_ids_list(exp_dict.keys(), batch_exp_id_list)
        sim_diff = not compare_two_ids_list(sim_dict.keys(), batch_sim_id_list)

        if exp_diff or sim_diff:
            # confirm only if existing batch contains different experiments
            print("\nBatch with name {} already exists and contains the following:\n".format(batch_name))
            print(batch)

            if exp_dict or sim_dict:
                var = input('\nDo you want to [O]verwrite, [M]erge, or [C]ancel:  ')
                # print("You selected '%s'" % var)
                if var == 'O':
                    # clear existing experiments associated with this Batch
                    DataStore.clear_batch(batch)
                    return exp_dict, sim_dict
                elif var == 'M':
                    return exp_dict, sim_dict
                elif var == 'C':
                    exit()
                else:
                    logger.error("Option '%s' is invalid..." % var)
                    exit()

    return exp_dict, sim_dict
예제 #2
0
def clear_batch(id_or_name, ask=False):
    """
    de-attach all associated experiments from the given batch
    """
    batches = DataStore.get_batch_list(id_or_name)

    if not batches:
        print("No batches identified by '%s' were found in the DB." % id_or_name)
        exit()

    if ask:
        for batch in batches:
            print(batch)
        if input("Are you sure you want to detach all associated experiments from those batches (Y/n)? ") != 'Y':
            print('No action taken.')
            return

    DataStore.clear_batch(batches)
    print('The associated experiments/simulations were detached.')