<commit_before>from ecnet import Server


def build(validate, shuffle, dset, sort_type):

    sv = Server()
    sv.import_data('cn_model_v1.0.csv', sort_type=sort_type)
    sv.create_project(
        'test_project',
        num_builds=1,
        num_nodes=2,
        num_candidates=2
    )
    sv.train_model(validate=validate, shuffle=shuffle)
    sv.select_best(dset)
    results = sv.use_model(dset)
    sv.save_results(results, 'test_results.csv')
    print(sv.calc_error('r2', 'rmse', 'mean_abs_error', 'med_abs_error'))
    sv.save_project()

if __name__ == '__main__':

    build(True, 'lv', 'test', 'random')
    build(True, 'lvt', 'test', 'random')
    build(False, 'lv', 'test', 'random')
    build(True, None, 'test', 'explicit')
    build(True, 'lv', 'learn', 'random')
    build(True, 'lv', 'valid', 'random')
    build(True, 'lv', 'train', 'random')
    build(True, 'lv', None, 'random')<commit_msg>Added unit test for multiprocessing<commit_after>from ecnet import Server


def build(validate, shuffle, dset, sort_type):

    sv = Server()
    sv.import_data('cn_model_v1.0.csv', sort_type=sort_type)
    sv.create_project(
        'test_project',
        num_builds=1,
        num_nodes=2,
        num_candidates=2
    )
    sv.train_model(validate=validate, shuffle=shuffle)
    sv.select_best(dset)
    results = sv.use_model(dset)
    sv.save_results(results, 'test_results.csv')
    print(sv.calc_error('r2', 'rmse', 'mean_abs_error', 'med_abs_error'))
    sv.save_project()


def build_mp():

    sv = Server(num_processes=4)
    sv.import_data('cn_model_v1.0.csv', sort_type='random')
    sv.create_project(
        'test_project_mp',
        num_builds=1,
        num_nodes=2,
        num_candidates=2
    )
    sv.train_model(validate=True, shuffle='lv')
    sv.select_best('test')
    results = sv.use_model('test')
    sv.save_results(results, 'test_mp_results.csv')
    print(sv.calc_error('r2', 'rmse', 'mean_abs_error', 'med_abs_error'))
    sv.save_project()


if __name__ == '__main__':

    build(True, 'lv', 'test', 'random')
    build(True, 'lvt', 'test', 'random')
    build(False, 'lv', 'test', 'random')
    build(True, None, 'test', 'explicit')
    build(True, 'lv', 'learn', 'random')
    build(True, 'lv', 'valid', 'random')
    build(True, 'lv', 'train', 'random')
    build(True, 'lv', None, 'random')
    build_mp()
{'fraction_non_alphanumeric': 0.16793893129770993, 'fraction_numerical': 0.008057675996607293, 'mean_word_length': 3.7274549098196395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1761739', 'n_tokens_mistral': 885, 'n_tokens_neox': 867, 'n_words': 157}