1
1
from typing import Dict , Optional , Union
2
+ from typing_extensions import Annotated
2
3
from enum import Enum
3
4
4
- from .base import ConfidenceValue , BaseMetric
5
+ from pydantic import field_validator
6
+ from pydantic .types import confloat
5
7
6
- from pydantic import confloat , field_validator , model_serializer
8
+ from . base import ConfidenceValue , BaseMetric
7
9
8
- ScalarMetricValue = confloat (ge = 0 , le = 100_000_000 )
10
+ ScalarMetricValue = Annotated [ float , confloat (ge = 0 , le = 100_000_000 )]
9
11
ScalarMetricConfidenceValue = Dict [ConfidenceValue , ScalarMetricValue ]
10
12
11
13
@@ -27,11 +29,12 @@ class ScalarMetric(BaseMetric):
27
29
For backwards compatibility, metric_name is optional.
28
30
The metric_name will be set to a default name in the editor if it is not set.
29
31
This is not recommended and support for empty metric_name fields will be removed.
30
- aggregation will be ignored wihtout providing a metric name.
32
+ aggregation will be ignored without providing a metric name.
31
33
"""
32
34
metric_name : Optional [str ] = None
33
35
value : Union [ScalarMetricValue , ScalarMetricConfidenceValue ]
34
- aggregation : ScalarMetricAggregation = ScalarMetricAggregation .ARITHMETIC_MEAN
36
+ aggregation : Optional [
37
+ ScalarMetricAggregation ] = ScalarMetricAggregation .ARITHMETIC_MEAN
35
38
36
39
@field_validator ('metric_name' )
37
40
def validate_metric_name (cls , name : Union [str , None ]):
0 commit comments