From 12407923c4ed5783932e511a49cd7605a9cc68a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Schmelczer?= Date: Wed, 25 May 2022 22:53:42 +0200 Subject: [PATCH] Show outputs on dashboard --- .../src/great_ai/great_ai/metrics/create_dash_app.py | 10 ++++++++-- .../great_ai/persistence/parallel_tinydb_driver.py | 3 +++ great_ai/src/great_ai/great_ai/views/trace.py | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/great_ai/src/great_ai/great_ai/metrics/create_dash_app.py b/great_ai/src/great_ai/great_ai/metrics/create_dash_app.py index cab63a3..4ab63e2 100644 --- a/great_ai/src/great_ai/great_ai/metrics/create_dash_app.py +++ b/great_ai/src/great_ai/great_ai/metrics/create_dash_app.py @@ -70,7 +70,6 @@ def create_dash_app(function_name: str, function_docs: str) -> Flask: get_footer(), interval := dcc.Interval( interval=4 * 1000, # in milliseconds - n_intervals=0, ), ] ) @@ -116,6 +115,10 @@ def create_dash_app(function_name: str, function_docs: str) -> Flask: rows = get_context().persistence.query( conjunctive_filters=non_null_conjunctive_filters ) + + if not rows: + return go.Figure() + df = pd.DataFrame(rows) fig = px.histogram( @@ -150,13 +153,16 @@ def create_dash_app(function_name: str, function_docs: str) -> Flask: conjunctive_filters=non_null_conjunctive_filters ) + if not rows: + return go.Figure() + df = pd.DataFrame(rows) return go.Figure( go.Parcoords( dimensions=[ get_dimension_descriptor(df, c) for c in df.columns - if not c.startswith("arg:") and c not in {"id", "created"} + if not c.startswith("arg:") and c not in {"id", "created", "output"} ], line_color=accent_color, ) diff --git a/great_ai/src/great_ai/great_ai/persistence/parallel_tinydb_driver.py b/great_ai/src/great_ai/great_ai/persistence/parallel_tinydb_driver.py index 0f1bfc4..f3112c1 100644 --- a/great_ai/src/great_ai/great_ai/persistence/parallel_tinydb_driver.py +++ b/great_ai/src/great_ai/great_ai/persistence/parallel_tinydb_driver.py @@ -56,6 +56,9 @@ class ParallelTinyDbDriver(PersistenceDriver): take: Optional[int] = None, ) -> List[Dict[str, Any]]: documents = self.get_documents() + if not documents: + return [] + df = pd.DataFrame(documents) for f in conjunctive_filters: diff --git a/great_ai/src/great_ai/great_ai/views/trace.py b/great_ai/src/great_ai/great_ai/views/trace.py index 8357c65..362f93a 100644 --- a/great_ai/src/great_ai/great_ai/views/trace.py +++ b/great_ai/src/great_ai/great_ai/views/trace.py @@ -1,3 +1,4 @@ +from json import dumps from typing import Any, Dict, List, Optional from uuid import uuid4 @@ -29,7 +30,7 @@ class Trace(BaseModel): "created": self.created, "execution_time_ms": self.execution_time_ms, "models": ", ".join(f"{m.key}:{m.version}" for m in self.models), - "output": self.output, + "output": dumps(self.output), "evaluation": self.evaluation, **self.logged_values, }