Update src/streamlit_app.py
Browse files🚀 Stable HF Deployment: SteelAI EAF Intelligence Explorer v3.0
- Added persistent session log separator (timestamped runs)
- Unified tab creation (Download & Logs tabs included upfront)
- Fixed safe metadata filtering for minimal JSONs (no KeyError)
- Fully removed bibliography PDF generation; replaced with clickable URLs
- Enabled self-contained logging inside ./logs with auto-run history
- Updated Streamlit width syntax (compliant with post-2025 deprecation)
- Added sidebar session info (timestamp + directory)
- Dataset + model artifacts remain reproducible & downloadable
44 unmodified lines454647484950302 unmodified lines353354355356357358359360361362363364365545 unmodified lines91191291391491591691714 unmodified lines93293393493593693793844 unmodified linesdef log(msg: str):stamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")with open(LOG_PATH, "a", encoding="utf-8") as f:f.write(f"[{stamp}] {msg}\n")print(msg)302 unmodified lines# Build sidebar safelyfeat_types = sorted(meta_df["source_type"].dropna().unique().tolist())selected_types = st.sidebar.multiselect("Feature type", feat_types, default=feat_types)filtered_meta = meta_df[meta_df["source_type"].isin(selected_types)]numeric_cols = df.select_dtypes(include=[np.number]).columns.tolist()# -------------------------# Features tab (robust)# -------------------------with tabs[0]:st.subheader("Feature metadata")st.dataframe(545 unmodified lines# ----- Download tabtabs.append("Download Saved Files")with tabs[-1]:st.subheader(" Download Saved Files (Flat Log Mode)")14 unmodified lines# ----- Logs tabtabs.append("View Logs")with tabs[-1]:st.subheader(" Master Log (append-in-place)")if os.path.exists(LOG_PATH):44 unmodified lines45464748495051302 unmodified lines354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383545 unmodified lines92993093193293393414 unmodified lines94995095195295395444 unmodified linesdef log(msg: str):stamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")with open(LOG_PATH, "a", encoding="utf-8") as f:f.write("\n\n===== New Session Started at {} =====\n".format(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))f.write(f"[{stamp}] {msg}\n")print(msg)302 unmodified lines# Build sidebar safelyfeat_types = sorted(meta_df["source_type"].dropna().unique().tolist())selected_types = st.sidebar.multiselect("Feature type", feat_types, default=feat_types)if "source_type" not in meta_df.columns or meta_df["source_type"].dropna().empty:filtered_meta = meta_df.copy()else:filtered_meta = meta_df[meta_df["source_type"].isin(selected_types)]numeric_cols = df.select_dtypes(include=[np.number]).columns.tolist()# -------------------------# Features tab (robust)# -------------------------tabs = st.tabs(["Features","Visualization","Correlations","Statistics","AutoML + SHAP","Business Impact","Bibliography","Download Saved Files","View Logs"])with tabs[0]:st.subheader("Feature metadata")st.dataframe(545 unmodified lines# ----- Download tabwith tabs[-1]:st.subheader(" Download Saved Files (Flat Log Mode)")14 unmodified lines# ----- Logs tabwith tabs[-1]:st.subheader(" Master Log (append-in-place)")if os.path.exists(LOG_PATH):
src/streamlit_app.py+19-3