Skip to content

Commit 1cf97a2

Browse files
committed
Add logging for data retrieval errors in dashboard routes
1 parent 5b39c39 commit 1cf97a2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

dashboard/routes.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Routes for the dashboard.
33
"""
44

5+
import logging
6+
import pandas as pd
57
from fasthtml.common import *
68
from monsterui.all import *
79
from fasthtml.svg import *
@@ -13,6 +15,9 @@
1315
from charts import ChartManager
1416

1517

18+
log = logging.getLogger("anomstack")
19+
20+
1621
@rt
1722
def index(request: Request):
1823
"""
@@ -34,9 +39,13 @@ def index(request: Request):
3439
batch_stats = {}
3540
for batch_name in app.state.metric_batches:
3641
if batch_name not in app.state.df_cache:
37-
df = get_data(
38-
app.state.specs_enabled[batch_name], max_n=DEFAULT_ALERT_MAX_N
39-
)
42+
try:
43+
df = get_data(
44+
app.state.specs_enabled[batch_name], max_n=DEFAULT_ALERT_MAX_N
45+
)
46+
except Exception as e:
47+
log.error(f"Error getting data for batch {batch_name}: {e}")
48+
df = pd.DataFrame()
4049
app.state.df_cache[batch_name] = df
4150
else:
4251
df = app.state.df_cache[batch_name]

0 commit comments

Comments
 (0)