38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
from pathlib import Path
|
|
import streamlit as st
|
|
from toolbox.tasks import ROOT, list_tasks, ACTIVE
|
|
from toolbox.validation import SOURCES
|
|
|
|
|
|
def _result_zip_count(tasks):
|
|
total = 0
|
|
for task in tasks:
|
|
directory = Path(task["output"])
|
|
if not directory.exists():
|
|
continue
|
|
total += sum(1 for path in directory.glob("*.zip") if path.is_file())
|
|
return total
|
|
|
|
|
|
def render():
|
|
st.markdown("## MarketGrid 工具箱")
|
|
tasks = list_tasks()
|
|
cols = st.columns(3)
|
|
cols[0].metric("正在运行", sum(t["status"] in ACTIVE for t in tasks))
|
|
cols[1].metric("任务记录", len(tasks))
|
|
cols[2].metric("成果包", _result_zip_count(tasks))
|
|
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")
|