Skip to content
Open
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
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ dagster-cleanup-menu:
# DASHBOARD OPERATIONS
# =============================================================================

.PHONY: dashboard dashboardd dashboard-uvicorn dashboardd-uvicorn dashboard-local-dev kill-dashboardd seed-local-db
.PHONY: dashboard dashboardd dashboard-uvicorn dashboardd-uvicorn dashboard-local-dev kill-dashboardd seed-local-db seed-local-db-all seed-local-db-custom

# start dashboard locally
dashboard:
Expand Down Expand Up @@ -371,7 +371,14 @@ dashboard-local-dev:

# kill any running dashboard process
kill-dashboardd:
kill $(shell ps aux | grep dashboard/app.py | grep -v grep | awk '{print $$2}') $(shell lsof -ti :5000)
@pids="$$(pgrep -f 'dashboard/app.py' 2>/dev/null) $$(pgrep -f 'uvicorn dashboard.app:app' 2>/dev/null) $$(lsof -ti :5003 2>/dev/null) $$(lsof -ti :8080 2>/dev/null) $$(lsof -ti :5000 2>/dev/null)"; \
pids="$$(printf '%s\n' $$pids | tr ' ' '\n' | sed '/^$$/d' | sort -u | tr '\n' ' ')"; \
if [ -n "$$pids" ]; then \
echo "🛑 Stopping dashboard processes: $$pids"; \
kill $$pids; \
else \
echo "No dashboard processes found"; \
fi

# =============================================================================
# TESTING & QUALITY
Expand Down
20 changes: 16 additions & 4 deletions dashboard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@

import logging
import os
from pathlib import Path

from dotenv import load_dotenv
from fasthtml.common import Link, Script, fast_app, serve
from monsterui.all import *

from dashboard.constants import POSTHOG_SCRIPT
from dashboard.state import AppState
from anomstack.version import get_git_commit_hash

# load the environment variables with custom env file support
def load_env_with_custom_path():
"""Load environment variables from custom path or default .env file."""
from pathlib import Path

env_file_path = os.getenv("ANOMSTACK_ENV_FILE_PATH")

if env_file_path:
Expand All @@ -44,6 +44,8 @@ def load_env_with_custom_path():
load_env_with_custom_path()

log = logging.getLogger("anomstack_dashboard")
STYLESHEET_PATH = Path(__file__).parent / "static" / "styles.css"
STYLESHEET_VERSION = f"{get_git_commit_hash()}-{int(STYLESHEET_PATH.stat().st_mtime)}"

# PostHog script generation function (lazy loading to ensure env vars are available)
def get_posthog_script():
Expand All @@ -68,16 +70,26 @@ def get_posthog_script():
# Define the app
app, rt = fast_app(
hdrs=(
Theme.blue.headers(),
Theme.blue.headers(
mode="auto",
radii=ThemeRadii.lg,
shadows=ThemeShadows.md,
font=ThemeFont.default,
),
Script(src="https://cdn.plot.ly/plotly-2.32.0.min.js"),
Script(posthog_script) if posthog_script else None,
Link(
rel="icon",
type="image/svg+xml",
href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWNoYXJ0LWxpbmUiPjxwYXRoIGQ9Ik0zIDN2MTZhMiAyIDAgMCAwIDIgMmgxNiIvPjxwYXRoIGQ9Im0xOSA5LTUgNS00LTQtMyAzIi8+PC9zdmc+",
),
Link(rel="stylesheet", href="dashboard/static/styles.css"),
Link(
rel="stylesheet",
href=f"/dashboard/static/styles.css?v={STYLESHEET_VERSION}",
),
),
title="Anomstack",
bodykw={"class": "antialiased"},
debug=os.getenv("ANOMSTACK_DASHBOARD_DEBUG", "false").lower() == "true",
log=log,
)
Expand Down
Loading
Loading