Exemplo n.º 1
0
def save_batches(col: collection.Collection, batches):
    """Saves the batches to the specified collection
    in the database"""
    logging.debug(f'Saving documents to the {col.full_name} collection')
    ids = col.insert_many([{
        '_id':
        i,
        'data':
        pickle.dumps(data, pickle.HIGHEST_PROTOCOL),
        'labels':
        pickle.dumps(labels, pickle.HIGHEST_PROTOCOL)
    } for i, (data, labels) in enumerate(batches)]).inserted_ids
    logging.debug(f'Inserted {len(ids)} documents')