删除env.local;新增漏损区域识别功能
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.services.leakage_identifier import run_leakage_identification
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
class LeakageIdentifyRequest(BaseModel):
|
||||
network: str
|
||||
observed_pressure_data: str | dict[str, list[Any]] | list[dict[str, Any]]
|
||||
start_time: float = 0
|
||||
duration: float = 24
|
||||
timestep: float = 5
|
||||
q_sum: float = 0.2
|
||||
q_sum_unit: str = "m3/s"
|
||||
output_dir: str = "Results"
|
||||
pop_size: int = 50
|
||||
max_gen: int = 100
|
||||
output_flow_unit: str = "m3/s"
|
||||
|
||||
|
||||
@router.post("/identify/")
|
||||
async def identify_leakage(data: LeakageIdentifyRequest) -> dict[str, Any]:
|
||||
try:
|
||||
return run_leakage_identification(**data.dict())
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
@@ -12,6 +12,7 @@ from app.api.v1.endpoints import (
|
||||
misc,
|
||||
risk,
|
||||
cache,
|
||||
leakage,
|
||||
user_management, # 新增:用户管理
|
||||
audit, # 新增:审计日志
|
||||
meta,
|
||||
@@ -83,6 +84,7 @@ api_router.include_router(schemes.router, tags=["Schemes"])
|
||||
api_router.include_router(misc.router, tags=["Misc"])
|
||||
api_router.include_router(risk.router, tags=["Risk"])
|
||||
api_router.include_router(cache.router, tags=["Cache"])
|
||||
api_router.include_router(leakage.router, prefix="/leakage", tags=["Leakage"])
|
||||
|
||||
# Database Routers
|
||||
api_router.include_router(timescaledb_router, tags=["TimescaleDB"])
|
||||
|
||||
Reference in New Issue
Block a user