Skip to content

Commit

Permalink
Support ByLabelValue in field iterators. (#1450)
Browse files Browse the repository at this point in the history
* Place descriptors from new reports in proper place in old snapshots.

* Custom iterator for ByLabelValue for ui.
  • Loading branch information
Liraim authored Jan 23, 2025
1 parent 63b476f commit 113b3b1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/evidently/ui/storage/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def iterate_obj_fields(
if es is not None:
yield from es
return

from evidently.future.backport import ByLabelValueV1

if isinstance(obj, ByLabelValueV1):
yield from (
[(".".join(paths + ["values"]), obj.values)]
+ [(".".join(paths + ["values", str(key)]), str(val)) for key, val in obj.values.items()]
)
return
if isinstance(obj, list):
return
if isinstance(obj, dict):
Expand All @@ -40,6 +49,9 @@ def iterate_obj_fields(

def iterate_obj_float_fields(obj: Any, paths: List[str]) -> Iterator[Tuple[str, str]]:
for path, value in iterate_obj_fields(obj, paths):
if isinstance(value, dict):
yield path, json.dumps(value, cls=NumpyEncoder)
continue
if isinstance(value, BaseResult) and value.__config__.extract_as_obj:
yield path, json.dumps(value.dict(), cls=NumpyEncoder)
continue
Expand Down

0 comments on commit 113b3b1

Please sign in to comment.