Spaces:
Runtime error
Runtime error
Commit ·
1c14ec3
1
Parent(s): b5fdc1f
diag: print checkpoints + visible loading banner; expose errors to stderr
Browse files- streamlit_app.py +19 -10
streamlit_app.py
CHANGED
|
@@ -2,8 +2,11 @@ import sys, os, traceback
|
|
| 2 |
from pathlib import Path
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
st.set_page_config(
|
| 8 |
page_title="SpindleFlow RL",
|
| 9 |
page_icon="⚡",
|
|
@@ -11,30 +14,36 @@ st.set_page_config(
|
|
| 11 |
initial_sidebar_state="collapsed",
|
| 12 |
)
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
_real_spc = st.set_page_config
|
| 17 |
st.set_page_config = lambda *a, **kw: None
|
| 18 |
|
| 19 |
-
# ── 3. Make env.*, reward.*, agents.* and orchestrator_widget importable.
|
| 20 |
-
_root = Path(__file__).resolve().parent
|
| 21 |
for _p in (str(_root), str(_root / "demo")):
|
| 22 |
if _p not in sys.path:
|
| 23 |
sys.path.insert(0, _p)
|
| 24 |
os.chdir(str(_root))
|
| 25 |
|
| 26 |
-
# ── 4. Run demo/streamlit_app.py exactly as __main__.
|
| 27 |
-
# Its st.set_page_config() call is now a no-op; main() draws the UI.
|
| 28 |
_demo = _root / "demo" / "streamlit_app.py"
|
|
|
|
|
|
|
| 29 |
try:
|
| 30 |
exec(
|
| 31 |
compile(_demo.read_text(encoding="utf-8"), str(_demo), "exec"),
|
| 32 |
{"__file__": str(_demo), "__name__": "__main__"},
|
| 33 |
)
|
|
|
|
|
|
|
| 34 |
except SystemExit:
|
| 35 |
-
|
| 36 |
except Exception as exc:
|
|
|
|
|
|
|
|
|
|
| 37 |
st.error(f"SpindleFlow failed to load: {exc}")
|
| 38 |
st.code(traceback.format_exc())
|
| 39 |
finally:
|
| 40 |
-
st.set_page_config = _real_spc
|
|
|
|
| 2 |
from pathlib import Path
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
+
print("[SpindleFlow] wrapper starting", flush=True)
|
| 6 |
+
|
| 7 |
+
_root = Path(__file__).resolve().parent
|
| 8 |
+
|
| 9 |
+
# Page config fires before anything else so the browser gets a live response.
|
| 10 |
st.set_page_config(
|
| 11 |
page_title="SpindleFlow RL",
|
| 12 |
page_icon="⚡",
|
|
|
|
| 14 |
initial_sidebar_state="collapsed",
|
| 15 |
)
|
| 16 |
|
| 17 |
+
# Show a visible loading message while the heavy ML imports run (~20-30 s).
|
| 18 |
+
_banner = st.empty()
|
| 19 |
+
_banner.info("⏳ Loading SpindleFlow RL — first load takes ~30 s on CPU…")
|
| 20 |
+
|
| 21 |
+
# Silence the duplicate set_page_config inside demo/streamlit_app.py.
|
| 22 |
_real_spc = st.set_page_config
|
| 23 |
st.set_page_config = lambda *a, **kw: None
|
| 24 |
|
|
|
|
|
|
|
| 25 |
for _p in (str(_root), str(_root / "demo")):
|
| 26 |
if _p not in sys.path:
|
| 27 |
sys.path.insert(0, _p)
|
| 28 |
os.chdir(str(_root))
|
| 29 |
|
|
|
|
|
|
|
| 30 |
_demo = _root / "demo" / "streamlit_app.py"
|
| 31 |
+
print(f"[SpindleFlow] running exec on {_demo}", flush=True)
|
| 32 |
+
|
| 33 |
try:
|
| 34 |
exec(
|
| 35 |
compile(_demo.read_text(encoding="utf-8"), str(_demo), "exec"),
|
| 36 |
{"__file__": str(_demo), "__name__": "__main__"},
|
| 37 |
)
|
| 38 |
+
print("[SpindleFlow] exec completed OK", flush=True)
|
| 39 |
+
_banner.empty()
|
| 40 |
except SystemExit:
|
| 41 |
+
_banner.empty()
|
| 42 |
except Exception as exc:
|
| 43 |
+
print(f"[SpindleFlow] ERROR: {exc}", file=sys.stderr, flush=True)
|
| 44 |
+
traceback.print_exc(file=sys.stderr)
|
| 45 |
+
_banner.empty()
|
| 46 |
st.error(f"SpindleFlow failed to load: {exc}")
|
| 47 |
st.code(traceback.format_exc())
|
| 48 |
finally:
|
| 49 |
+
st.set_page_config = _real_spc
|