Spaces:
Runtime error
Runtime error
Speed up Space loading
Browse files
app.py
CHANGED
@@ -4,16 +4,15 @@ from pathlib import Path
|
|
4 |
|
5 |
import numpy as np
|
6 |
import pandas as pd
|
7 |
-
import requests
|
8 |
import streamlit as st
|
9 |
from datasets import get_dataset_config_names
|
10 |
from dotenv import load_dotenv
|
|
|
11 |
|
12 |
if Path(".env").is_file():
|
13 |
load_dotenv(".env")
|
14 |
|
15 |
auth_token = os.getenv("HF_HUB_TOKEN")
|
16 |
-
header = {"Authorization": "Bearer " + auth_token}
|
17 |
|
18 |
TASKS = sorted(get_dataset_config_names("ought/raft"))
|
19 |
# Split and capitalize the task names, e.g. banking_77 => Banking 77
|
@@ -22,37 +21,36 @@ FORMATTED_TASK_NAMES = sorted([" ".join(t.capitalize() for t in task.split("_"))
|
|
22 |
|
23 |
def extract_tags(dataset):
|
24 |
tags = {}
|
25 |
-
for tag in dataset
|
26 |
k, v = tuple(tag.split(":", 1))
|
27 |
tags[k] = v
|
28 |
return tags
|
29 |
|
30 |
|
31 |
def download_submissions():
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
submissions = []
|
36 |
|
37 |
-
for dataset in
|
38 |
tags = extract_tags(dataset)
|
39 |
-
if tags.get("
|
40 |
submissions.append(dataset)
|
41 |
return submissions
|
42 |
|
43 |
|
44 |
def format_submissions(submissions):
|
45 |
-
submission_data = {
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
# The following picks the latest submissions which adhere to the model card schema
|
48 |
for submission in submissions:
|
49 |
-
submission_id = submission
|
50 |
-
|
51 |
-
f"http://huggingface.co/api/datasets/{submission_id}?full=true",
|
52 |
-
headers=header,
|
53 |
-
)
|
54 |
-
data = response.json()
|
55 |
-
card_data = data["cardData"]
|
56 |
username = card_data["submission_dataset"].split("/")[0]
|
57 |
submission_data["Submitter"].append(username)
|
58 |
submission_id = card_data["submission_id"]
|
|
|
4 |
|
5 |
import numpy as np
|
6 |
import pandas as pd
|
|
|
7 |
import streamlit as st
|
8 |
from datasets import get_dataset_config_names
|
9 |
from dotenv import load_dotenv
|
10 |
+
from huggingface_hub import DatasetFilter, list_datasets
|
11 |
|
12 |
if Path(".env").is_file():
|
13 |
load_dotenv(".env")
|
14 |
|
15 |
auth_token = os.getenv("HF_HUB_TOKEN")
|
|
|
16 |
|
17 |
TASKS = sorted(get_dataset_config_names("ought/raft"))
|
18 |
# Split and capitalize the task names, e.g. banking_77 => Banking 77
|
|
|
21 |
|
22 |
def extract_tags(dataset):
|
23 |
tags = {}
|
24 |
+
for tag in dataset.tags:
|
25 |
k, v = tuple(tag.split(":", 1))
|
26 |
tags[k] = v
|
27 |
return tags
|
28 |
|
29 |
|
30 |
def download_submissions():
|
31 |
+
filt = DatasetFilter(benchmark="raft")
|
32 |
+
all_submissions = list_datasets(filter=filt, cardData=True, use_auth_token=auth_token)
|
|
|
33 |
submissions = []
|
34 |
|
35 |
+
for dataset in all_submissions:
|
36 |
tags = extract_tags(dataset)
|
37 |
+
if tags.get("type") == "evaluation":
|
38 |
submissions.append(dataset)
|
39 |
return submissions
|
40 |
|
41 |
|
42 |
def format_submissions(submissions):
|
43 |
+
submission_data = {
|
44 |
+
**{"Submitter": []},
|
45 |
+
**{"Submission Name": []},
|
46 |
+
**{"Submission Date": []},
|
47 |
+
**{t: [] for t in TASKS},
|
48 |
+
}
|
49 |
|
50 |
# The following picks the latest submissions which adhere to the model card schema
|
51 |
for submission in submissions:
|
52 |
+
submission_id = submission.id
|
53 |
+
card_data = submission.cardData
|
|
|
|
|
|
|
|
|
|
|
54 |
username = card_data["submission_dataset"].split("/")[0]
|
55 |
submission_data["Submitter"].append(username)
|
56 |
submission_id = card_data["submission_id"]
|