telemetry-dev 0.3.4__tar.gz → 0.3.5__tar.gz
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.
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/PKG-INFO +1 -1
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/pyproject.toml +1 -1
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/pyproject.toml.orig +1 -1
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_experiments.py +57 -7
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/LICENSE +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/README.md +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/__init__.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_api.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_capture.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_ci.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_client.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_config.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_context.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_export.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_logs.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_metrics.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_observe.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_process_lock.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_processor.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_prompts.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_scores.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_semconv.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_serialize.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/_spans.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/otel.py +0 -0
- {telemetry_dev-0.3.4 → telemetry_dev-0.3.5}/src/telemetry_dev/py.typed +0 -0
|
@@ -14,7 +14,8 @@ import urllib.parse
|
|
|
14
14
|
from collections.abc import Awaitable, Callable, Generator, Mapping, Sequence
|
|
15
15
|
from concurrent.futures import ThreadPoolExecutor
|
|
16
16
|
from dataclasses import dataclass
|
|
17
|
-
from decimal import Decimal
|
|
17
|
+
from decimal import ROUND_HALF_UP, Decimal
|
|
18
|
+
from decimal import Context as DecimalContext
|
|
18
19
|
from time import perf_counter
|
|
19
20
|
from typing import Any, Literal, TypeAlias, TypeGuard, cast
|
|
20
21
|
|
|
@@ -1000,12 +1001,7 @@ def _check_result(result: ExperimentResult, runs_per_item: int) -> None:
|
|
|
1000
1001
|
)
|
|
1001
1002
|
if result.check_status != "failed":
|
|
1002
1003
|
return
|
|
1003
|
-
failed = [
|
|
1004
|
-
f"{score.name} is {_format(score.kind, score.value)}, under the pass mark "
|
|
1005
|
-
f"{_format(score.kind, score.min_score)}"
|
|
1006
|
-
for score in result.scores
|
|
1007
|
-
if score.passed is False
|
|
1008
|
-
]
|
|
1004
|
+
failed = [_under_mark(score) for score in result.scores if score.passed is False]
|
|
1009
1005
|
if result.items_failed > 0:
|
|
1010
1006
|
failed.insert(0, _items_failed_text(result, runs_per_item))
|
|
1011
1007
|
detail = f": {'; '.join(failed)}" if failed else ""
|
|
@@ -1025,6 +1021,60 @@ def _items_failed_text(result: ExperimentResult, runs_per_item: int) -> str:
|
|
|
1025
1021
|
return f"{result.items_failed} of {result.items_done} {unit} failed"
|
|
1026
1022
|
|
|
1027
1023
|
|
|
1024
|
+
def _under_mark(score: ExperimentScore) -> str:
|
|
1025
|
+
"""A score under its pass mark, with the numbers of the annotation of the action.
|
|
1026
|
+
|
|
1027
|
+
The mark has 10 decimals. The value has 2 decimals for a rate and 3 otherwise, and one more
|
|
1028
|
+
while it rounds to the mark or above it, up to 17, so that a value just under the mark does not
|
|
1029
|
+
read as the mark. A rate shows both as percents. A score with no kind had no values: a mark of
|
|
1030
|
+
1 or less on it is a pass rate, as the action reads it.
|
|
1031
|
+
"""
|
|
1032
|
+
rate = score.kind in _RATE_KINDS or (
|
|
1033
|
+
score.kind is None and score.min_score is not None and score.min_score <= 1
|
|
1034
|
+
)
|
|
1035
|
+
|
|
1036
|
+
def rounded(number: float, digits: int) -> float:
|
|
1037
|
+
# float() first: a whole number from the JSON is an int, which JavaScript holds as a float.
|
|
1038
|
+
return _js_fixed(float(number) * 100 if rate else float(number), digits)
|
|
1039
|
+
|
|
1040
|
+
def text(number: float) -> str:
|
|
1041
|
+
return _js_string(number) + ("%" if rate else "")
|
|
1042
|
+
|
|
1043
|
+
mark = None if score.min_score is None else rounded(score.min_score, 10)
|
|
1044
|
+
mark_text = "no score" if mark is None else text(mark)
|
|
1045
|
+
if score.value is None:
|
|
1046
|
+
return f"{score.name} is no score, under the pass mark {mark_text}"
|
|
1047
|
+
digits = 2 if rate else 3
|
|
1048
|
+
while mark is not None and digits < 17 and rounded(score.value, digits) >= mark:
|
|
1049
|
+
digits += 1
|
|
1050
|
+
return f"{score.name} is {text(rounded(score.value, digits))}, under the pass mark {mark_text}"
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
def _js_fixed(number: float, digits: int) -> float:
|
|
1054
|
+
# +number.toFixed(digits) of JavaScript: the exact value with a half rounded away from zero.
|
|
1055
|
+
# The precision holds the 309 whole digits of the largest float and the decimals.
|
|
1056
|
+
step = Decimal(1).scaleb(-digits)
|
|
1057
|
+
return float(Decimal(number).quantize(step, ROUND_HALF_UP, DecimalContext(prec=400)))
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
def _js_string(number: float) -> str:
|
|
1061
|
+
"""String(number) of JavaScript: the digits of repr(), with an exponent under 1e-6 and from
|
|
1062
|
+
1e21 only, and no ".0" or "-0"."""
|
|
1063
|
+
_, digit_tuple, exponent = Decimal(repr(abs(number))).normalize().as_tuple()
|
|
1064
|
+
digits = "".join(map(str, digit_tuple))
|
|
1065
|
+
point = len(digits) + int(exponent)
|
|
1066
|
+
if len(digits) <= point <= 21:
|
|
1067
|
+
text = digits + "0" * (point - len(digits))
|
|
1068
|
+
elif 0 < point <= 21:
|
|
1069
|
+
text = f"{digits[:point]}.{digits[point:]}"
|
|
1070
|
+
elif -6 < point <= 0:
|
|
1071
|
+
text = f"0.{'0' * -point}{digits}"
|
|
1072
|
+
else:
|
|
1073
|
+
mantissa = digits if len(digits) == 1 else f"{digits[0]}.{digits[1:]}"
|
|
1074
|
+
text = f"{mantissa}e{'+' if point > 0 else '-'}{abs(point - 1)}"
|
|
1075
|
+
return f"{'-' if number < 0 else ''}{text}"
|
|
1076
|
+
|
|
1077
|
+
|
|
1028
1078
|
def _describe(result: ExperimentResult, runs_per_item: int) -> str:
|
|
1029
1079
|
if result.status != "completed":
|
|
1030
1080
|
outcome = result.status + (f": {result.error}" if result.error else "")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|