File size: 2,544 Bytes
ee9e25e
 
 
513e813
 
ee9e25e
 
 
 
 
 
 
 
 
 
 
 
513e813
b58e1f0
513e813
 
 
6251f5a
 
9adae3c
 
 
 
6251f5a
 
 
 
 
 
9adae3c
cc32c4f
 
 
 
 
 
 
 
 
 
83a34f0
c32735e
 
 
 
 
 
 
 
30fa96a
c32735e
30fa96a
 
c32735e
 
ee9e25e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import unittest
from details_data_processor import DetailsDataProcessor
import pandas as pd
import requests
import os

class TestDetailsDataProcessor(unittest.TestCase):

    def setUp(self):
        self.processor = DetailsDataProcessor()

    # check that the result is a pandas dataframe
    def test_process_data(self):
        pass
        # data = self.processor.data
        # self.assertIsInstance(data, pd.DataFrame)

    def test_download_file(self):
        DetailsDataProcessor.download_file('https://www.google.com', 'test_file_please_remove')
        self.assertTrue(os.path.exists('test.html'))
        os.remove('test.html')

    # queries_harness is in the url
    def test_download_file_queries(self):
        file_path_with_error = 'results/shaohang/Sparse0.5_OPT-1.3/results_2023-07-19T19:10:31.005235.json'
        url = self.processor.build_url(file_path_with_error)
        DetailsDataProcessor.download_file(url, 'test_file_please_remove')

    # details harness is in the url
    def test_download_file_details(self):
        file_path = 'results/v2ray/LLaMA-2-Wizard-70B-QLoRA/results_2023-08-18T07:09:43.451689.json'
        url = self.processor.build_url(file_path)
        DetailsDataProcessor.download_file(url, 'test_file_please_remove')


    def test_build_url(self):
        test_cases = [
            ('results/64bits/LexPodLM-13B/results_2023-07-25T13:41:51.227672.json',
            'https://huggingface.co/datasets/open-llm-leaderboard/details/resolve/main/64bits/LexPodLM-13B/details_harness%7ChendrycksTest-moral_scenarios%7C5_2023-07-25T13%3A41%3A51.227672.json'),
            ('results/AlpinDale/pygmalion-instruct/results_2023-08-17T11:20:15.687659.json',
            'https://huggingface.co/datasets/open-llm-leaderboard/details/resolve/main/AlpinDale/pygmalion-instruct/details_harness%7ChendrycksTest-moral_scenarios%7C5_2023-08-17T11%3A20%3A15.687659.json')
        ]
    
        for file_path, expected in test_cases:
            assert self.processor.build_url(file_path) == expected, f"Test failed for file_path: {file_path}"

    def test_pipeline(self):
        df = self.processor.pipeline()
        print(100 * "****")
        print(df)
        self.assertIsInstance(df, pd.DataFrame)

    def test_find_files(self):
        directory = 'results'
        pattern = 'results*.json'
        files = self.processor._find_files(directory, pattern)
        # breakpoint()
        # print(files)
        self.assertIsInstance(files, list)

        
if __name__ == '__main__':
    unittest.main()