Spaces:
Sleeping
Sleeping
Removing -- is in place in https://huggingface.co/spaces/Bias-Leaderboard/leaderboard-backend
Browse files- main_backend.py +0 -84
main_backend.py
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
import logging
|
2 |
-
import pprint
|
3 |
-
|
4 |
-
from huggingface_hub import snapshot_download
|
5 |
-
from datasets import load_dataset
|
6 |
-
|
7 |
-
logging.getLogger("openai").setLevel(logging.WARNING)
|
8 |
-
|
9 |
-
from src.backend.run_eval_suite import run_evaluation
|
10 |
-
from src.backend.manage_requests import check_completed_evals, get_eval_requests, set_eval_request
|
11 |
-
from src.backend.sort_queue import sort_models_by_priority
|
12 |
-
|
13 |
-
from src.envs import TOKEN, QUEUE_REPO, EVAL_REQUESTS_PATH_BACKEND, RESULTS_REPO, EVAL_RESULTS_PATH_BACKEND, DEVICE, API, LIMIT
|
14 |
-
from src.about import Tasks, NUM_FEWSHOT
|
15 |
-
TASKS_HARNESS = [task.value.benchmark for task in Tasks]
|
16 |
-
|
17 |
-
logging.basicConfig(level=logging.ERROR)
|
18 |
-
pp = pprint.PrettyPrinter(width=80)
|
19 |
-
|
20 |
-
PENDING_STATUS = "PENDING"
|
21 |
-
RUNNING_STATUS = "RUNNING"
|
22 |
-
FINISHED_STATUS = "FINISHED"
|
23 |
-
FAILED_STATUS = "FAILED"
|
24 |
-
|
25 |
-
print("JUST trying toxigen access...")
|
26 |
-
load_dataset("skg/toxigen-data", token=TOKEN)
|
27 |
-
print("Done.")
|
28 |
-
|
29 |
-
print("Downloading snapshot from %s to %s" % (RESULTS_REPO, EVAL_RESULTS_PATH_BACKEND))
|
30 |
-
snapshot_download(repo_id=RESULTS_REPO, revision="main", local_dir=EVAL_RESULTS_PATH_BACKEND, repo_type="dataset", token=TOKEN, max_workers=60)
|
31 |
-
snapshot_download(repo_id=QUEUE_REPO, revision="main", local_dir=EVAL_REQUESTS_PATH_BACKEND, repo_type="dataset", token=TOKEN, max_workers=60)
|
32 |
-
|
33 |
-
def run_auto_eval():
|
34 |
-
current_pending_status = [PENDING_STATUS]
|
35 |
-
|
36 |
-
# pull the eval dataset from the hub and parse any eval requests
|
37 |
-
# check completed evals and set them to finished
|
38 |
-
check_completed_evals(
|
39 |
-
api=API,
|
40 |
-
checked_status=RUNNING_STATUS,
|
41 |
-
completed_status=FINISHED_STATUS,
|
42 |
-
failed_status=FAILED_STATUS,
|
43 |
-
hf_repo=QUEUE_REPO,
|
44 |
-
local_dir=EVAL_REQUESTS_PATH_BACKEND,
|
45 |
-
hf_repo_results=RESULTS_REPO,
|
46 |
-
local_dir_results=EVAL_RESULTS_PATH_BACKEND
|
47 |
-
)
|
48 |
-
|
49 |
-
# Get all eval request that are PENDING, if you want to run other evals, change this parameter
|
50 |
-
eval_requests = get_eval_requests(job_status=current_pending_status, hf_repo=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH_BACKEND)
|
51 |
-
# Sort the evals by priority (first submitted first run)
|
52 |
-
eval_requests = sort_models_by_priority(api=API, models=eval_requests)
|
53 |
-
|
54 |
-
print(f"Found {len(eval_requests)} {','.join(current_pending_status)} eval requests")
|
55 |
-
|
56 |
-
if len(eval_requests) == 0:
|
57 |
-
return
|
58 |
-
|
59 |
-
eval_request = eval_requests[0]
|
60 |
-
pp.pprint(eval_request)
|
61 |
-
|
62 |
-
set_eval_request(
|
63 |
-
api=API,
|
64 |
-
eval_request=eval_request,
|
65 |
-
set_to_status=RUNNING_STATUS,
|
66 |
-
hf_repo=QUEUE_REPO,
|
67 |
-
local_dir=EVAL_REQUESTS_PATH_BACKEND,
|
68 |
-
)
|
69 |
-
|
70 |
-
run_evaluation(
|
71 |
-
eval_request=eval_request,
|
72 |
-
task_names=TASKS_HARNESS,
|
73 |
-
num_fewshot=NUM_FEWSHOT,
|
74 |
-
local_dir=EVAL_RESULTS_PATH_BACKEND,
|
75 |
-
results_repo=RESULTS_REPO,
|
76 |
-
batch_size=1,
|
77 |
-
device=DEVICE,
|
78 |
-
no_cache=True,
|
79 |
-
limit=LIMIT
|
80 |
-
)
|
81 |
-
|
82 |
-
|
83 |
-
if __name__ == "__main__":
|
84 |
-
run_auto_eval()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|