File size: 1,793 Bytes
d9a47f6
 
 
6b02a54
d9a47f6
 
 
 
 
 
 
 
 
 
 
 
6b02a54
d9a47f6
 
 
6b02a54
d9a47f6
 
 
 
 
6b02a54
 
 
d9a47f6
 
6b02a54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Root app.py – HuggingFace Spaces entry point.

Delegates directly to visualization/app.py.

Run locally :  streamlit run app.py
HF Spaces   :  set "app_file: app.py" in README.md front-matter (default)
"""

import sys
import importlib.util
from pathlib import Path

import streamlit as st

ROOT = Path(__file__).resolve().parent
APP_DIR = ROOT / "visualization"

# ── Page config (must be the very first Streamlit call) ────────────────────────
st.set_page_config(
    page_title="Musora Sentiment Analysis",
    page_icon="πŸ“Š",
    layout="wide",
    initial_sidebar_state="expanded",
)

# Prevent visualization/app.py's module-level st.set_page_config() call from
# raising an error – patch it to a no-op on the shared streamlit module object.
import streamlit as _st_mod
_st_mod.set_page_config = lambda *a, **kw: None

# ── Ensure sub-app packages are importable ─────────────────────────────────────
app_dir_str = str(APP_DIR)
if app_dir_str not in sys.path:
    sys.path.insert(0, app_dir_str)

# ── Load and run visualization/app.py ─────────────────────────────────────────
spec = importlib.util.spec_from_file_location("_subapp", APP_DIR / "app.py")
mod  = importlib.util.module_from_spec(spec)

try:
    spec.loader.exec_module(mod)   # runs module-level code (config, auth, etc.)
    if hasattr(mod, "main"):
        mod.main()                 # renders the full dashboard
except Exception as exc:
    if "Stop" in type(exc).__name__:   # re-raise st.stop() for Streamlit's runner
        raise
    st.error(f"Dashboard error: {exc}")
    st.exception(exc)