Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Change the model search behavior
Browse files
app.py
CHANGED
@@ -141,27 +141,16 @@ def filter_models(
|
|
141 |
return filtered_df
|
142 |
|
143 |
|
144 |
-
def
|
145 |
-
return df[df[AutoEvalColumn.dummy.name].str.contains(
|
146 |
-
|
147 |
-
|
148 |
-
def
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
queries = [q.strip() for q in query.split(";")]
|
155 |
-
for _q in queries:
|
156 |
-
_q = _q.strip()
|
157 |
-
if _q != "":
|
158 |
-
temp_filtered_df = search_table(filtered_df, _q)
|
159 |
-
if len(temp_filtered_df) > 0:
|
160 |
-
final_df.append(temp_filtered_df)
|
161 |
-
if len(final_df) > 0:
|
162 |
-
filtered_df = pd.concat(final_df)
|
163 |
-
filtered_df = filtered_df.drop_duplicates(subset=AutoEvalColumn.row_id.name)
|
164 |
-
return filtered_df
|
165 |
|
166 |
|
167 |
def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
@@ -217,8 +206,8 @@ def update_table(
|
|
217 |
)
|
218 |
print(f"filtered_df shape after filter_models: {filtered_df.shape}")
|
219 |
|
220 |
-
filtered_df =
|
221 |
-
print(f"filtered_df shape after
|
222 |
|
223 |
print(
|
224 |
f"Filter applied: query={query}, columns={columns}, type_query={type_query}, precision_query={precision_query}"
|
|
|
141 |
return filtered_df
|
142 |
|
143 |
|
144 |
+
def search_model_by_name(df: pd.DataFrame, model_name: str) -> pd.DataFrame:
|
145 |
+
return df[df[AutoEvalColumn.dummy.name].str.contains(model_name, case=False)]
|
146 |
+
|
147 |
+
|
148 |
+
def search_models_by_multiple_names(df: pd.DataFrame, search_text: str) -> pd.DataFrame:
|
149 |
+
if not search_text:
|
150 |
+
return df
|
151 |
+
model_names = [name.strip() for name in search_text.split(";")]
|
152 |
+
dfs = [search_model_by_name(df, name) for name in model_names if name]
|
153 |
+
return pd.concat(dfs).drop_duplicates(subset=AutoEvalColumn.row_id.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
|
156 |
def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
|
|
206 |
)
|
207 |
print(f"filtered_df shape after filter_models: {filtered_df.shape}")
|
208 |
|
209 |
+
filtered_df = search_models_by_multiple_names(filtered_df, query)
|
210 |
+
print(f"filtered_df shape after search_models_by_multiple_names: {filtered_df.shape}")
|
211 |
|
212 |
print(
|
213 |
f"Filter applied: query={query}, columns={columns}, type_query={type_query}, precision_query={precision_query}"
|