Hao Xu
commited on
Commit
·
2c95c7e
1
Parent(s):
feaf833
community result load fix
Browse files
app.py
CHANGED
@@ -14,20 +14,23 @@ api = HfApi()
|
|
14 |
URL = os.environ.get("URL")
|
15 |
|
16 |
|
17 |
-
def load_data(source):
|
18 |
if source == "core":
|
19 |
with open("data.json", "r") as f:
|
20 |
data = json.load(f)
|
21 |
else:
|
22 |
-
|
|
|
|
|
|
|
23 |
data = []
|
24 |
for entry in ds:
|
25 |
data.append(entry)
|
26 |
return data
|
27 |
|
28 |
|
29 |
-
def build_table(source):
|
30 |
-
data = load_data(source)
|
31 |
entries = []
|
32 |
|
33 |
if source == "core":
|
@@ -46,7 +49,10 @@ def build_table(source):
|
|
46 |
for entry in data:
|
47 |
name = entry.get("Benchmark", "")
|
48 |
url = entry.get("URL", "#")
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
row = {
|
52 |
"Benchmark": hyperlink,
|
@@ -228,13 +234,13 @@ with gr.Blocks() as interface:
|
|
228 |
value="core"
|
229 |
)
|
230 |
|
231 |
-
leaderboard_html = gr.HTML(build_table("core"))
|
232 |
|
233 |
def update_table(source):
|
234 |
-
return build_table(source)
|
235 |
|
236 |
source_radio.change(
|
237 |
-
fn=
|
238 |
inputs=source_radio,
|
239 |
outputs=leaderboard_html
|
240 |
)
|
@@ -256,7 +262,7 @@ with gr.Blocks() as interface:
|
|
256 |
with gr.Row():
|
257 |
jsonl_input = gr.File(label="Upload .jsonl File", file_types=[".jsonl"])
|
258 |
with gr.Column():
|
259 |
-
hf_path_input = gr.Textbox(label="HuggingFace Dataset Path")
|
260 |
hf_split_input = gr.Textbox(label="Dataset split (only if providing HuggingFace Dataset)", placeholder="e.g., validation, test")
|
261 |
field_name_input = gr.Textbox(label="Context or Question Field Name", placeholder="e.g., context, question, ...")
|
262 |
|
|
|
14 |
URL = os.environ.get("URL")
|
15 |
|
16 |
|
17 |
+
def load_data(source, refresh=False):
|
18 |
if source == "core":
|
19 |
with open("data.json", "r") as f:
|
20 |
data = json.load(f)
|
21 |
else:
|
22 |
+
if refresh:
|
23 |
+
ds = load_dataset(RESULTS_COMMUNITY, split='train', download_mode="force_redownload")
|
24 |
+
else:
|
25 |
+
ds = load_dataset(RESULTS_COMMUNITY, split='train')
|
26 |
data = []
|
27 |
for entry in ds:
|
28 |
data.append(entry)
|
29 |
return data
|
30 |
|
31 |
|
32 |
+
def build_table(source, refresh=False):
|
33 |
+
data = load_data(source, refresh)
|
34 |
entries = []
|
35 |
|
36 |
if source == "core":
|
|
|
49 |
for entry in data:
|
50 |
name = entry.get("Benchmark", "")
|
51 |
url = entry.get("URL", "#")
|
52 |
+
if url:
|
53 |
+
hyperlink = f'<a href="{url}" target="_blank">{name}</a>'
|
54 |
+
else:
|
55 |
+
hyperlink = name
|
56 |
|
57 |
row = {
|
58 |
"Benchmark": hyperlink,
|
|
|
234 |
value="core"
|
235 |
)
|
236 |
|
237 |
+
leaderboard_html = gr.HTML(build_table("core", refresh=False))
|
238 |
|
239 |
def update_table(source):
|
240 |
+
return build_table(source, refresh=True)
|
241 |
|
242 |
source_radio.change(
|
243 |
+
fn=build_table,
|
244 |
inputs=source_radio,
|
245 |
outputs=leaderboard_html
|
246 |
)
|
|
|
262 |
with gr.Row():
|
263 |
jsonl_input = gr.File(label="Upload .jsonl File", file_types=[".jsonl"])
|
264 |
with gr.Column():
|
265 |
+
hf_path_input = gr.Textbox(label="HuggingFace Dataset Path", placeholder="e.g., author/benchmark-name")
|
266 |
hf_split_input = gr.Textbox(label="Dataset split (only if providing HuggingFace Dataset)", placeholder="e.g., validation, test")
|
267 |
field_name_input = gr.Textbox(label="Context or Question Field Name", placeholder="e.g., context, question, ...")
|
268 |
|