pminervini commited on
Commit
1739293
1 Parent(s): 9cbf014
Files changed (1) hide show
  1. 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
- result_name: str = request_to_result_name(eval_request)
 
122
 
123
- # Check the corresponding result
124
- from typing import Optional
125
- eval_result: Optional[EvalResult] = result_name_to_result[result_name] if result_name in result_name_to_result else None
126
 
127
- task_lst = TASKS_HARNESS.copy()
128
- random.shuffle(task_lst)
129
 
130
- # Iterate over tasks and, if we do not have results for a task, run the relevant evaluations
131
- for task in task_lst:
132
- task_name = task.benchmark
133
 
134
- if eval_result is None or task_name not in eval_result.results:
135
- eval_request: EvalRequest = result_name_to_request[result_name]
136
 
137
- my_snapshot_download(repo_id=QUEUE_REPO, revision="main", local_dir=EVAL_REQUESTS_PATH_BACKEND, repo_type="dataset", max_workers=60)
138
- set_eval_request(api=API, eval_request=eval_request, set_to_status=RUNNING_STATUS, hf_repo=QUEUE_REPO,
139
- local_dir=EVAL_REQUESTS_PATH_BACKEND)
140
 
141
- results = process_evaluation(task, eval_request)
142
 
143
- my_snapshot_download(repo_id=QUEUE_REPO, revision="main", local_dir=EVAL_REQUESTS_PATH_BACKEND, repo_type="dataset", max_workers=60)
144
- set_eval_request(api=API, eval_request=eval_request, set_to_status=FINISHED_STATUS, hf_repo=QUEUE_REPO,
145
- local_dir=EVAL_REQUESTS_PATH_BACKEND)
146
 
147
- return True
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(3, 10))
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)