"""Streamlit entry point for exploring OpenPinch analysis results.
Run with ``streamlit run streamlit_app.py`` to load the bundled demonstration
case and launch the interactive dashboard defined in
``OpenPinch.streamlit_webviewer.web_graphing``.
"""
from __future__ import annotations
from pathlib import Path
import streamlit as st
from OpenPinch import PinchProblem
# Current case. Update this path if you want to switch datasets.
PROBLEM_FILE = Path("examples/OpenPinchWkbs/Ziyatdinov et al (example 2).xlsb")
@st.cache_resource
def _load_problem(problem_path: str) -> PinchProblem:
"""Load and solve the pinch problem once per Streamlit session."""
problem = PinchProblem(source=problem_path)
problem.target()
return problem
[docs]
def validate_problem_path(problem_path) -> None:
"""Stop the Streamlit app early when the configured problem file is missing."""
if not problem_path.exists():
st.error(
f"Problem file not found at {problem_path}. "
"Update PROBLEM_FILE to point to a valid case."
)
st.stop()
if __name__ == "__main__":
problem_path = PROBLEM_FILE
validate_problem_path(problem_path)
problem = _load_problem(str(problem_path))
problem.show_dashboard()