@@ -157,18 +157,24 @@ def _check_nested_dict_keys(cls, nested: dict[Any, Any], metdims: dict[Any, Any]
157157 raise ValueError ("Error in dicts of Results" )
158158
159159 for key , value in nested .items ():
160- if isinstance (value , dict ) and level < len (metdims [MetricCV .JSON_STRUCTURE .value ]) - 1 :
160+ if key == MetricCV .ATTRIBUTES .value :
161+ continue
162+
163+ elif isinstance (value , dict ) and level < len (metdims [MetricCV .JSON_STRUCTURE .value ]) - 1 :
161164 cls ._check_nested_dict_keys (value , metdims , level + 1 )
162165 elif isinstance (value , dict ):
163- StrNumDict (value )
166+ tmp = dict (value )
167+ if MetricCV .ATTRIBUTES .value in tmp :
168+ tmp .pop (MetricCV .ATTRIBUTES .value )
169+ StrNumDict (tmp )
164170
165171 @field_validator ("root" , mode = "after" )
166172 @classmethod
167173 def _validate_results (cls , rlt : Any , info : ValidationInfo ) -> Any :
168174 """Validate a MetricResults object"""
169175 if not isinstance (info .context , MetricDimensions ):
170176 s = "\n To validate MetricResults object, MetricDimensions is needed,\n "
171- s += "please use model_validate(Results, context=MetricDimensions to instantiate\n "
177+ s += "please use model_validate(Results, context=MetricDimensions) to instantiate\n "
172178 raise ValueError (s )
173179 else :
174180 # results = rlt.root
@@ -295,7 +301,11 @@ def _fill(cls, mdict: dict[Any, Any], mdims: dict[Any, Any], level: int = 0) ->
295301 mdict [key ] = {}
296302
297303 for key , value in mdict .items ():
298- if isinstance (value , dict ) and level < len (mdims [MetricCV .JSON_STRUCTURE .value ]) - 1 :
304+ if (
305+ isinstance (value , dict )
306+ and level < len (mdims [MetricCV .JSON_STRUCTURE .value ]) - 1
307+ and key != MetricCV .ATTRIBUTES .value
308+ ):
299309 cls ._fill (value , mdims , level + 1 )
300310
301311 @classmethod
@@ -321,8 +331,8 @@ def merge(cls, metric_obj1: Any, metric_obj2: Any) -> Self:
321331
322332 merged_obj_dims = MetricDimensions .merge_dimension (mobj1 .DIMENSIONS , mobj2 .DIMENSIONS )
323333
324- result1 = mobj2 .RESULTS
325- result2 = mobj1 .RESULTS
334+ result1 = mobj1 .RESULTS
335+ result2 = mobj2 .RESULTS
326336 merged_obj_rlts = cls ._merge (dict (result1 ), result2 )
327337
328338 cls ._fill (merged_obj_rlts , merged_obj_dims .root )
0 commit comments