Spaces:
Running
Running
Commit
·
996d4ed
1
Parent(s):
8ca4da7
define click event
Browse files- app.py +10 -28
- src/utils.py +16 -0
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import pandas as pd
|
|
| 5 |
from apscheduler.schedulers.background import BackgroundScheduler
|
| 6 |
|
| 7 |
from src.assets.text_content import TITLE, INTRODUCTION_TEXT, SINGLE_A100_TEXT, CITATION_BUTTON_LABEL, CITATION_BUTTON_TEXT
|
| 8 |
-
from src.utils import restart_space, load_dataset_repo, make_clickable_model, make_clickable_score,
|
| 9 |
from src.assets.css_html_js import custom_css
|
| 10 |
|
| 11 |
|
|
@@ -187,7 +187,15 @@ with demo:
|
|
| 187 |
# elem_id="1xA100-plot",
|
| 188 |
# show_label=False,
|
| 189 |
# )
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
with gr.Row():
|
| 192 |
with gr.Accordion("📙 Citation", open=False):
|
| 193 |
citation_button = gr.Textbox(
|
|
@@ -197,32 +205,6 @@ with demo:
|
|
| 197 |
).style(show_copy_button=True)
|
| 198 |
|
| 199 |
|
| 200 |
-
def submit_query(text, backends, datatypes, threshold, raw_df):
|
| 201 |
-
raw_df["H4 Score ⬆️"] = raw_df["H4 Score ⬆️"].apply(
|
| 202 |
-
extract_score_from_clickable)
|
| 203 |
-
|
| 204 |
-
filtered_df = raw_df[
|
| 205 |
-
raw_df["Model 🤗"].str.lower().str.contains(text.lower()) &
|
| 206 |
-
raw_df["Backend 🏭"].isin(backends) &
|
| 207 |
-
raw_df["Datatype 📥"].isin(datatypes) &
|
| 208 |
-
(raw_df["H4 Score ⬆️"] >= threshold)
|
| 209 |
-
]
|
| 210 |
-
|
| 211 |
-
filtered_df["H4 Score ⬆️"] = filtered_df["H4 Score ⬆️"].apply(
|
| 212 |
-
make_clickable_score)
|
| 213 |
-
return filtered_df
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
# Callbacks
|
| 217 |
-
submit_button.click(
|
| 218 |
-
submit_query,
|
| 219 |
-
[
|
| 220 |
-
search_bar, backend_checkboxes, datatype_checkboxes, threshold_slider,
|
| 221 |
-
single_A100_for_search
|
| 222 |
-
],
|
| 223 |
-
[single_A100_leaderboard]
|
| 224 |
-
)
|
| 225 |
-
|
| 226 |
# Restart space every hour
|
| 227 |
scheduler = BackgroundScheduler()
|
| 228 |
scheduler.add_job(restart_space, "interval", seconds=3600,
|
|
|
|
| 5 |
from apscheduler.schedulers.background import BackgroundScheduler
|
| 6 |
|
| 7 |
from src.assets.text_content import TITLE, INTRODUCTION_TEXT, SINGLE_A100_TEXT, CITATION_BUTTON_LABEL, CITATION_BUTTON_TEXT
|
| 8 |
+
from src.utils import restart_space, load_dataset_repo, make_clickable_model, make_clickable_score, submit_query
|
| 9 |
from src.assets.css_html_js import custom_css
|
| 10 |
|
| 11 |
|
|
|
|
| 187 |
# elem_id="1xA100-plot",
|
| 188 |
# show_label=False,
|
| 189 |
# )
|
| 190 |
+
# Callbacks
|
| 191 |
+
submit_button.click(
|
| 192 |
+
submit_query,
|
| 193 |
+
[
|
| 194 |
+
search_bar, backend_checkboxes, datatype_checkboxes, threshold_slider,
|
| 195 |
+
single_A100_for_search
|
| 196 |
+
],
|
| 197 |
+
[single_A100_leaderboard]
|
| 198 |
+
)
|
| 199 |
with gr.Row():
|
| 200 |
with gr.Accordion("📙 Citation", open=False):
|
| 201 |
citation_button = gr.Textbox(
|
|
|
|
| 205 |
).style(show_copy_button=True)
|
| 206 |
|
| 207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
# Restart space every hour
|
| 209 |
scheduler = BackgroundScheduler()
|
| 210 |
scheduler.add_job(restart_space, "interval", seconds=3600,
|
src/utils.py
CHANGED
|
@@ -70,3 +70,19 @@ def make_clickable_score(score):
|
|
| 70 |
|
| 71 |
def extract_score_from_clickable(clickable_score) -> float:
|
| 72 |
return float(re.findall(r"\d+\.\d+", clickable_score)[-1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
def extract_score_from_clickable(clickable_score) -> float:
|
| 72 |
return float(re.findall(r"\d+\.\d+", clickable_score)[-1])
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def submit_query(text, backends, datatypes, threshold, raw_df):
|
| 76 |
+
raw_df["H4 Score ⬆️"] = raw_df["H4 Score ⬆️"].apply(
|
| 77 |
+
extract_score_from_clickable)
|
| 78 |
+
|
| 79 |
+
filtered_df = raw_df[
|
| 80 |
+
raw_df["Model 🤗"].str.lower().str.contains(text.lower()) &
|
| 81 |
+
raw_df["Backend 🏭"].isin(backends) &
|
| 82 |
+
raw_df["Datatype 📥"].isin(datatypes) &
|
| 83 |
+
(raw_df["H4 Score ⬆️"] >= threshold)
|
| 84 |
+
]
|
| 85 |
+
|
| 86 |
+
filtered_df["H4 Score ⬆️"] = filtered_df["H4 Score ⬆️"].apply(
|
| 87 |
+
make_clickable_score)
|
| 88 |
+
return filtered_df
|