Spaces:
Sleeping
Sleeping
Feat: works and looks fine?
Browse files- app.py +38 -7
- src/retrieve_data.py +0 -1
app.py
CHANGED
@@ -44,27 +44,44 @@ def create_table_for_lb(lb_name, gpu_name):
|
|
44 |
|
45 |
lb_data = leaderboard_data[lb_name][gpu_name]
|
46 |
|
47 |
-
headers = ["Rank", "
|
48 |
|
49 |
rows = []
|
50 |
for i, result in enumerate(lb_data.results, 1):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
rows.append(
|
52 |
[
|
53 |
-
|
54 |
-
result.submission_name,
|
55 |
result.user_id,
|
|
|
56 |
f"{float(result.submission_score):.4f}",
|
57 |
result.submission_time,
|
58 |
]
|
59 |
)
|
60 |
|
61 |
-
|
62 |
headers=headers,
|
63 |
-
datatype=[
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
value=rows,
|
65 |
interactive=False,
|
66 |
)
|
67 |
|
|
|
|
|
68 |
|
69 |
def refresh_ui():
|
70 |
"""Force refresh the UI with latest data"""
|
@@ -101,7 +118,21 @@ def update_table(lb_name, gpu_name):
|
|
101 |
|
102 |
|
103 |
def build_ui():
|
104 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
gr.Markdown("# 🍿 KernelBot Leaderboard 🍿")
|
106 |
|
107 |
asyncio.run(fetch_data())
|
@@ -132,7 +163,7 @@ def build_ui():
|
|
132 |
inputs=[lb_dropdown],
|
133 |
outputs=[gpu_dropdown, results_table],
|
134 |
)
|
135 |
-
|
136 |
gpu_dropdown.change(
|
137 |
fn=update_table, inputs=[lb_dropdown, gpu_dropdown], outputs=results_table
|
138 |
)
|
|
|
44 |
|
45 |
lb_data = leaderboard_data[lb_name][gpu_name]
|
46 |
|
47 |
+
headers = ["Rank", "Discord User ID", "Submission Name", "Score", "Date"]
|
48 |
|
49 |
rows = []
|
50 |
for i, result in enumerate(lb_data.results, 1):
|
51 |
+
# Add medal emoji for top 3 ranks
|
52 |
+
rank_display = i
|
53 |
+
if i == 1:
|
54 |
+
rank_display = "🥇 1"
|
55 |
+
elif i == 2:
|
56 |
+
rank_display = "🥈 2"
|
57 |
+
elif i == 3:
|
58 |
+
rank_display = "🥉 3"
|
59 |
+
|
60 |
rows.append(
|
61 |
[
|
62 |
+
rank_display,
|
|
|
63 |
result.user_id,
|
64 |
+
result.submission_name,
|
65 |
f"{float(result.submission_score):.4f}",
|
66 |
result.submission_time,
|
67 |
]
|
68 |
)
|
69 |
|
70 |
+
df = gr.Dataframe(
|
71 |
headers=headers,
|
72 |
+
datatype=[
|
73 |
+
"str",
|
74 |
+
"int",
|
75 |
+
"str",
|
76 |
+
"str",
|
77 |
+
"datetime",
|
78 |
+
], # Changed first column to str for medals
|
79 |
value=rows,
|
80 |
interactive=False,
|
81 |
)
|
82 |
|
83 |
+
return df
|
84 |
+
|
85 |
|
86 |
def refresh_ui():
|
87 |
"""Force refresh the UI with latest data"""
|
|
|
118 |
|
119 |
|
120 |
def build_ui():
|
121 |
+
with gr.Blocks(
|
122 |
+
title="ML Leaderboards",
|
123 |
+
theme=gr.themes.Soft(),
|
124 |
+
css="""
|
125 |
+
.gradio-container table tr:nth-child(1) {
|
126 |
+
background-color: rgba(255, 215, 0, 0.2) !important; /* Gold */
|
127 |
+
}
|
128 |
+
.gradio-container table tr:nth-child(2) {
|
129 |
+
background-color: rgba(192, 192, 192, 0.2) !important; /* Silver */
|
130 |
+
}
|
131 |
+
.gradio-container table tr:nth-child(3) {
|
132 |
+
background-color: rgba(205, 127, 50, 0.2) !important; /* Bronze */
|
133 |
+
}
|
134 |
+
""",
|
135 |
+
) as app:
|
136 |
gr.Markdown("# 🍿 KernelBot Leaderboard 🍿")
|
137 |
|
138 |
asyncio.run(fetch_data())
|
|
|
163 |
inputs=[lb_dropdown],
|
164 |
outputs=[gpu_dropdown, results_table],
|
165 |
)
|
166 |
+
|
167 |
gpu_dropdown.change(
|
168 |
fn=update_table, inputs=[lb_dropdown, gpu_dropdown], outputs=results_table
|
169 |
)
|
src/retrieve_data.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import asyncio
|
2 |
from collections import defaultdict
|
3 |
|
4 |
from httpx import AsyncClient
|
|
|
|
|
1 |
from collections import defaultdict
|
2 |
|
3 |
from httpx import AsyncClient
|