Fix metrics formatting and add sorting
Browse files- app.py +5 -12
- src/get_results_for_task.py +13 -2
- src/leaderboard_formatting.py +3 -0
app.py
CHANGED
@@ -5,18 +5,11 @@ import gradio as gr # type: ignore[import]
|
|
5 |
from apscheduler.schedulers.background import BackgroundScheduler
|
6 |
from huggingface_hub import HfApi
|
7 |
|
8 |
-
from src.content import (
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
SUBMISSION_TEXT_FILES,
|
14 |
-
SUBMISSION_TEXT_INTRO,
|
15 |
-
SUBMISSION_TEXT_METADATA,
|
16 |
-
SUBMISSION_TEXT_SUBMIT,
|
17 |
-
SUBMISSION_TEXT_TASK,
|
18 |
-
SUBMISSION_TITLE,
|
19 |
-
)
|
20 |
from src.get_results_for_task import get_results_for_task
|
21 |
from src.submission_uploader import SubmissionUploader
|
22 |
from src.tasks import TASKS_DESCRIPTIONS, TASKS_PRETTY, TASKS_PRETTY_REVERSE
|
|
|
5 |
from apscheduler.schedulers.background import BackgroundScheduler
|
6 |
from huggingface_hub import HfApi
|
7 |
|
8 |
+
from src.content import (INTRODUCTION_TEXT, INTRODUCTION_TITLE,
|
9 |
+
LEADERBOARD_TEXT, LEADERBOARD_TITLE,
|
10 |
+
SUBMISSION_TEXT_FILES, SUBMISSION_TEXT_INTRO,
|
11 |
+
SUBMISSION_TEXT_METADATA, SUBMISSION_TEXT_SUBMIT,
|
12 |
+
SUBMISSION_TEXT_TASK, SUBMISSION_TITLE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
from src.get_results_for_task import get_results_for_task
|
14 |
from src.submission_uploader import SubmissionUploader
|
15 |
from src.tasks import TASKS_DESCRIPTIONS, TASKS_PRETTY, TASKS_PRETTY_REVERSE
|
src/get_results_for_task.py
CHANGED
@@ -2,9 +2,12 @@ import logging
|
|
2 |
import os
|
3 |
|
4 |
import pandas as pd # type: ignore[import]
|
5 |
-
from datasets import get_dataset_config_names,
|
|
|
6 |
|
7 |
-
from .leaderboard_formatting import COLUMNS_PRETTY,
|
|
|
|
|
8 |
from .tasks import TASKS_PRETTY_REVERSE
|
9 |
|
10 |
AVAILABLE_TASKS = get_dataset_config_names(os.environ["DATASET_ID"])
|
@@ -48,6 +51,14 @@ def _get_results_dataset(task_id: str) -> pd.DataFrame:
|
|
48 |
results_df["Context Size"] = results_df["Context Size"].map(
|
49 |
lambda x: f"{int(x) // 1000}k" if int(x) >= 1000 else x
|
50 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
results_df = results_df[get_columns_per_task(task_id)]
|
52 |
return results_df
|
53 |
|
|
|
2 |
import os
|
3 |
|
4 |
import pandas as pd # type: ignore[import]
|
5 |
+
from datasets import (get_dataset_config_names, # type: ignore[import]
|
6 |
+
load_dataset)
|
7 |
|
8 |
+
from .leaderboard_formatting import (COLUMNS_PRETTY, METRICS_PER_TASK,
|
9 |
+
SORT_COLUMN_PER_TASK,
|
10 |
+
get_columns_per_task)
|
11 |
from .tasks import TASKS_PRETTY_REVERSE
|
12 |
|
13 |
AVAILABLE_TASKS = get_dataset_config_names(os.environ["DATASET_ID"])
|
|
|
51 |
results_df["Context Size"] = results_df["Context Size"].map(
|
52 |
lambda x: f"{int(x) // 1000}k" if int(x) >= 1000 else x
|
53 |
)
|
54 |
+
|
55 |
+
results_df = results_df.sort_values(
|
56 |
+
by=SORT_COLUMN_PER_TASK[task_id], ascending=False
|
57 |
+
)
|
58 |
+
|
59 |
+
for metric_column in METRICS_PER_TASK[task_id]:
|
60 |
+
results_df[metric_column] = results_df[metric_column].map(lambda x: f"{x:.2f}")
|
61 |
+
|
62 |
results_df = results_df[get_columns_per_task(task_id)]
|
63 |
return results_df
|
64 |
|
src/leaderboard_formatting.py
CHANGED
@@ -29,6 +29,9 @@ METRICS_PER_TASK = {
|
|
29 |
}
|
30 |
|
31 |
|
|
|
|
|
|
|
32 |
def get_columns_per_task(task_id: str) -> List[str]:
|
33 |
metrics_per_task = METRICS_PER_TASK[task_id]
|
34 |
|
|
|
29 |
}
|
30 |
|
31 |
|
32 |
+
SORT_COLUMN_PER_TASK = {"commit_message_generation": "ROUGE-1"}
|
33 |
+
|
34 |
+
|
35 |
def get_columns_per_task(task_id: str) -> List[str]:
|
36 |
metrics_per_task = METRICS_PER_TASK[task_id]
|
37 |
|