Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
fix: fix the bug in duplicated columns
Browse files- src/display/utils.py +2 -2
- src/utils.py +11 -4
- tests/src/display/test_utils.py +7 -1
- tests/test_utils.py +2 -1
src/display/utils.py
CHANGED
|
@@ -52,10 +52,10 @@ def get_default_auto_eval_column_dict():
|
|
| 52 |
["average", ColumnContent, ColumnContent(COL_NAME_AVG, "number", True)]
|
| 53 |
)
|
| 54 |
auto_eval_column_dict.append(
|
| 55 |
-
["retrieval_model_link", ColumnContent, ColumnContent(
|
| 56 |
)
|
| 57 |
auto_eval_column_dict.append(
|
| 58 |
-
["reranking_model_link", ColumnContent, ColumnContent(
|
| 59 |
)
|
| 60 |
auto_eval_column_dict.append(
|
| 61 |
["is_anonymous", ColumnContent, ColumnContent(COL_NAME_IS_ANONYMOUS, "bool", False, hidden=True)]
|
|
|
|
| 52 |
["average", ColumnContent, ColumnContent(COL_NAME_AVG, "number", True)]
|
| 53 |
)
|
| 54 |
auto_eval_column_dict.append(
|
| 55 |
+
["retrieval_model_link", ColumnContent, ColumnContent(COL_NAME_RETRIEVAL_MODEL_LINK, "markdown", False, hidden=True, never_hidden=False)]
|
| 56 |
)
|
| 57 |
auto_eval_column_dict.append(
|
| 58 |
+
["reranking_model_link", ColumnContent, ColumnContent(COL_NAME_RERANKING_MODEL_LINK, "markdown", False, hidden=True, never_hidden=False)]
|
| 59 |
)
|
| 60 |
auto_eval_column_dict.append(
|
| 61 |
["is_anonymous", ColumnContent, ColumnContent(COL_NAME_IS_ANONYMOUS, "bool", False, hidden=True)]
|
src/utils.py
CHANGED
|
@@ -43,7 +43,7 @@ def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
|
| 43 |
return df[(df[COL_NAME_RETRIEVAL_MODEL].str.contains(query, case=False))]
|
| 44 |
|
| 45 |
|
| 46 |
-
def get_default_cols(task: str, columns: list
|
| 47 |
cols = []
|
| 48 |
types = []
|
| 49 |
if task == "qa":
|
|
@@ -65,12 +65,19 @@ def get_default_cols(task: str, columns: list = [], add_fix_cols: bool = True) -
|
|
| 65 |
types.append(col_type)
|
| 66 |
|
| 67 |
if add_fix_cols:
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
return cols, types
|
| 71 |
|
| 72 |
|
| 73 |
-
fixed_cols = get_default_auto_eval_column_dict()[:-
|
| 74 |
|
| 75 |
FIXED_COLS = [c.name for _, _, c in fixed_cols]
|
| 76 |
FIXED_COLS_TYPES = [c.type for _, _, c in fixed_cols]
|
|
|
|
| 43 |
return df[(df[COL_NAME_RETRIEVAL_MODEL].str.contains(query, case=False))]
|
| 44 |
|
| 45 |
|
| 46 |
+
def get_default_cols(task: str, columns: list=[], add_fix_cols: bool=True) -> list:
|
| 47 |
cols = []
|
| 48 |
types = []
|
| 49 |
if task == "qa":
|
|
|
|
| 65 |
types.append(col_type)
|
| 66 |
|
| 67 |
if add_fix_cols:
|
| 68 |
+
_cols = []
|
| 69 |
+
_types = []
|
| 70 |
+
for col_name, col_type in zip(cols, types):
|
| 71 |
+
if col_name in FIXED_COLS:
|
| 72 |
+
continue
|
| 73 |
+
_cols.append(col_name)
|
| 74 |
+
_types.append(col_type)
|
| 75 |
+
cols = FIXED_COLS + _cols
|
| 76 |
+
types = FIXED_COLS_TYPES + _types
|
| 77 |
return cols, types
|
| 78 |
|
| 79 |
|
| 80 |
+
fixed_cols = get_default_auto_eval_column_dict()[:-3]
|
| 81 |
|
| 82 |
FIXED_COLS = [c.name for _, _, c in fixed_cols]
|
| 83 |
FIXED_COLS_TYPES = [c.type for _, _, c in fixed_cols]
|
tests/src/display/test_utils.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import pytest
|
| 2 |
-
from src.display.utils import fields, AutoEvalColumnQA, COLS_QA, COLS_LONG_DOC, COLS_LITE, TYPES_QA, TYPES_LONG_DOC, QA_BENCHMARK_COLS, LONG_DOC_BENCHMARK_COLS
|
| 3 |
|
| 4 |
|
| 5 |
def test_fields():
|
|
@@ -15,3 +15,9 @@ def test_macro_variables():
|
|
| 15 |
print(f'TYPES_LONG_DOC: {TYPES_LONG_DOC}')
|
| 16 |
print(f'QA_BENCHMARK_COLS: {QA_BENCHMARK_COLS}')
|
| 17 |
print(f'LONG_DOC_BENCHMARK_COLS: {LONG_DOC_BENCHMARK_COLS}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import pytest
|
| 2 |
+
from src.display.utils import fields, AutoEvalColumnQA, COLS_QA, COLS_LONG_DOC, COLS_LITE, TYPES_QA, TYPES_LONG_DOC, QA_BENCHMARK_COLS, LONG_DOC_BENCHMARK_COLS, get_default_auto_eval_column_dict
|
| 3 |
|
| 4 |
|
| 5 |
def test_fields():
|
|
|
|
| 15 |
print(f'TYPES_LONG_DOC: {TYPES_LONG_DOC}')
|
| 16 |
print(f'QA_BENCHMARK_COLS: {QA_BENCHMARK_COLS}')
|
| 17 |
print(f'LONG_DOC_BENCHMARK_COLS: {LONG_DOC_BENCHMARK_COLS}')
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def test_get_default_auto_eval_column_dict():
|
| 21 |
+
auto_eval_column_dict_list = get_default_auto_eval_column_dict()
|
| 22 |
+
assert len(auto_eval_column_dict_list) == 9
|
| 23 |
+
|
tests/test_utils.py
CHANGED
|
@@ -91,4 +91,5 @@ def test_get_iso_format_timestamp():
|
|
| 91 |
def test_get_default_cols():
|
| 92 |
cols, types = get_default_cols("qa")
|
| 93 |
for c, t in zip(cols, types):
|
| 94 |
-
print(f"type({c}): {t}")
|
|
|
|
|
|
| 91 |
def test_get_default_cols():
|
| 92 |
cols, types = get_default_cols("qa")
|
| 93 |
for c, t in zip(cols, types):
|
| 94 |
+
print(f"type({c}): {t}")
|
| 95 |
+
assert len(frozenset(cols)) == len(cols)
|