Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +12 -9
src/streamlit_app.py
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import xml.etree.ElementTree as ET
|
| 3 |
import networkx as nx
|
| 4 |
import streamlit.components.v1 as components
|
| 5 |
import json
|
| 6 |
-
import os
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 10 |
-
file_path = os.path.join(current_dir, "ISO15288_Archi_Import.xml")
|
| 11 |
|
| 12 |
# Page configuration
|
| 13 |
st.set_page_config(page_title="ISO 15288 Analyzer", layout="wide")
|
|
@@ -197,7 +193,6 @@ def render_mermaid(mermaid_code, nodes_json):
|
|
| 197 |
</body>
|
| 198 |
</html>
|
| 199 |
"""
|
| 200 |
-
# Restored to 800px standard height without forcing 100vw overrides
|
| 201 |
components.html(html_code, height=800, scrolling=False)
|
| 202 |
|
| 203 |
@st.cache_data
|
|
@@ -287,14 +282,22 @@ def graph_to_mermaid_and_data(G, nodes_to_include, edges_to_include):
|
|
| 287 |
|
| 288 |
return "\n".join(lines), json.dumps(nodes_data)
|
| 289 |
|
| 290 |
-
#
|
| 291 |
try:
|
| 292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
U = G.to_undirected()
|
| 294 |
sorted_process_names = sorted(list(processes.values()))
|
| 295 |
except FileNotFoundError:
|
| 296 |
-
|
|
|
|
| 297 |
st.stop()
|
|
|
|
| 298 |
|
| 299 |
# UI Setup
|
| 300 |
mode = st.radio(
|
|
|
|
| 1 |
+
import os
|
| 2 |
import streamlit as st
|
| 3 |
import xml.etree.ElementTree as ET
|
| 4 |
import networkx as nx
|
| 5 |
import streamlit.components.v1 as components
|
| 6 |
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Page configuration
|
| 9 |
st.set_page_config(page_title="ISO 15288 Analyzer", layout="wide")
|
|
|
|
| 193 |
</body>
|
| 194 |
</html>
|
| 195 |
"""
|
|
|
|
| 196 |
components.html(html_code, height=800, scrolling=False)
|
| 197 |
|
| 198 |
@st.cache_data
|
|
|
|
| 282 |
|
| 283 |
return "\n".join(lines), json.dumps(nodes_data)
|
| 284 |
|
| 285 |
+
# --- ИЗМЕНЕННЫЙ БЛОК: Поиск файла относительно самого скрипта ---
|
| 286 |
try:
|
| 287 |
+
# Вычисляем абсолютный путь к папке, где запущен этот python-скрипт
|
| 288 |
+
current_script_dir = os.path.dirname(os.path.abspath(__file__))
|
| 289 |
+
|
| 290 |
+
# Формируем полный путь к XML, который лежит в той же папке
|
| 291 |
+
xml_file_path = os.path.join(current_script_dir, "ISO15288_Archi_Import.xml")
|
| 292 |
+
|
| 293 |
+
G, processes = load_and_parse_xml(xml_file_path)
|
| 294 |
U = G.to_undirected()
|
| 295 |
sorted_process_names = sorted(list(processes.values()))
|
| 296 |
except FileNotFoundError:
|
| 297 |
+
# В ошибке выводим полный путь, чтобы в логах Hugging Face было видно, где именно он искал файл
|
| 298 |
+
st.error(f"File 'ISO15288_Archi_Import.xml' not found. Looked at: {xml_file_path}")
|
| 299 |
st.stop()
|
| 300 |
+
# ----------------------------------------------------------------
|
| 301 |
|
| 302 |
# UI Setup
|
| 303 |
mode = st.radio(
|