36 lines
1.7 KiB
Python
36 lines
1.7 KiB
Python
import json
|
|
import streamlit as st
|
|
from toolbox.tasks import ROOT, list_tasks, ACTIVE
|
|
from toolbox.validation import SOURCES
|
|
|
|
|
|
def render():
|
|
st.markdown("## MarketGrid 工具箱")
|
|
tasks = list_tasks()
|
|
output = ROOT / "output"
|
|
cols = st.columns(3)
|
|
cols[0].metric("正在运行", sum(t["status"] in ACTIVE for t in tasks))
|
|
cols[1].metric("任务记录", len(tasks))
|
|
cols[2].metric("现有 ZIP 成果", len(list(output.glob("*.zip"))))
|
|
st.markdown("#### 选择工具")
|
|
left, right = st.columns(2)
|
|
with left, st.container(border=True):
|
|
st.markdown("##### 🗺️ 市场网格出图")
|
|
st.write("按市场生成信号图和成果包。")
|
|
st.page_link(st.session_state["pages"]["market"], label="开始出图", icon="➡️")
|
|
with right, st.container(border=True):
|
|
st.markdown("##### 🏢 楼宇数据查询")
|
|
st.write("按坐标批量查询楼宇信息。")
|
|
st.page_link(st.session_state["pages"]["buildings"], label="开始查询", icon="➡️")
|
|
st.markdown("#### 默认数据源")
|
|
st.dataframe([{"数据源": label, "状态": "已就绪" if (ROOT / file).is_file() else "缺失",
|
|
"文件": file, "大小 MB": round((ROOT / file).stat().st_size / 1024**2, 1) if (ROOT / file).is_file() else 0}
|
|
for label, file, _ in SOURCES.values()], hide_index=True, width="stretch")
|
|
summary_path = output / "summary.json"
|
|
if summary_path.exists():
|
|
try:
|
|
data = json.loads(summary_path.read_text(encoding="utf-8"))
|
|
st.caption(f"现有正式成果:{len(data.get('zip_results', []))} 个市场包")
|
|
except (OSError, ValueError) as error:
|
|
st.warning(f"汇总记录无法读取:{error}")
|