Spaces:
Runtime error
Runtime error
Replaced RuntimeError with CheckSignificanceError
Browse files
server.py
CHANGED
@@ -57,6 +57,9 @@ MARKDOWN_SPECIAL_CHARACTERS = {
|
|
57 |
def xmlAndMarkdownEscape(text):
|
58 |
return xmlEscape(text, MARKDOWN_SPECIAL_CHARACTERS)
|
59 |
|
|
|
|
|
|
|
60 |
def check_significance_send_task(model_a_path, model_b_path):
|
61 |
url = 'https://czechllm.fit.vutbr.cz/benczechmark-leaderboard/compare_significance/'
|
62 |
|
@@ -76,9 +79,9 @@ def check_significance_send_task(model_a_path, model_b_path):
|
|
76 |
result_url = response.url
|
77 |
#task_id = response.json()['task_id']
|
78 |
elif response.status_code == 429:
|
79 |
-
raise
|
80 |
else:
|
81 |
-
raise
|
82 |
|
83 |
return result_url
|
84 |
|
@@ -91,12 +94,12 @@ def check_significance_wait_for_result(result_url):
|
|
91 |
elif response.status_code == 202:
|
92 |
time.sleep(5)
|
93 |
else:
|
94 |
-
raise
|
95 |
|
96 |
if result["state"] == "COMPLETED":
|
97 |
return result['result']
|
98 |
else:
|
99 |
-
raise
|
100 |
|
101 |
def check_significance(model_a_path, model_b_path):
|
102 |
result_url = check_significance_send_task(model_a_path, model_b_path)
|
|
|
57 |
def xmlAndMarkdownEscape(text):
|
58 |
return xmlEscape(text, MARKDOWN_SPECIAL_CHARACTERS)
|
59 |
|
60 |
+
class CheckSignificanceError(Exception):
|
61 |
+
pass
|
62 |
+
|
63 |
def check_significance_send_task(model_a_path, model_b_path):
|
64 |
url = 'https://czechllm.fit.vutbr.cz/benczechmark-leaderboard/compare_significance/'
|
65 |
|
|
|
79 |
result_url = response.url
|
80 |
#task_id = response.json()['task_id']
|
81 |
elif response.status_code == 429:
|
82 |
+
raise CheckSignificanceError('Server is too busy. Please try again later.')
|
83 |
else:
|
84 |
+
raise CheckSignificanceError(f'Failed to submit task. Status code: {response.status_code}')
|
85 |
|
86 |
return result_url
|
87 |
|
|
|
94 |
elif response.status_code == 202:
|
95 |
time.sleep(5)
|
96 |
else:
|
97 |
+
raise CheckSignificanceError(f'Failed to get result. Status code: {response.status_code}')
|
98 |
|
99 |
if result["state"] == "COMPLETED":
|
100 |
return result['result']
|
101 |
else:
|
102 |
+
raise CheckSignificanceError(result['result']['error'])
|
103 |
|
104 |
def check_significance(model_a_path, model_b_path):
|
105 |
result_url = check_significance_send_task(model_a_path, model_b_path)
|