Show outputs on dashboard

This commit is contained in:
Andras Schmelczer 2022-05-25 22:53:42 +02:00
parent ba955c444b
commit b4492da2e6
No known key found for this signature in database
GPG key ID: 39260B5B0614A13E
3 changed files with 13 additions and 3 deletions

View file

@ -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,
)

View file

@ -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:

View file

@ -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,
}