diff --git a/capella_model_explorer/demo.py b/capella_model_explorer/demo.py index c5bf64a..4d37328 100644 --- a/capella_model_explorer/demo.py +++ b/capella_model_explorer/demo.py @@ -51,19 +51,21 @@ def describe_object(obj): ) if not model_name: + st.session_state["model_name"] = None + st.session_state["model"] = None st.stop() -if ( - "model_name" not in st.session_state - or st.session_state["model_name"] != model_name -): +if st.session_state.get("model_name") != model_name: all_models = st.session_state["all_models"] st.session_state.clear() st.session_state["all_models"] = all_models - st.session_state["model"] = capellambse.MelodyModel( - st.session_state["all_models"][model_name] - ) - st.session_state["model_name"] = model_name + + with st.sidebar, st.spinner(f"Loading {model_name}..."): + st.session_state["model"] = capellambse.MelodyModel( + st.session_state["all_models"][model_name] + ) + st.session_state["model_name"] = model_name + model = st.session_state["model"] with st.sidebar: st.write(f"Loaded model {model.name!r}")