Spaces:
Runtime error
Runtime error
Nikhil Raghavan commited on
Commit Β·
9775a07
1
Parent(s): bec6307
changes to file parsing structure
Browse files- app.py +4 -17
- src/about.py +9 -5
- src/display/utils.py +5 -16
- src/leaderboard/read_evals.py +39 -151
- src/populate.py +3 -3
app.py
CHANGED
|
@@ -20,9 +20,9 @@ from src.display.utils import (
|
|
| 20 |
EVAL_TYPES,
|
| 21 |
AutoEvalColumn,
|
| 22 |
ModelType,
|
| 23 |
-
fields,
|
| 24 |
WeightType,
|
| 25 |
-
Precision
|
|
|
|
| 26 |
)
|
| 27 |
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
|
| 28 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
|
@@ -68,22 +68,9 @@ def init_leaderboard(dataframe):
|
|
| 68 |
cant_deselect=[c.name for c in fields(AutoEvalColumn) if c.never_hidden],
|
| 69 |
label="Select Columns to Display:",
|
| 70 |
),
|
| 71 |
-
search_columns=[AutoEvalColumn.
|
| 72 |
hide_columns=[c.name for c in fields(AutoEvalColumn) if c.hidden],
|
| 73 |
-
filter_columns=[
|
| 74 |
-
ColumnFilter(AutoEvalColumn.model_type.name, type="checkboxgroup", label="Model types"),
|
| 75 |
-
ColumnFilter(AutoEvalColumn.precision.name, type="checkboxgroup", label="Precision"),
|
| 76 |
-
ColumnFilter(
|
| 77 |
-
AutoEvalColumn.params.name,
|
| 78 |
-
type="slider",
|
| 79 |
-
min=0.01,
|
| 80 |
-
max=150,
|
| 81 |
-
label="Select the number of parameters (B)",
|
| 82 |
-
),
|
| 83 |
-
ColumnFilter(
|
| 84 |
-
AutoEvalColumn.still_on_hub.name, type="boolean", label="Deleted/incomplete", default=True
|
| 85 |
-
),
|
| 86 |
-
],
|
| 87 |
bool_checkboxgroup_label="Hide models",
|
| 88 |
interactive=False,
|
| 89 |
)
|
|
|
|
| 20 |
EVAL_TYPES,
|
| 21 |
AutoEvalColumn,
|
| 22 |
ModelType,
|
|
|
|
| 23 |
WeightType,
|
| 24 |
+
Precision,
|
| 25 |
+
fields,
|
| 26 |
)
|
| 27 |
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
|
| 28 |
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
|
|
|
| 68 |
cant_deselect=[c.name for c in fields(AutoEvalColumn) if c.never_hidden],
|
| 69 |
label="Select Columns to Display:",
|
| 70 |
),
|
| 71 |
+
search_columns=[AutoEvalColumn.technique.name],
|
| 72 |
hide_columns=[c.name for c in fields(AutoEvalColumn) if c.hidden],
|
| 73 |
+
filter_columns=[],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
bool_checkboxgroup_label="Hide models",
|
| 75 |
interactive=False,
|
| 76 |
)
|
src/about.py
CHANGED
|
@@ -11,11 +11,15 @@ class Task:
|
|
| 11 |
# Select your tasks here
|
| 12 |
# ---------------------------------------------------
|
| 13 |
class Tasks(Enum):
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# ---------------------------------------------------
|
| 20 |
|
| 21 |
|
|
|
|
| 11 |
# Select your tasks here
|
| 12 |
# ---------------------------------------------------
|
| 13 |
class Tasks(Enum):
|
| 14 |
+
# benchmark key in metric_results, value key inside each metric, display name
|
| 15 |
+
asr_i2p = Task("asr_i2p", "value", "ASR (I2P)")
|
| 16 |
+
asr_ring_a_bell = Task("asr_ring_a_bell", "value", "ASR (RingABell)")
|
| 17 |
+
asr_mma_diffusion = Task("asr_mma_diffusion", "value", "ASR (MMA)")
|
| 18 |
+
err = Task("err", "value", "ERR")
|
| 19 |
+
fid = Task("fid", "value", "FID")
|
| 20 |
+
clip_score = Task("clip_score", "value", "CLIP Score")
|
| 21 |
+
ua_ira = Task("ua_ira", "value", "UA-IRA")
|
| 22 |
+
tifa = Task("tifa", "value", "TIFA")
|
| 23 |
# ---------------------------------------------------
|
| 24 |
|
| 25 |
|
src/display/utils.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from dataclasses import dataclass, make_dataclass
|
| 2 |
from enum import Enum
|
| 3 |
|
| 4 |
import pandas as pd
|
|
@@ -23,22 +23,11 @@ class ColumnContent:
|
|
| 23 |
## Leaderboard columns
|
| 24 |
auto_eval_column_dict = []
|
| 25 |
# Init
|
| 26 |
-
auto_eval_column_dict.append(["
|
| 27 |
-
|
| 28 |
-
#Scores
|
| 29 |
-
auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average β¬οΈ", "number", True)])
|
| 30 |
for task in Tasks:
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
| 34 |
-
auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
| 35 |
-
auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
|
| 36 |
-
auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
|
| 37 |
-
auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False)])
|
| 38 |
-
auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
|
| 39 |
-
auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub β€οΈ", "number", False)])
|
| 40 |
-
auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
|
| 41 |
-
auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
|
| 42 |
|
| 43 |
# We use make dataclass to dynamically fill the scores from Tasks
|
| 44 |
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
|
|
|
| 1 |
+
from dataclasses import dataclass, field, make_dataclass
|
| 2 |
from enum import Enum
|
| 3 |
|
| 4 |
import pandas as pd
|
|
|
|
| 23 |
## Leaderboard columns
|
| 24 |
auto_eval_column_dict = []
|
| 25 |
# Init
|
| 26 |
+
auto_eval_column_dict.append(["technique", ColumnContent, field(default_factory=lambda: ColumnContent("Technique", "str", True, never_hidden=True))])
|
| 27 |
+
# Metric scores
|
|
|
|
|
|
|
| 28 |
for task in Tasks:
|
| 29 |
+
_task = task # capture loop variable
|
| 30 |
+
auto_eval_column_dict.append([task.name, ColumnContent, field(default_factory=lambda t=_task: ColumnContent(t.value.col_name, "number", True))])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# We use make dataclass to dynamically fill the scores from Tasks
|
| 33 |
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
src/leaderboard/read_evals.py
CHANGED
|
@@ -1,196 +1,84 @@
|
|
| 1 |
-
import glob
|
| 2 |
import json
|
| 3 |
-
import math
|
| 4 |
import os
|
| 5 |
-
from dataclasses import dataclass
|
| 6 |
|
| 7 |
-
import
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
from src.display.formatting import make_clickable_model
|
| 11 |
-
from src.display.utils import AutoEvalColumn, ModelType, Tasks, Precision, WeightType
|
| 12 |
-
from src.submission.check_validity import is_model_on_hub
|
| 13 |
|
| 14 |
|
| 15 |
@dataclass
|
| 16 |
class EvalResult:
|
| 17 |
-
"""Represents one
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
org: str
|
| 22 |
-
model: str
|
| 23 |
-
revision: str # commit hash, "" if main
|
| 24 |
-
results: dict
|
| 25 |
-
precision: Precision = Precision.Unknown
|
| 26 |
-
model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
|
| 27 |
-
weight_type: WeightType = WeightType.Original # Original or Adapter
|
| 28 |
-
architecture: str = "Unknown"
|
| 29 |
-
license: str = "?"
|
| 30 |
-
likes: int = 0
|
| 31 |
-
num_params: int = 0
|
| 32 |
-
date: str = "" # submission date of request file
|
| 33 |
-
still_on_hub: bool = False
|
| 34 |
|
| 35 |
@classmethod
|
| 36 |
-
def init_from_json_file(
|
| 37 |
-
"""Inits the result from the specific model result file"""
|
| 38 |
with open(json_filepath) as fp:
|
| 39 |
data = json.load(fp)
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
# Precision
|
| 44 |
-
precision = Precision.from_str(config.get("model_dtype"))
|
| 45 |
-
|
| 46 |
-
# Get model and org
|
| 47 |
-
org_and_model = config.get("model_name", config.get("model_args", None))
|
| 48 |
-
org_and_model = org_and_model.split("/", 1)
|
| 49 |
-
|
| 50 |
-
if len(org_and_model) == 1:
|
| 51 |
-
org = None
|
| 52 |
-
model = org_and_model[0]
|
| 53 |
-
result_key = f"{model}_{precision.value.name}"
|
| 54 |
-
else:
|
| 55 |
-
org = org_and_model[0]
|
| 56 |
-
model = org_and_model[1]
|
| 57 |
-
result_key = f"{org}_{model}_{precision.value.name}"
|
| 58 |
-
full_model = "/".join(org_and_model)
|
| 59 |
-
|
| 60 |
-
still_on_hub, _, model_config = is_model_on_hub(
|
| 61 |
-
full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
|
| 62 |
-
)
|
| 63 |
-
architecture = "?"
|
| 64 |
-
if model_config is not None:
|
| 65 |
-
architectures = getattr(model_config, "architectures", None)
|
| 66 |
-
if architectures:
|
| 67 |
-
architecture = ";".join(architectures)
|
| 68 |
|
| 69 |
-
# Extract results available in this file (some results are split in several files)
|
| 70 |
results = {}
|
| 71 |
for task in Tasks:
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
accs = np.array([v.get(task.metric, None) for k, v in data["results"].items() if task.benchmark == k])
|
| 76 |
-
if accs.size == 0 or any([acc is None for acc in accs]):
|
| 77 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
return self(
|
| 83 |
-
eval_name=result_key,
|
| 84 |
-
full_model=full_model,
|
| 85 |
-
org=org,
|
| 86 |
-
model=model,
|
| 87 |
results=results,
|
| 88 |
-
precision=precision,
|
| 89 |
-
revision= config.get("model_sha", ""),
|
| 90 |
-
still_on_hub=still_on_hub,
|
| 91 |
-
architecture=architecture
|
| 92 |
)
|
| 93 |
|
| 94 |
-
def update_with_request_file(self, requests_path):
|
| 95 |
-
"""Finds the relevant request file for the current model and updates info with it"""
|
| 96 |
-
request_file = get_request_file_for_model(requests_path, self.full_model, self.precision.value.name)
|
| 97 |
-
|
| 98 |
-
try:
|
| 99 |
-
with open(request_file, "r") as f:
|
| 100 |
-
request = json.load(f)
|
| 101 |
-
self.model_type = ModelType.from_str(request.get("model_type", ""))
|
| 102 |
-
self.weight_type = WeightType[request.get("weight_type", "Original")]
|
| 103 |
-
self.license = request.get("license", "?")
|
| 104 |
-
self.likes = request.get("likes", 0)
|
| 105 |
-
self.num_params = request.get("params", 0)
|
| 106 |
-
self.date = request.get("submitted_time", "")
|
| 107 |
-
except Exception:
|
| 108 |
-
print(f"Could not find request file for {self.org}/{self.model} with precision {self.precision.value.name}")
|
| 109 |
-
|
| 110 |
def to_dict(self):
|
| 111 |
-
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
| 112 |
-
average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)
|
| 113 |
data_dict = {
|
| 114 |
-
"eval_name": self.eval_name,
|
| 115 |
-
AutoEvalColumn.
|
| 116 |
-
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
| 117 |
-
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
| 118 |
-
AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
| 119 |
-
AutoEvalColumn.architecture.name: self.architecture,
|
| 120 |
-
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
| 121 |
-
AutoEvalColumn.revision.name: self.revision,
|
| 122 |
-
AutoEvalColumn.average.name: average,
|
| 123 |
-
AutoEvalColumn.license.name: self.license,
|
| 124 |
-
AutoEvalColumn.likes.name: self.likes,
|
| 125 |
-
AutoEvalColumn.params.name: self.num_params,
|
| 126 |
-
AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
| 127 |
}
|
| 128 |
-
|
| 129 |
for task in Tasks:
|
| 130 |
data_dict[task.value.col_name] = self.results[task.value.benchmark]
|
| 131 |
-
|
| 132 |
return data_dict
|
| 133 |
|
| 134 |
|
| 135 |
-
def
|
| 136 |
-
"""
|
| 137 |
-
request_files = os.path.join(
|
| 138 |
-
requests_path,
|
| 139 |
-
f"{model_name}_eval_request_*.json",
|
| 140 |
-
)
|
| 141 |
-
request_files = glob.glob(request_files)
|
| 142 |
-
|
| 143 |
-
# Select correct request file (precision)
|
| 144 |
-
request_file = ""
|
| 145 |
-
request_files = sorted(request_files, reverse=True)
|
| 146 |
-
for tmp_request_file in request_files:
|
| 147 |
-
with open(tmp_request_file, "r") as f:
|
| 148 |
-
req_content = json.load(f)
|
| 149 |
-
if (
|
| 150 |
-
req_content["status"] in ["FINISHED"]
|
| 151 |
-
and req_content["precision"] == precision.split(".")[-1]
|
| 152 |
-
):
|
| 153 |
-
request_file = tmp_request_file
|
| 154 |
-
return request_file
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResult]:
|
| 158 |
-
"""From the path of the results folder root, extract all needed info for results"""
|
| 159 |
model_result_filepaths = []
|
| 160 |
|
| 161 |
for root, _, files in os.walk(results_path):
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
# Sort the files by date
|
| 167 |
-
try:
|
| 168 |
-
files.sort(key=lambda x: x.removesuffix(".json").removeprefix("results_")[:-7])
|
| 169 |
-
except dateutil.parser._parser.ParserError:
|
| 170 |
-
files = [files[-1]]
|
| 171 |
-
|
| 172 |
-
for file in files:
|
| 173 |
-
model_result_filepaths.append(os.path.join(root, file))
|
| 174 |
|
| 175 |
eval_results = {}
|
| 176 |
-
for
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
| 180 |
|
| 181 |
-
# Store results of same eval together
|
| 182 |
eval_name = eval_result.eval_name
|
| 183 |
-
if eval_name in eval_results
|
| 184 |
-
|
|
|
|
|
|
|
|
|
|
| 185 |
else:
|
| 186 |
eval_results[eval_name] = eval_result
|
| 187 |
|
| 188 |
results = []
|
| 189 |
for v in eval_results.values():
|
| 190 |
try:
|
| 191 |
-
v.to_dict()
|
| 192 |
results.append(v)
|
| 193 |
-
except KeyError:
|
| 194 |
continue
|
| 195 |
|
| 196 |
return results
|
|
|
|
|
|
|
| 1 |
import json
|
|
|
|
| 2 |
import os
|
| 3 |
+
from dataclasses import dataclass, field
|
| 4 |
|
| 5 |
+
from src.display.utils import AutoEvalColumn
|
| 6 |
+
from src.about import Tasks
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
@dataclass
|
| 10 |
class EvalResult:
|
| 11 |
+
"""Represents one evaluation run, built from a report JSON file."""
|
| 12 |
+
eval_name: str # technique_name (used as uid)
|
| 13 |
+
technique_name: str
|
| 14 |
+
results: dict = field(default_factory=dict)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
@classmethod
|
| 17 |
+
def init_from_json_file(cls, json_filepath):
|
|
|
|
| 18 |
with open(json_filepath) as fp:
|
| 19 |
data = json.load(fp)
|
| 20 |
|
| 21 |
+
technique_name = data["technique_name"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
|
|
|
| 23 |
results = {}
|
| 24 |
for task in Tasks:
|
| 25 |
+
task_val = task.value
|
| 26 |
+
metric_data = data.get("metric_results", {}).get(task_val.benchmark)
|
| 27 |
+
if metric_data is None:
|
|
|
|
|
|
|
| 28 |
continue
|
| 29 |
+
value = metric_data.get(task_val.metric)
|
| 30 |
+
if value is None:
|
| 31 |
+
continue
|
| 32 |
+
results[task_val.benchmark] = value
|
| 33 |
|
| 34 |
+
return cls(
|
| 35 |
+
eval_name=technique_name,
|
| 36 |
+
technique_name=technique_name,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
results=results,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
)
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
def to_dict(self):
|
|
|
|
|
|
|
| 41 |
data_dict = {
|
| 42 |
+
"eval_name": self.eval_name,
|
| 43 |
+
AutoEvalColumn.technique.name: self.technique_name,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
}
|
|
|
|
| 45 |
for task in Tasks:
|
| 46 |
data_dict[task.value.col_name] = self.results[task.value.benchmark]
|
|
|
|
| 47 |
return data_dict
|
| 48 |
|
| 49 |
|
| 50 |
+
def get_raw_eval_results(results_path: str, requests_path: str = None) -> list[EvalResult]:
|
| 51 |
+
"""Walk results_path recursively and load all JSON report files."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
model_result_filepaths = []
|
| 53 |
|
| 54 |
for root, _, files in os.walk(results_path):
|
| 55 |
+
for f in files:
|
| 56 |
+
if f.endswith(".json"):
|
| 57 |
+
model_result_filepaths.append(os.path.join(root, f))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
eval_results = {}
|
| 60 |
+
for filepath in model_result_filepaths:
|
| 61 |
+
try:
|
| 62 |
+
eval_result = EvalResult.init_from_json_file(filepath)
|
| 63 |
+
except Exception as e:
|
| 64 |
+
print(f"Could not parse {filepath}: {e}")
|
| 65 |
+
continue
|
| 66 |
|
|
|
|
| 67 |
eval_name = eval_result.eval_name
|
| 68 |
+
if eval_name in eval_results:
|
| 69 |
+
# Merge metrics from multiple files for the same technique
|
| 70 |
+
eval_results[eval_name].results.update(
|
| 71 |
+
{k: v for k, v in eval_result.results.items() if v is not None}
|
| 72 |
+
)
|
| 73 |
else:
|
| 74 |
eval_results[eval_name] = eval_result
|
| 75 |
|
| 76 |
results = []
|
| 77 |
for v in eval_results.values():
|
| 78 |
try:
|
| 79 |
+
v.to_dict()
|
| 80 |
results.append(v)
|
| 81 |
+
except KeyError:
|
| 82 |
continue
|
| 83 |
|
| 84 |
return results
|
src/populate.py
CHANGED
|
@@ -8,9 +8,9 @@ from src.display.utils import AutoEvalColumn, EvalQueueColumn
|
|
| 8 |
from src.leaderboard.read_evals import get_raw_eval_results
|
| 9 |
|
| 10 |
|
| 11 |
-
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
| 12 |
"""Creates a dataframe from all the individual experiment results"""
|
| 13 |
-
raw_data = get_raw_eval_results(results_path
|
| 14 |
all_data_json = [v.to_dict() for v in raw_data]
|
| 15 |
|
| 16 |
df = pd.DataFrame.from_records(all_data_json)
|
|
@@ -39,7 +39,7 @@ def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
|
| 39 |
all_evals.append(data)
|
| 40 |
elif ".md" not in entry:
|
| 41 |
# this is a folder
|
| 42 |
-
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if os.path.isfile(e) and not e.startswith(".")]
|
| 43 |
for sub_entry in sub_entries:
|
| 44 |
file_path = os.path.join(save_path, entry, sub_entry)
|
| 45 |
with open(file_path) as fp:
|
|
|
|
| 8 |
from src.leaderboard.read_evals import get_raw_eval_results
|
| 9 |
|
| 10 |
|
| 11 |
+
def get_leaderboard_df(results_path: str, requests_path: str = None, cols: list = None, benchmark_cols: list = None) -> pd.DataFrame:
|
| 12 |
"""Creates a dataframe from all the individual experiment results"""
|
| 13 |
+
raw_data = get_raw_eval_results(results_path)
|
| 14 |
all_data_json = [v.to_dict() for v in raw_data]
|
| 15 |
|
| 16 |
df = pd.DataFrame.from_records(all_data_json)
|
|
|
|
| 39 |
all_evals.append(data)
|
| 40 |
elif ".md" not in entry:
|
| 41 |
# this is a folder
|
| 42 |
+
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if os.path.isfile(os.path.join(save_path, entry, e)) and not e.startswith(".")]
|
| 43 |
for sub_entry in sub_entries:
|
| 44 |
file_path = os.path.join(save_path, entry, sub_entry)
|
| 45 |
with open(file_path) as fp:
|