Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix metric args plot values #750

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/evidently/ui/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from evidently.model.dashboard import DashboardInfo
from evidently.model.widget import BaseWidgetInfo
from evidently.pydantic_utils import EnumValueMixin
from evidently.pydantic_utils import EvidentlyBaseModel
from evidently.pydantic_utils import FieldPath
from evidently.pydantic_utils import PolymorphicModel
from evidently.renderers.html_widgets import CounterData
Expand Down Expand Up @@ -87,7 +88,7 @@ class PanelValue(BaseModel):
field_path: Union[str, FieldPath]
metric_id: Optional[str] = None
metric_hash: Optional[int] = None
metric_args: Dict[str, Any] = {}
metric_args: Dict[str, Union[EvidentlyBaseModel, Any]] = {}
legend: Optional[str] = None

@property
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/test_dashboards.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import json
from typing import Dict

import pytest
from pydantic import parse_obj_as

from evidently.base_metric import MetricResult
from evidently.descriptors import OOV
from evidently.ui.dashboards import PanelValue
from evidently.ui.dashboards import getattr_nested


Expand All @@ -21,3 +25,12 @@ class B(MetricResult):
)
def test_getattr_nested(obj, path: str, value):
assert getattr_nested(obj, path.split(".")) == value


def test_panel_value_metric_args_ser():
pv = PanelValue(field_path="", metric_args={"col": OOV(display_name="OOV").for_column("Review_Text")})

pl = json.dumps(pv.dict())
pv2 = parse_obj_as(PanelValue, json.loads(pl))

assert pv2 == pv