evalsuite-python 0.6.0__cp39-abi3-win_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evalsuite/__init__.py +268 -0
- evalsuite/__main__.py +5 -0
- evalsuite/_bench_metrics.py +2080 -0
- evalsuite/_core.pyd +0 -0
- evalsuite/_lazy.py +32 -0
- evalsuite/_native.py +60 -0
- evalsuite/api.py +275 -0
- evalsuite/benchmarks.py +946 -0
- evalsuite/calibration.py +392 -0
- evalsuite/classification/__init__.py +51 -0
- evalsuite/classification/_common.py +111 -0
- evalsuite/classification/metrics.py +945 -0
- evalsuite/cli/__init__.py +5 -0
- evalsuite/cli/main.py +606 -0
- evalsuite/clinical/__init__.py +18 -0
- evalsuite/clinical/metrics.py +342 -0
- evalsuite/clinical/report.py +366 -0
- evalsuite/core/__init__.py +1 -0
- evalsuite/core/context.py +199 -0
- evalsuite/core/exceptions.py +52 -0
- evalsuite/core/export.py +100 -0
- evalsuite/core/registry.py +90 -0
- evalsuite/core/result.py +379 -0
- evalsuite/core/types.py +23 -0
- evalsuite/core/validation.py +256 -0
- evalsuite/llmsys/__init__.py +189 -0
- evalsuite/llmsys/_common.py +215 -0
- evalsuite/llmsys/agents.py +384 -0
- evalsuite/llmsys/code.py +923 -0
- evalsuite/llmsys/efficiency.py +346 -0
- evalsuite/llmsys/longcontext.py +361 -0
- evalsuite/llmsys/multilingual.py +339 -0
- evalsuite/llmsys/robustness.py +504 -0
- evalsuite/llmsys/safety.py +509 -0
- evalsuite/llmsys/uncertainty.py +229 -0
- evalsuite/plot.py +651 -0
- evalsuite/py.typed +0 -0
- evalsuite/regression/__init__.py +41 -0
- evalsuite/regression/metrics.py +629 -0
- evalsuite/reporting.py +241 -0
- evalsuite/stats/__init__.py +46 -0
- evalsuite/stats/_resolve.py +229 -0
- evalsuite/stats/compare.py +420 -0
- evalsuite/stats/effect.py +159 -0
- evalsuite/stats/hypothesis.py +593 -0
- evalsuite/stats/intervals.py +338 -0
- evalsuite/stats/paired.py +214 -0
- evalsuite/stats/results.py +129 -0
- evalsuite/text/__init__.py +154 -0
- evalsuite/text/_common.py +97 -0
- evalsuite/text/factuality.py +469 -0
- evalsuite/text/generation.py +1346 -0
- evalsuite/text/judge.py +556 -0
- evalsuite/text/qa.py +108 -0
- evalsuite/text/rag.py +235 -0
- evalsuite/text/reasoning.py +215 -0
- evalsuite/text/report.py +158 -0
- evalsuite/text/retrieval.py +238 -0
- evalsuite/text/semantic.py +499 -0
- evalsuite/text/spice.py +162 -0
- evalsuite/text/structured.py +793 -0
- evalsuite/version.py +3 -0
- evalsuite/vision/__init__.py +47 -0
- evalsuite/vision/detection.py +696 -0
- evalsuite/vision/segmentation.py +1028 -0
- evalsuite_python-0.6.0.dist-info/METADATA +509 -0
- evalsuite_python-0.6.0.dist-info/RECORD +72 -0
- evalsuite_python-0.6.0.dist-info/WHEEL +4 -0
- evalsuite_python-0.6.0.dist-info/entry_points.txt +2 -0
- evalsuite_python-0.6.0.dist-info/licenses/LICENSE +21 -0
- evalsuite_python-0.6.0.dist-info/licenses/LICENSE-APACHE +191 -0
- evalsuite_python-0.6.0.dist-info/sboms/evalsuite-py.cyclonedx.json +576 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"""Inference efficiency and operational cost (v0.5.0): time to first token, time per output token, end-to-end
|
|
2
|
+
latency and its percentiles, throughput, token counts, cost, resource utilisation, energy, request rate and
|
|
3
|
+
availability. Inputs are the timestamps, counts and readings your serving stack or load test records; times are
|
|
4
|
+
in seconds unless stated.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from collections.abc import Mapping
|
|
10
|
+
from typing import Any, Optional
|
|
11
|
+
|
|
12
|
+
import numpy as np
|
|
13
|
+
|
|
14
|
+
from ..core.exceptions import InputValidationError
|
|
15
|
+
from ..core.registry import register
|
|
16
|
+
from ..core.result import MetricResult
|
|
17
|
+
from ._common import floats, rate, same_length, seq, summary
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"availability",
|
|
21
|
+
"energy_per_request",
|
|
22
|
+
"inference_cost",
|
|
23
|
+
"latency_percentiles",
|
|
24
|
+
"requests_per_second",
|
|
25
|
+
"resource_utilization",
|
|
26
|
+
"throughput",
|
|
27
|
+
"time_per_output_token",
|
|
28
|
+
"time_to_first_token",
|
|
29
|
+
"token_usage",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
_C = "efficiency"
|
|
33
|
+
_REF_VLLM = (
|
|
34
|
+
"Kwon W, Li Z, Zhuang S, et al. Efficient memory management for large language model serving with "
|
|
35
|
+
"PagedAttention. SOSP. 2023:611-626."
|
|
36
|
+
)
|
|
37
|
+
_REF_MLPERF = "Reddi VJ, Cheng C, Kanter D, et al. MLPerf inference benchmark. ISCA. 2020:446-459."
|
|
38
|
+
_REF_DEAN = "Dean J, Barroso LA. The tail at scale. Commun ACM. 2013;56(2):74-80."
|
|
39
|
+
_REF_LUCCIONI = (
|
|
40
|
+
"Luccioni S, Jernite Y, Strubell E. Power hungry processing: watts driving the cost of AI deployment? ACM "
|
|
41
|
+
"FAccT. "
|
|
42
|
+
"2024:85-99."
|
|
43
|
+
)
|
|
44
|
+
_REF_SRE = "Beyer B, Jones C, Petoff J, Murphy NR. Site Reliability Engineering. O'Reilly; 2016."
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _durations(start: Any, end: Any, a: str, b: str) -> np.ndarray:
|
|
48
|
+
s, e = floats(start, a), floats(end, b)
|
|
49
|
+
same_length((a, s), (b, e))
|
|
50
|
+
d = e - s
|
|
51
|
+
if np.any(d < 0):
|
|
52
|
+
raise InputValidationError(f"{b} must not be earlier than {a}.")
|
|
53
|
+
return np.asarray(d, dtype=np.float64)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _stat_result(
|
|
57
|
+
metric: str, name: str, x: np.ndarray, unit: str, extra: Optional[dict[str, Any]] = None
|
|
58
|
+
) -> MetricResult:
|
|
59
|
+
return MetricResult(metric, name, float(x.mean()), {"unit": unit, **summary(x), **(extra or {})})
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@register(
|
|
63
|
+
category=_C,
|
|
64
|
+
task="latency",
|
|
65
|
+
name="Time to First Token (TTFT)",
|
|
66
|
+
definition="Time from sending a request to receiving the first output token; mean with p50/p90/p95/p99.",
|
|
67
|
+
formula="TTFT = t_first_token − t_request",
|
|
68
|
+
range="[0, ∞) s",
|
|
69
|
+
input_requirements=("request_times", "first_token_times"),
|
|
70
|
+
references=(_REF_VLLM, _REF_MLPERF),
|
|
71
|
+
higher_is_better=False,
|
|
72
|
+
)
|
|
73
|
+
def time_to_first_token(request_times: Any, first_token_times: Any) -> MetricResult:
|
|
74
|
+
return _stat_result(
|
|
75
|
+
"time_to_first_token",
|
|
76
|
+
"Time to first token",
|
|
77
|
+
_durations(request_times, first_token_times, "request_times", "first_token_times"),
|
|
78
|
+
"s",
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@register(
|
|
83
|
+
category=_C,
|
|
84
|
+
task="latency",
|
|
85
|
+
name="Time per Output Token (TPOT)",
|
|
86
|
+
definition="Mean time between output tokens after the first (inter-token latency), per request: "
|
|
87
|
+
"(t_end − t_first) / (output tokens − 1).",
|
|
88
|
+
formula="TPOT = (t_end − t_first) / (n_out − 1)",
|
|
89
|
+
range="[0, ∞) s",
|
|
90
|
+
input_requirements=("first_token_times", "end_times", "output_tokens"),
|
|
91
|
+
references=(_REF_VLLM, _REF_MLPERF),
|
|
92
|
+
higher_is_better=False,
|
|
93
|
+
)
|
|
94
|
+
def time_per_output_token(first_token_times: Any, end_times: Any, output_tokens: Any) -> MetricResult:
|
|
95
|
+
d = _durations(first_token_times, end_times, "first_token_times", "end_times")
|
|
96
|
+
n = floats(output_tokens, "output_tokens", lo=0)
|
|
97
|
+
same_length(("end_times", d), ("output_tokens", n))
|
|
98
|
+
keep = n > 1
|
|
99
|
+
if not keep.any():
|
|
100
|
+
raise InputValidationError("TPOT needs requests with at least two output tokens.")
|
|
101
|
+
return _stat_result(
|
|
102
|
+
"time_per_output_token", "Time per output token", d[keep] / (n[keep] - 1), "s", {"n_used": int(keep.sum())}
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@register(
|
|
107
|
+
category=_C,
|
|
108
|
+
task="latency",
|
|
109
|
+
name="p50 / p95 / p99 latency",
|
|
110
|
+
definition="End-to-end request latency percentiles; tail latency (p95, p99) governs user experience at "
|
|
111
|
+
"scale. The value is p95; mean, p50, p90 and p99 are in ``params``.",
|
|
112
|
+
formula="p-th percentile of latency (linear interpolation)",
|
|
113
|
+
range="[0, ∞)",
|
|
114
|
+
input_requirements=("latencies",),
|
|
115
|
+
references=(_REF_DEAN,),
|
|
116
|
+
higher_is_better=False,
|
|
117
|
+
)
|
|
118
|
+
def latency_percentiles(latencies: Any, *, unit: str = "s", percentile: float = 95) -> MetricResult:
|
|
119
|
+
x = floats(latencies, "latencies", lo=0)
|
|
120
|
+
if not 0 <= percentile <= 100:
|
|
121
|
+
raise InputValidationError("percentile must be in [0, 100].")
|
|
122
|
+
s = summary(x, extra=(percentile,))
|
|
123
|
+
value = s[f"p{percentile:g}"]
|
|
124
|
+
return MetricResult("latency_percentiles", f"p{percentile:g} latency", value, {"unit": unit, **s})
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@register(
|
|
128
|
+
category=_C,
|
|
129
|
+
task="throughput",
|
|
130
|
+
name="Throughput / tokens per second",
|
|
131
|
+
definition="Output tokens generated per second: system throughput over the measurement window (total tokens / "
|
|
132
|
+
"wall-clock span), and the mean per-request decode speed when request durations are given.",
|
|
133
|
+
formula="Σ output tokens / (t_last_end − t_first_start)",
|
|
134
|
+
range="[0, ∞) tokens/s",
|
|
135
|
+
input_requirements=("output_tokens", "start_times", "end_times"),
|
|
136
|
+
references=(_REF_VLLM, _REF_MLPERF),
|
|
137
|
+
)
|
|
138
|
+
def throughput(output_tokens: Any, start_times: Any, end_times: Any) -> MetricResult:
|
|
139
|
+
n = floats(output_tokens, "output_tokens", lo=0)
|
|
140
|
+
d = _durations(start_times, end_times, "start_times", "end_times")
|
|
141
|
+
same_length(("output_tokens", n), ("end_times", d))
|
|
142
|
+
s, e = floats(start_times, "start_times"), floats(end_times, "end_times")
|
|
143
|
+
span = float(e.max() - s.min())
|
|
144
|
+
if span <= 0:
|
|
145
|
+
raise InputValidationError("The measurement window has zero length.")
|
|
146
|
+
per = n[d > 0] / d[d > 0]
|
|
147
|
+
return MetricResult(
|
|
148
|
+
"throughput",
|
|
149
|
+
"Throughput (tokens/s)",
|
|
150
|
+
float(n.sum() / span),
|
|
151
|
+
{"per_request_tokens_per_second": float(per.mean()) if per.size else float("nan"), "window_s": span},
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@register(
|
|
156
|
+
category=_C,
|
|
157
|
+
task="usage",
|
|
158
|
+
name="Input / output token counts",
|
|
159
|
+
definition="Token usage per request: mean input and output tokens (the value is mean total tokens), with "
|
|
160
|
+
"percentiles and totals.",
|
|
161
|
+
formula="mean_r (input_r + output_r)",
|
|
162
|
+
range="[0, ∞)",
|
|
163
|
+
input_requirements=("input_tokens", "output_tokens"),
|
|
164
|
+
references=(_REF_MLPERF,),
|
|
165
|
+
higher_is_better=False,
|
|
166
|
+
)
|
|
167
|
+
def token_usage(input_tokens: Any, output_tokens: Any) -> MetricResult:
|
|
168
|
+
i = floats(input_tokens, "input_tokens", lo=0)
|
|
169
|
+
o = floats(output_tokens, "output_tokens", lo=0)
|
|
170
|
+
same_length(("input_tokens", i), ("output_tokens", o))
|
|
171
|
+
return MetricResult(
|
|
172
|
+
"token_usage",
|
|
173
|
+
"Tokens per request",
|
|
174
|
+
float((i + o).mean()),
|
|
175
|
+
{"input": summary(i), "output": summary(o), "total_input": float(i.sum()), "total_output": float(o.sum())},
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
@register(
|
|
180
|
+
category=_C,
|
|
181
|
+
task="cost",
|
|
182
|
+
name="Cost per request / per 1,000 tokens",
|
|
183
|
+
definition="Monetary cost from token counts and per-million-token prices (input and output priced "
|
|
184
|
+
"separately): mean cost per request (the value) and blended cost per 1,000 tokens.",
|
|
185
|
+
formula="cost_r = in_r · p_in / 10⁶ + out_r · p_out / 10⁶",
|
|
186
|
+
range="[0, ∞) currency units",
|
|
187
|
+
input_requirements=("input_tokens", "output_tokens", "input_price", "output_price"),
|
|
188
|
+
references=(_REF_LUCCIONI,),
|
|
189
|
+
higher_is_better=False,
|
|
190
|
+
)
|
|
191
|
+
def inference_cost(
|
|
192
|
+
input_tokens: Any,
|
|
193
|
+
output_tokens: Any,
|
|
194
|
+
*,
|
|
195
|
+
input_price: float,
|
|
196
|
+
output_price: float,
|
|
197
|
+
cached_tokens: Any = None,
|
|
198
|
+
cached_price: Optional[float] = None,
|
|
199
|
+
) -> MetricResult:
|
|
200
|
+
"""Prices are per million tokens. ``cached_tokens`` (part of the input billed at ``cached_price``)."""
|
|
201
|
+
i = floats(input_tokens, "input_tokens", lo=0)
|
|
202
|
+
o = floats(output_tokens, "output_tokens", lo=0)
|
|
203
|
+
same_length(("input_tokens", i), ("output_tokens", o))
|
|
204
|
+
if input_price < 0 or output_price < 0:
|
|
205
|
+
raise InputValidationError("Prices must be non-negative.")
|
|
206
|
+
cost = i * input_price / 1e6 + o * output_price / 1e6
|
|
207
|
+
if cached_tokens is not None:
|
|
208
|
+
if cached_price is None or cached_price < 0:
|
|
209
|
+
raise InputValidationError(
|
|
210
|
+
"cached_price (non-negative, per million tokens) is required with cached_tokens."
|
|
211
|
+
)
|
|
212
|
+
c = floats(cached_tokens, "cached_tokens", lo=0)
|
|
213
|
+
same_length(("input_tokens", i), ("cached_tokens", c))
|
|
214
|
+
if np.any(c > i):
|
|
215
|
+
raise InputValidationError("cached_tokens cannot exceed input_tokens.")
|
|
216
|
+
cost = cost - c * (input_price - cached_price) / 1e6
|
|
217
|
+
tokens = float((i + o).sum())
|
|
218
|
+
return MetricResult(
|
|
219
|
+
"inference_cost",
|
|
220
|
+
"Cost per request",
|
|
221
|
+
float(cost.mean()),
|
|
222
|
+
{
|
|
223
|
+
"total_cost": float(cost.sum()),
|
|
224
|
+
"cost_per_1k_tokens": float(cost.sum() / tokens * 1000) if tokens else float("nan"),
|
|
225
|
+
},
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@register(
|
|
230
|
+
category=_C,
|
|
231
|
+
task="resources",
|
|
232
|
+
name="Peak memory / CPU / GPU utilization",
|
|
233
|
+
definition="From periodic resource readings (memory in GB, CPU and GPU utilisation in %), the peak and mean "
|
|
234
|
+
"of each series; the value is peak memory when memory readings are given, otherwise the first series' peak.",
|
|
235
|
+
formula="peak = max_t reading_t; mean = mean_t reading_t",
|
|
236
|
+
range="[0, ∞)",
|
|
237
|
+
input_requirements=("readings",),
|
|
238
|
+
references=(_REF_MLPERF,),
|
|
239
|
+
higher_is_better=False,
|
|
240
|
+
)
|
|
241
|
+
def resource_utilization(readings: Mapping[str, Any]) -> MetricResult:
|
|
242
|
+
"""``readings``: mapping series name (``"memory_gb"``, ``"gpu_util"``, ``"cpu_util"``...) -> samples."""
|
|
243
|
+
if not isinstance(readings, Mapping) or not readings:
|
|
244
|
+
raise InputValidationError("readings must map a series name to its samples.")
|
|
245
|
+
out = {}
|
|
246
|
+
for k, v in readings.items():
|
|
247
|
+
x = floats(v, f"readings[{k!r}]", lo=0)
|
|
248
|
+
out[str(k)] = {"peak": float(x.max()), "mean": float(x.mean()), "p95": float(np.percentile(x, 95))}
|
|
249
|
+
key = next((k for k in out if "mem" in k.lower()), next(iter(out)))
|
|
250
|
+
return MetricResult("resource_utilization", f"Peak {key}", out[key]["peak"], {"series": out, "primary": key})
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
@register(
|
|
254
|
+
category=_C,
|
|
255
|
+
task="energy",
|
|
256
|
+
name="Energy per request",
|
|
257
|
+
definition="Energy consumed per request in watt-hours, from power readings sampled at a fixed interval over "
|
|
258
|
+
"the run (trapezoidal integration) or from a measured total, divided by the requests served.",
|
|
259
|
+
formula="E = ∫ P dt / 3600 / n_requests",
|
|
260
|
+
range="[0, ∞) Wh",
|
|
261
|
+
input_requirements=("power_watts", "interval_s", "n_requests"),
|
|
262
|
+
references=(_REF_LUCCIONI,),
|
|
263
|
+
higher_is_better=False,
|
|
264
|
+
)
|
|
265
|
+
def energy_per_request(
|
|
266
|
+
power_watts: Any = None,
|
|
267
|
+
*,
|
|
268
|
+
interval_s: Optional[float] = None,
|
|
269
|
+
n_requests: int,
|
|
270
|
+
total_joules: Optional[float] = None,
|
|
271
|
+
) -> MetricResult:
|
|
272
|
+
if isinstance(n_requests, bool) or not isinstance(n_requests, (int, np.integer)) or n_requests < 1:
|
|
273
|
+
raise InputValidationError("n_requests must be a positive integer.")
|
|
274
|
+
if total_joules is not None:
|
|
275
|
+
if total_joules < 0:
|
|
276
|
+
raise InputValidationError("total_joules must be non-negative.")
|
|
277
|
+
joules = float(total_joules)
|
|
278
|
+
else:
|
|
279
|
+
if power_watts is None or interval_s is None or interval_s <= 0:
|
|
280
|
+
raise InputValidationError("Pass power_watts with a positive interval_s, or total_joules.")
|
|
281
|
+
p = floats(power_watts, "power_watts", lo=0)
|
|
282
|
+
joules = float(np.sum((p[1:] + p[:-1]) / 2) * interval_s) if p.size > 1 else float(p[0] * interval_s)
|
|
283
|
+
wh = joules / 3600
|
|
284
|
+
return MetricResult(
|
|
285
|
+
"energy_per_request",
|
|
286
|
+
"Energy per request (Wh)",
|
|
287
|
+
wh / n_requests,
|
|
288
|
+
{"total_wh": wh, "joules_per_request": joules / n_requests},
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
@register(
|
|
293
|
+
category=_C,
|
|
294
|
+
task="throughput",
|
|
295
|
+
name="Requests per second",
|
|
296
|
+
definition="Completed requests per second over the measurement window, from request completion times.",
|
|
297
|
+
formula="(n − 1) / (t_last − t_first)",
|
|
298
|
+
range="[0, ∞)",
|
|
299
|
+
input_requirements=("completion_times",),
|
|
300
|
+
references=(_REF_MLPERF,),
|
|
301
|
+
)
|
|
302
|
+
def requests_per_second(completion_times: Any, *, start_time: Optional[float] = None) -> MetricResult:
|
|
303
|
+
"""With ``start_time`` (when the load test began) the rate is n / (t_last − start_time)."""
|
|
304
|
+
t = np.sort(floats(completion_times, "completion_times"))
|
|
305
|
+
if start_time is not None:
|
|
306
|
+
span, n = float(t[-1] - start_time), t.size
|
|
307
|
+
else:
|
|
308
|
+
if t.size < 2:
|
|
309
|
+
raise InputValidationError("Need at least two completions (or pass start_time).")
|
|
310
|
+
span, n = float(t[-1] - t[0]), t.size - 1
|
|
311
|
+
if span <= 0:
|
|
312
|
+
raise InputValidationError("The measurement window has zero length.")
|
|
313
|
+
return MetricResult(
|
|
314
|
+
"requests_per_second", "Requests per second", n / span, {"window_s": span, "completed": int(t.size)}
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
@register(
|
|
319
|
+
category=_C,
|
|
320
|
+
task="reliability",
|
|
321
|
+
name="Error rate / availability",
|
|
322
|
+
definition="Availability: share of requests served successfully (the value), with the error rate and the "
|
|
323
|
+
"error budget remaining against a service-level objective.",
|
|
324
|
+
formula="availability = successful / total; budget = 1 − (1 − availability) / (1 − SLO)",
|
|
325
|
+
range="[0, 1]",
|
|
326
|
+
input_requirements=("success",),
|
|
327
|
+
references=(_REF_SRE,),
|
|
328
|
+
)
|
|
329
|
+
def availability(success: Any, *, slo: float = 0.999) -> MetricResult:
|
|
330
|
+
items = seq(success, "success")
|
|
331
|
+
ok = np.array(
|
|
332
|
+
[
|
|
333
|
+
s is True or s == 1 or (isinstance(s, (int, np.integer)) and 200 <= int(s) < 400) or s == "ok"
|
|
334
|
+
for s in items
|
|
335
|
+
]
|
|
336
|
+
)
|
|
337
|
+
if not 0 < slo < 1:
|
|
338
|
+
raise InputValidationError("slo must be in (0, 1).")
|
|
339
|
+
r = rate("availability", "Availability", ok)
|
|
340
|
+
err = 1 - float(ok.mean())
|
|
341
|
+
return MetricResult(
|
|
342
|
+
r.metric,
|
|
343
|
+
r.name,
|
|
344
|
+
r.value,
|
|
345
|
+
{**r.params, "error_rate": err, "slo": slo, "error_budget_remaining": 1 - err / (1 - slo)},
|
|
346
|
+
)
|