Skip to content

Commit ff0bb3b

Browse files
authored
Fix: Add alias for custom_name in Metric (#233)
* Fixed naming for metrics * Fix test case
1 parent ea4eded commit ff0bb3b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

polaris/benchmark/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _convert(m: str | dict | Metric) -> Metric:
171171
unique_names = {m.name for m in unique_metrics}
172172
if len(unique_names) != len(unique_metrics):
173173
raise InvalidBenchmarkError(
174-
"The benchmark has similarly named metrics. Specify a custom name with Metric(custom_name=...)"
174+
"The metrics of a benchmark need to have unique names. Specify a custom name with Metric(custom_name=...)"
175175
)
176176

177177
return unique_metrics

polaris/evaluate/_metric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class Metric(BaseModel):
285285

286286
label: MetricLabel
287287
config: GroupedMetricConfig | None = None
288-
custom_name: str | None = Field(None, exclude=True)
288+
custom_name: str | None = Field(None, exclude=True, alias="name")
289289

290290
# Frozen metadata
291291
fn: Callable = Field(frozen=True, exclude=True)

tests/test_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def test_benchmark_duplicate_metrics(test_single_task_benchmark):
233233
m["main_metric"] = m["metrics"][0]
234234
SingleTaskBenchmarkSpecification(**m)
235235

236-
with pytest.raises(ValidationError, match="The benchmark has similarly named metrics"):
236+
with pytest.raises(ValidationError, match="The metrics of a benchmark need to have unique names."):
237237
m["metrics"][0].config.group_by = "MULTICLASS_calc"
238238
SingleTaskBenchmarkSpecification(**m)
239239

0 commit comments

Comments
 (0)