예제 #1
0
def check_existing_batch(exp_dict, sim_dict):
    exp_ids_list = exp_dict.keys()
    sim_ids_list = sim_dict.keys()
    batch_list = DataStore.get_batch_list()

    for batch in batch_list:
        batch_exp_ids = batch.get_experiment_ids()
        batch_sim_ids = batch.get_simulation_ids()
        if compare_two_ids_list(exp_ids_list, batch_exp_ids) and compare_two_ids_list(sim_ids_list, batch_sim_ids):
            return batch

    return None
예제 #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.')
예제 #3
0
def list_batch(id_or_name=None):
    """
        List Details of Batches from local database
    """

    batches = DataStore.get_batch_list(id_or_name)

    if batches is None:
        # Batches still none probably didnt exist
        print("No batches idendified by {} could be found in the database...".format(id_or_name))
        exit()

    # Display
    if batches:
        print('---------- Batch(s) in DB -----------')
        if isinstance(batches, list):
            for batch in batches:
                print(batch)
            print('\nTotal: %s Batch(s)' % len(batches))
    else:
        print('There is no Batch records in DB.')
예제 #4
0
def delete_batch(id_or_name=None):
    """
    Delete a particular batch or all batches in DB
    """
    batches = DataStore.get_batch_list(id_or_name)
    if id_or_name:
        print("Batch to delete:")
        for batch in batches: print(batch)
    else:
        print("ALL the batches present in the database ({} batches total) will be deleted...".format(len(batches)))

    choice = input("Are you sure you want to proceed? (Y/n)")

    if choice != 'Y':
        print('No action taken.')
        return
    else:
        if not id_or_name:
            DataStore.delete_batch() # Wipe all
        else:
            for batch in batches:
                DataStore.delete_batch(batch)

        print('The Batch(s) have been deleted.')