-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
52 lines (43 loc) · 1.58 KB
/
Copy pathstreamlit_app.py
File metadata and controls
52 lines (43 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""Streamlit Cloud entrypoint.
Streamlit Cloud installs the package via uv-sync, but the shim also
adds `src/` to ``sys.path`` so the entrypoint works regardless of
install state.
DIAGNOSTIC MODE: we render a heartbeat banner *before* any other
imports so we can tell at a glance whether Streamlit is even running
our script. If the page is blank, you're seeing browser/Cloud issues.
If you see the banner but the rest is missing, something downstream
crashed.
"""
from __future__ import annotations
import sys
from pathlib import Path
import streamlit as st
# ---- Heartbeat — this is the FIRST visible output --------------------------
st.set_page_config(
page_title="CanAID — Contact Center",
layout="wide",
initial_sidebar_state="expanded",
)
_DIAG_BOX = st.empty()
_DIAG_BOX.success(
"✅ streamlit_app.py loaded — proceeding to import canaid.ui.streamlit_app …"
)
# Now bootstrap canaid.
_SRC = Path(__file__).resolve().parent / "src"
if _SRC.exists() and str(_SRC) not in sys.path:
sys.path.insert(0, str(_SRC))
try:
from canaid.ui.streamlit_app import * # noqa: F401, F403, E402
except Exception as exc: # noqa: BLE001
import traceback as _tb
_DIAG_BOX.error(
f"**Import error in canaid.ui.streamlit_app**\n\n"
f"`{type(exc).__name__}: {exc}`"
)
with st.expander("Full traceback", expanded=True):
st.code(_tb.format_exc(), language="python")
st.stop()
else:
# Successful import — clear the heartbeat (the real app has rendered
# its own UI by now, so leaving the banner just adds clutter).
_DIAG_BOX.empty()