|
import subprocess |
|
import time |
|
import requests |
|
import unittest |
|
from app import find_top_differences_table |
|
from result_data_processor import ResultDataProcessor |
|
|
|
class TestAppFunctions(unittest.TestCase): |
|
|
|
def setUp(self): |
|
|
|
self.processor = ResultDataProcessor() |
|
self.data = self.processor.data |
|
|
|
def test_find_top_differences_table_error(self): |
|
|
|
filtered_data = self.data |
|
|
|
|
|
selected_model_name = 'Platypus2-70B-instruct' |
|
exclude_columns=['Parameters','organization'] |
|
closest_models_diffs = filtered_data['MMLU_average'].sub(filtered_data.loc[selected_model_name, 'MMLU_average']).abs() |
|
closest_models = closest_models_diffs.nsmallest(5, keep='first').index.drop_duplicates().tolist() |
|
|
|
|
|
|
|
|
|
|
|
top_differences_table, top_differences_tasks = find_top_differences_table( |
|
self.data, selected_model_name, closest_models, exclude_columns |
|
) |
|
|
|
def test_streamlit_app_runs(self): |
|
|
|
process = subprocess.Popen(["streamlit", "run", "app.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
|
|
|
|
time.sleep(5) |
|
|
|
|
|
response = requests.get('http://localhost:8501') |
|
|
|
|
|
process.terminate() |
|
|
|
|
|
assert response.status_code == 200, "Streamlit app did not start successfully" |
|
|
|
if __name__ == '__main__': |
|
unittest.main() |
|
|