Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
•
1739293
1
Parent(s):
9cbf014
update
Browse files- backend-cli.py +26 -22
backend-cli.py
CHANGED
@@ -96,7 +96,7 @@ def process_evaluation(task: Task, eval_request: EvalRequest) -> dict:
|
|
96 |
return results
|
97 |
|
98 |
|
99 |
-
def process_finished_requests() -> bool:
|
100 |
sanity_checks()
|
101 |
|
102 |
current_finished_status = [FINISHED_STATUS, FAILED_STATUS]
|
@@ -118,33 +118,34 @@ def process_finished_requests() -> bool:
|
|
118 |
result_name_to_result = {r.eval_name: r for r in eval_results}
|
119 |
|
120 |
for eval_request in eval_requests:
|
121 |
-
|
|
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
|
127 |
-
|
128 |
-
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
|
134 |
-
|
135 |
-
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
|
141 |
-
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
|
147 |
-
|
148 |
|
149 |
return False
|
150 |
|
@@ -190,10 +191,13 @@ if __name__ == "__main__":
|
|
190 |
import socket
|
191 |
if socket.gethostname() not in {'hamburg'}:
|
192 |
import time
|
193 |
-
time.sleep(60 * random.randint(
|
194 |
|
195 |
# res = False
|
196 |
res = process_pending_requests()
|
197 |
|
198 |
if res is False:
|
199 |
-
res = process_finished_requests()
|
|
|
|
|
|
|
|
96 |
return results
|
97 |
|
98 |
|
99 |
+
def process_finished_requests(thr: int) -> bool:
|
100 |
sanity_checks()
|
101 |
|
102 |
current_finished_status = [FINISHED_STATUS, FAILED_STATUS]
|
|
|
118 |
result_name_to_result = {r.eval_name: r for r in eval_results}
|
119 |
|
120 |
for eval_request in eval_requests:
|
121 |
+
if eval_request.likes >= thr:
|
122 |
+
result_name: str = request_to_result_name(eval_request)
|
123 |
|
124 |
+
# Check the corresponding result
|
125 |
+
from typing import Optional
|
126 |
+
eval_result: Optional[EvalResult] = result_name_to_result[result_name] if result_name in result_name_to_result else None
|
127 |
|
128 |
+
task_lst = TASKS_HARNESS.copy()
|
129 |
+
random.shuffle(task_lst)
|
130 |
|
131 |
+
# Iterate over tasks and, if we do not have results for a task, run the relevant evaluations
|
132 |
+
for task in task_lst:
|
133 |
+
task_name = task.benchmark
|
134 |
|
135 |
+
if eval_result is None or task_name not in eval_result.results:
|
136 |
+
eval_request: EvalRequest = result_name_to_request[result_name]
|
137 |
|
138 |
+
my_snapshot_download(repo_id=QUEUE_REPO, revision="main", local_dir=EVAL_REQUESTS_PATH_BACKEND, repo_type="dataset", max_workers=60)
|
139 |
+
set_eval_request(api=API, eval_request=eval_request, set_to_status=RUNNING_STATUS, hf_repo=QUEUE_REPO,
|
140 |
+
local_dir=EVAL_REQUESTS_PATH_BACKEND)
|
141 |
|
142 |
+
results = process_evaluation(task, eval_request)
|
143 |
|
144 |
+
my_snapshot_download(repo_id=QUEUE_REPO, revision="main", local_dir=EVAL_REQUESTS_PATH_BACKEND, repo_type="dataset", max_workers=60)
|
145 |
+
set_eval_request(api=API, eval_request=eval_request, set_to_status=FINISHED_STATUS, hf_repo=QUEUE_REPO,
|
146 |
+
local_dir=EVAL_REQUESTS_PATH_BACKEND)
|
147 |
|
148 |
+
return True
|
149 |
|
150 |
return False
|
151 |
|
|
|
191 |
import socket
|
192 |
if socket.gethostname() not in {'hamburg'}:
|
193 |
import time
|
194 |
+
time.sleep(60 * random.randint(2, 5))
|
195 |
|
196 |
# res = False
|
197 |
res = process_pending_requests()
|
198 |
|
199 |
if res is False:
|
200 |
+
res = process_finished_requests(100)
|
201 |
+
|
202 |
+
if res is False:
|
203 |
+
res = process_finished_requests(0)
|