Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Alina Lozovskaya
commited on
Commit
•
6456497
1
Parent(s):
2785a0b
Refactored app.py
Browse files- app.py +25 -23
- pyproject.toml +1 -1
app.py
CHANGED
@@ -48,7 +48,7 @@ from src.tools.collections import update_collections
|
|
48 |
from src.tools.plots import create_metric_plot_obj, create_plot_df, create_scores_df
|
49 |
|
50 |
# Start ephemeral Spaces on PRs (see config in README.md)
|
51 |
-
|
52 |
|
53 |
|
54 |
def restart_space():
|
@@ -115,10 +115,14 @@ def init_space(full_init: bool = True):
|
|
115 |
return leaderboard_df, original_df, plot_df, finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df
|
116 |
|
117 |
|
118 |
-
|
|
|
|
|
119 |
|
|
|
|
|
120 |
leaderboard_df, original_df, plot_df, finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = (
|
121 |
-
init_space(full_init=
|
122 |
)
|
123 |
|
124 |
|
@@ -152,7 +156,7 @@ def load_query(request: gr.Request): # triggered only once at startup => read q
|
|
152 |
) # return one for the "search_bar", one for a hidden component that triggers a reload only if value has changed
|
153 |
|
154 |
|
155 |
-
def
|
156 |
return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False, na=False))]
|
157 |
|
158 |
|
@@ -171,27 +175,26 @@ def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
|
171 |
|
172 |
|
173 |
def filter_queries(query: str, df: pd.DataFrame):
|
174 |
-
"""Added by Abishek + Updated by alozowski"""
|
175 |
tmp_result_df = []
|
176 |
|
177 |
# Empty query return the same df
|
178 |
if query == "":
|
179 |
return df
|
180 |
|
181 |
-
all_queries = [q.strip() for q in query.split(";")]
|
182 |
-
license_queries = []
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
# Handling model name search
|
185 |
-
for
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
continue
|
190 |
-
|
191 |
-
if _q != "":
|
192 |
-
tmp_df = search_table(df, _q)
|
193 |
-
if len(tmp_df) > 0:
|
194 |
-
tmp_result_df.append(tmp_df)
|
195 |
|
196 |
if not tmp_result_df and not license_queries:
|
197 |
# Nothing is found, no license_queries -> return empty df
|
@@ -206,13 +209,12 @@ def filter_queries(query: str, df: pd.DataFrame):
|
|
206 |
if not license_queries:
|
207 |
return df
|
208 |
|
|
|
209 |
tmp_result_df = []
|
210 |
-
for
|
211 |
-
|
212 |
-
if
|
213 |
-
tmp_df
|
214 |
-
if len(tmp_df) > 0:
|
215 |
-
tmp_result_df.append(tmp_df)
|
216 |
|
217 |
if not tmp_result_df:
|
218 |
# Nothing is found, return empty df
|
|
|
48 |
from src.tools.plots import create_metric_plot_obj, create_plot_df, create_scores_df
|
49 |
|
50 |
# Start ephemeral Spaces on PRs (see config in README.md)
|
51 |
+
enable_space_ci()
|
52 |
|
53 |
|
54 |
def restart_space():
|
|
|
115 |
return leaderboard_df, original_df, plot_df, finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df
|
116 |
|
117 |
|
118 |
+
# Convert the environment variable "LEADERBOARD_FULL_INIT" to a boolean value, defaulting to True if the variable is not set.
|
119 |
+
# This controls whether a full initialization should be performed.
|
120 |
+
do_full_init = os.getenv("LEADERBOARD_FULL_INIT", "True") == "True"
|
121 |
|
122 |
+
# Calls the init_space function with the `full_init` parameter determined by the `do_full_init` variable.
|
123 |
+
# This initializes various DataFrames used throughout the application, with the level of initialization detail controlled by the `do_full_init` flag.
|
124 |
leaderboard_df, original_df, plot_df, finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = (
|
125 |
+
init_space(full_init=do_full_init)
|
126 |
)
|
127 |
|
128 |
|
|
|
156 |
) # return one for the "search_bar", one for a hidden component that triggers a reload only if value has changed
|
157 |
|
158 |
|
159 |
+
def search_model(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
160 |
return df[(df[AutoEvalColumn.dummy.name].str.contains(query, case=False, na=False))]
|
161 |
|
162 |
|
|
|
175 |
|
176 |
|
177 |
def filter_queries(query: str, df: pd.DataFrame):
|
|
|
178 |
tmp_result_df = []
|
179 |
|
180 |
# Empty query return the same df
|
181 |
if query == "":
|
182 |
return df
|
183 |
|
184 |
+
# all_queries = [q.strip() for q in query.split(";")]
|
185 |
+
# license_queries = []
|
186 |
+
all_queries = [q.strip() for q in query.split(";") if q.strip() != ""]
|
187 |
+
model_queries = [q for q in all_queries if not q.startswith("licence")]
|
188 |
+
license_queries_raw = [q for q in all_queries if q.startswith("license")]
|
189 |
+
license_queries = [
|
190 |
+
q.replace("license:", "").strip() for q in license_queries_raw if q.replace("license:", "").strip() != ""
|
191 |
+
]
|
192 |
|
193 |
# Handling model name search
|
194 |
+
for query in model_queries:
|
195 |
+
tmp_df = search_model(df, query)
|
196 |
+
if len(tmp_df) > 0:
|
197 |
+
tmp_result_df.append(tmp_df)
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
if not tmp_result_df and not license_queries:
|
200 |
# Nothing is found, no license_queries -> return empty df
|
|
|
209 |
if not license_queries:
|
210 |
return df
|
211 |
|
212 |
+
# Handling license search
|
213 |
tmp_result_df = []
|
214 |
+
for query in license_queries:
|
215 |
+
tmp_df = search_license(df, query)
|
216 |
+
if len(tmp_df) > 0:
|
217 |
+
tmp_result_df.append(tmp_df)
|
|
|
|
|
218 |
|
219 |
if not tmp_result_df:
|
220 |
# Nothing is found, return empty df
|
pyproject.toml
CHANGED
@@ -16,7 +16,7 @@ line-length = 119
|
|
16 |
name = "open-llm-leaderboard"
|
17 |
version = "0.1.0"
|
18 |
description = ""
|
19 |
-
authors = [
|
20 |
readme = "README.md"
|
21 |
|
22 |
[tool.poetry.dependencies]
|
|
|
16 |
name = "open-llm-leaderboard"
|
17 |
version = "0.1.0"
|
18 |
description = ""
|
19 |
+
authors = []
|
20 |
readme = "README.md"
|
21 |
|
22 |
[tool.poetry.dependencies]
|