diff --git a/examples/future_dashboads.ipynb b/examples/future_dashboads.ipynb index 802c4f99b3..7bf8fc503d 100644 --- a/examples/future_dashboads.ipynb +++ b/examples/future_dashboads.ipynb @@ -6,11 +6,14 @@ "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2025-01-03T16:03:38.786175Z", - "start_time": "2025-01-03T16:03:35.972155Z" + "end_time": "2025-01-08T13:01:54.904648Z", + "start_time": "2025-01-08T13:01:51.766554Z" } }, "source": [ + "from evidently.ui.dashboards import CounterAgg\n", + "from evidently.ui.dashboards import PanelValue\n", + "from evidently.ui.dashboards import ReportFilter\n", "import datetime\n", "import pandas as pd\n", "\n", @@ -24,6 +27,7 @@ "from evidently.future.backport import SingleValueDashboardPanel\n", "from evidently.future.report import Report\n", "from evidently.future.tests import lte\n", + "from evidently.ui.dashboards import DashboardPanelCounter\n", "from evidently.ui.workspace import Workspace\n", "\n", "def create_snapshot(i):\n", @@ -31,9 +35,7 @@ " dataset = Dataset.from_pandas(\n", " df,\n", " data_definition=DataDefinition(\n", - " {\n", - " \"col\": ColumnInfo(ColumnType.Numerical),\n", - " }\n", + " numerical_features=[\"col\"],\n", " ),\n", " )\n", " report = Report([MeanValue(column=\"col\", tests=[lte(4)])])\n", @@ -55,7 +57,14 @@ "\n", " project = ws.add_project(Project(id=ZERO_UUID, name=\"test proj\"))\n", "\n", - " project.dashboard.add_panel(SingleValueDashboardPanel(metric_id=\"mean:col\"))\n", + " project.dashboard.add_panel(SingleValueDashboardPanel(metric_id=MeanValue(column=\"col\", tests=[lte(4)]).metric_id))\n", + " project.dashboard.add_panel(DashboardPanelCounter(\n", + " title=\"Last mean value\",\n", + " agg=CounterAgg.LAST,\n", + " value=PanelValue(field_path=\"value\", metric_args={\"metric.metric_id\": \"2e5caa9690281e02cf243c736d687782\"}),\n", + " filter=ReportFilter(metadata_values={}, tag_values=[], include_test_suites=True),\n", + " ))\n", + " # project.dashboard.add_panel(SingleValueDashboardPanel(metric_id=\"mean:col\"))\n", " project.save()\n", "\n", "for i in range(10):\n", @@ -67,17 +76,17 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-01-03T16:03:38.789133Z", - "start_time": "2025-01-03T16:03:38.787020Z" + "end_time": "2025-01-08T13:01:54.911704Z", + "start_time": "2025-01-08T13:01:54.908667Z" } }, "cell_type": "code", - "outputs": [], - "execution_count": 2, "source": [ "# use `evidently ui` to run UI service to see project dashboard." ], - "id": "35a20fd14d577dc8" + "id": "35a20fd14d577dc8", + "outputs": [], + "execution_count": 2 } ], "metadata": { diff --git a/src/evidently/future/metric_types.py b/src/evidently/future/metric_types.py index c02efbbe88..617a8596ac 100644 --- a/src/evidently/future/metric_types.py +++ b/src/evidently/future/metric_types.py @@ -369,6 +369,10 @@ def to_calculation(self) -> TCalculation: def get_metric_id(self) -> str: return self.get_fingerprint() + @property + def metric_id(self) -> str: + return self.get_fingerprint() + def _default_tests(self) -> List[MetricTestProto[TResult]]: """ allows to redefine default tests for metric