更新前端看板
This commit is contained in:
@@ -255,10 +255,21 @@ async def _fine_tune_preflight_with_job_payload(
|
||||
|
||||
@router.post("/login")
|
||||
async def login(payload: dict[str, Any] = Body(...)) -> dict[str, Any]:
|
||||
user = get_platform_store().login(payload.get("username", ""), payload.get("password", ""))
|
||||
store = get_platform_store()
|
||||
user = store.login(payload.get("username", ""), payload.get("password", ""))
|
||||
if not user:
|
||||
raise fail(401, "invalid username or password")
|
||||
return ok({"token": f"platform-token-{user['id']}", "user": user})
|
||||
sess = store.create_session(user["id"])
|
||||
return ok({"token": f"platform-token-{user['id']}", "user": user, "session_id": sess["session_id"]})
|
||||
|
||||
|
||||
@router.post("/logout")
|
||||
async def logout(payload: dict[str, Any] = Body(...)) -> dict[str, Any]:
|
||||
store = get_platform_store()
|
||||
session_id = payload.get("session_id", "")
|
||||
if session_id:
|
||||
store.finish_session(session_id)
|
||||
return ok(None)
|
||||
|
||||
|
||||
@router.get("/me")
|
||||
@@ -388,37 +399,23 @@ async def dashboard_stats() -> dict[str, Any]:
|
||||
for t in tasks[:8]
|
||||
]
|
||||
|
||||
# 用户操作分布:统计平台全部操作(含治理模块)
|
||||
# 用户操作分布:仅统计 模型推理 / 模型训练 / 模型评测 / 数据处理 四类
|
||||
MODULE_LABELS = [
|
||||
("data-process", "数据处理"),
|
||||
("data_process", "数据处理"),
|
||||
("dataset", "数据集管理"),
|
||||
("dataset", "数据处理"),
|
||||
("fine-tune", "模型训练"),
|
||||
("fine_tune", "模型训练"),
|
||||
("model-eval", "模型评测"),
|
||||
("eval", "模型评测"),
|
||||
("model-inference", "模型推理"),
|
||||
("inference", "模型推理"),
|
||||
("model-manage", "模型管理"),
|
||||
("model", "模型管理"),
|
||||
("trained", "模型管理"),
|
||||
# 治理模块操作
|
||||
("tenant", "租户与项目"),
|
||||
("project", "租户与项目"),
|
||||
("approval", "租户与项目"),
|
||||
("acl", "租户与项目"),
|
||||
("user", "用户管理"),
|
||||
("role", "用户管理"),
|
||||
]
|
||||
OP_ORDER = [
|
||||
"数据集管理",
|
||||
"数据处理",
|
||||
"模型训练",
|
||||
"模型评测",
|
||||
"模型推理",
|
||||
"模型管理",
|
||||
"租户与项目",
|
||||
"用户管理",
|
||||
]
|
||||
|
||||
def _op_module(action: str) -> str | None:
|
||||
@@ -451,8 +448,8 @@ async def dashboard_stats() -> dict[str, Any]:
|
||||
for u in recent
|
||||
]
|
||||
|
||||
# 登录时长排行(本月)
|
||||
login_duration_rank = store.login_duration_rank()
|
||||
# 登录时长排行(本月),只取 top 5
|
||||
login_duration_rank = store.login_duration_rank(limit=5)
|
||||
|
||||
return ok(
|
||||
{
|
||||
|
||||
@@ -297,9 +297,9 @@ class PlatformStore:
|
||||
# TCP keepalive 让操作系统持续保活连接,抵抗远程库空闲静默断连。
|
||||
pool_kwargs = {
|
||||
"keepalives": 1,
|
||||
"keepalives_idle": 30,
|
||||
"keepalives_interval": 10,
|
||||
"keepalives_count": 5,
|
||||
"keepalives_idle": 10,
|
||||
"keepalives_interval": 5,
|
||||
"keepalives_count": 3,
|
||||
}
|
||||
self._pool = ConnectionPool(
|
||||
conninfo=self.database_url,
|
||||
|
||||
Reference in New Issue
Block a user