# from email_test import *
from cont_modules import *
start = time.perf_counter()
# write cleaned and prepped api report (general collection) to csv with identifier

# csv_wrapper = read_api_to_wrapper()
# write_csv_from_list(construct_ID('api_out', 'ALL'), csv_wrapper)


# loads in test and training data, splits them by collection to feed into algorithm

A = time.perf_counter() - start
print('A: ' + str(A))
training_wrapper = read_csv_to_list_wrapper('./data/training_data/training_ALL_api_out.csv')
B = time.perf_counter() - A
print('B: ' + str(B))

test_wrapper = read_csv_to_list_wrapper('./2020-08-18_ALL_api_out.csv')
# test_wrapper = read_api_to_wrapper()
# too slow for now
C = time.perf_counter() - B
print('C: ' + str(C))
training_collections = split_collection(training_wrapper)
D = time.perf_counter() - C
print('D: ' + str(D))
test_collections = split_collection(test_wrapper)
E = time.perf_counter() - D
print('E: ' + str(E))

# run algorithm on split dataset

# for collection_code in training_collections:
#     run_algorithm(collection_code, test_collections[collection_code], training_collections[collection_code])

#     # sends human readable data to email
#     sendmail('data/predictions/%s' % construct_ID('predictions', collection_code))

collection_code = 'B_PHILPSYR'

run_algorithm(collection_code, test_collections[collection_code], training_collections[collection_code])
F = time.perf_counter() - E
print('F: ' + str(F))
print('*****')
print('total: ' + str(F+E+D+C+B+A))

# sends human readable data to email
# sendmail('data/predictions/%s' % construct_ID('predictions', collection_code))
