File size: 1,357 Bytes
f91d9a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""Task interface for modular benchmark parsing and scoring."""

from __future__ import annotations

from dataclasses import dataclass
from pathlib import Path
from typing import Any

from ..io import BENCHMARK_ROOT


@dataclass(frozen=True)
class TaskSpec:
    name: str
    display_name: str
    default_manifest: Path | None
    sort_key: str = "eval_id"


class BenchmarkTask:
    spec: TaskSpec
    primary_metric: str

    @property
    def name(self) -> str:
        return self.spec.name

    @property
    def display_name(self) -> str:
        return self.spec.display_name

    @property
    def default_manifest(self) -> Path | None:
        return self.spec.default_manifest

    @property
    def sort_key(self) -> str:
        return self.spec.sort_key

    def load_examples(
        self,
        *,
        benchmark_root: Path = BENCHMARK_ROOT,
        manifest_path: Path | None = None,
        video_root: Path | None = None,
    ) -> list[dict[str, Any]]:
        raise NotImplementedError

    def parse_record(self, row: dict[str, Any]) -> dict[str, Any]:
        raise NotImplementedError

    def parse_rows(self, rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
        return [self.parse_record(dict(row)) for row in rows]

    def score(self, rows: list[dict[str, Any]]) -> dict[str, Any]:
        raise NotImplementedError