Skip to content

Evaluation session

The object yielded by ExperimentStore.evaluation(...). It binds an evaluation_id so the record writers inside the context block never have to pass one, and forwards each call to the matching ExperimentStore method.

research_tracker.evaluation_session.EvaluationSession

Source code in src/research_tracker/evaluation_session.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class EvaluationSession:
    def __init__(
        self,
        store: ExperimentStore,
        evaluation: Evaluation,
    ):
        self.store = store
        self.evaluation = evaluation

    @property
    def evaluation_id(self) -> str:
        return self.evaluation.evaluation_id

    def add_condition(
        self,
        name: str,
        value: str | float | bool,
        *,
        unit: str | None = None,
    ) -> None:
        return self.store.add_condition(
            evaluation_id=self.evaluation_id,
            name=name,
            value=value,
            unit=unit,
        )

    def log_metric(
        self,
        metric: str,
        value: float,
        *,
        sample_id: str | None = None,
        target: str | None = None,
        comparison: str | None = None,
        region: str | None = None,
        unit: str | None = None,
    ) -> None:
        return self.store.log_metric(
            evaluation_id=self.evaluation_id,
            sample_id=sample_id,
            target=target,
            metric=metric,
            value=value,
            comparison=comparison,
            region=region,
            unit=unit,
        )

    def log_artifact(
        self,
        kind: str,
        path: Path,
        *,
        sample_id: str | None = None,
    ) -> None:
        return self.store.log_artifact(
            evaluation_id=self.evaluation_id,
            kind=kind,
            path=path,
            sample_id=sample_id,
        )