- 고정 자료 fixtures/golden_472(검증_랩탑메인 노선 370 · GET · storage 사본 · 2.98 MB) - 길 넷: 정본(GET) · [저장] 서버 재계산 · 노선 저장 체인(DB 없이) · 브라우저 진짜 단계 묶음(vite ssr) - 값 = 측점 · 열쇠 · x · y · 계획고 · 면적 · 층따기 · 누가토량 · 관 길이 · 종단 경고 · 길마다 0 차 - 두 길 사이 = 알려진 차(R7 · W0 · X2 · W1)만 · 안 나타난 알려진 차도 실패 - 값 다시 뜨기 = helper_472_1_dump.py(손으로만) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
100 lines
4.1 KiB
Python
100 lines
4.1 KiB
Python
"""472-1 고정 자료 · 값 다시 뜨기(사용자 · 브레인 승인 때만 손으로 돌림 — 시험은 다시 안 뜸).
|
|
|
|
./venv/Scripts/python.exe resources/tester/helper_472_1_dump.py # 값만 다시
|
|
./venv/Scripts/python.exe resources/tester/helper_472_1_dump.py --fetch # 고정 자료도
|
|
|
|
--fetch = 검증_랩탑메인(`PROJECT`) 노선 하나를 **읽기만**(GET · storage 파일 사본) —
|
|
쓰기 · 저장 · 지움 없음.
|
|
서버 = 자기 포트(`--base` · 기본 8004) · 로그인 = 메인 폴더 `tmp/aislo_cred.json`(값은 출력 안 함).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import shutil
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
sys.path.insert(0, str(HERE.parents[1]))
|
|
sys.path.insert(0, str(HERE))
|
|
|
|
import helper_472_1_paths as paths # noqa: E402
|
|
|
|
PROJECT = "dad81824-4bb7-41df-ad9c-95c870c2a0dc"
|
|
MAIN = Path("C:/Program_coding/임도설계 및 견적자동화 프로그램 개발")
|
|
#: storage 사본 — 노선 저장 체인 · [저장] 재계산이 읽는 파일만(노선 · 곡선표 · 관 · 설계 지표면).
|
|
STORAGE_FILES = (
|
|
"B05_Profile/route/route_main.geojson",
|
|
"B05_Profile/route/planned_route_initial.csv",
|
|
"B05_Profile/route/planned_route_initial_curves.json",
|
|
"B05_Profile/route/planned_route_initial_nodes.csv",
|
|
"B04_PreProcess/drainage/edits/pipe_points.json",
|
|
paths.NPZ,
|
|
)
|
|
|
|
|
|
def fetch(base: str) -> None:
|
|
import httpx
|
|
|
|
cred = json.loads((MAIN / "tmp" / "aislo_cred.json").read_text(encoding="utf-8"))
|
|
client = httpx.Client(base_url=f"{base}/api", timeout=120)
|
|
login = client.post(
|
|
"/auth/login/request", json={"email": cred["email"], "password": cred["password"]}
|
|
)
|
|
login.raise_for_status()
|
|
get = lambda path: client.get(path).raise_for_status().json() # noqa: E731
|
|
latest = get(f"/projects/{PROJECT}/route/latest")
|
|
route = int(latest["route"]["id"])
|
|
out = {
|
|
"detail.json": get(f"/projects/{PROJECT}/sections/{route}/detail"),
|
|
"summary.json": get(f"/projects/{PROJECT}/sections/{route}"),
|
|
"context.json": get(f"/projects/{PROJECT}/sections/context"),
|
|
"plan.json": get(f"/projects/{PROJECT}/route/plan"),
|
|
"pipes.json": {
|
|
"pipe_points": get(f"/projects/{PROJECT}/drainage/pipe-points")["pipe_points"]
|
|
},
|
|
"structures.json": get(f"/projects/{PROJECT}/route/structures"),
|
|
"plus_stations.json": get(f"/projects/{PROJECT}/section/plus-stations"),
|
|
"structure_types.json": get("/projects/structure-types"),
|
|
"terrain_sources.json": get(f"/projects/{PROJECT}/route/terrain-sources"),
|
|
}
|
|
assert out["context.json"]["route_id"] == route
|
|
paths.FIXTURE.mkdir(parents=True, exist_ok=True)
|
|
for name, body in out.items():
|
|
(paths.FIXTURE / name).write_text(
|
|
json.dumps(body, ensure_ascii=False, separators=(",", ":")), encoding="utf-8"
|
|
)
|
|
project = next((MAIN / "storage").glob(f"*/*/{PROJECT}"))
|
|
for relative in STORAGE_FILES:
|
|
target = paths.FIXTURE / "project" / relative # 폴더 이름 storage = .gitignore
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copy2(project / relative, target)
|
|
|
|
|
|
def dump() -> dict:
|
|
values: dict = {"project_id": PROJECT}
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
for name in paths.PATHS:
|
|
work = Path(tmp) / name
|
|
work.mkdir()
|
|
values[name] = paths.run_path(name, work)
|
|
paths.VALUES.write_text(json.dumps(values, ensure_ascii=False, indent=1), encoding="utf-8")
|
|
return values
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--fetch", action="store_true")
|
|
parser.add_argument("--base", default="http://localhost:8004")
|
|
args = parser.parse_args()
|
|
if args.fetch:
|
|
fetch(args.base)
|
|
got = dump()
|
|
size = sum(p.stat().st_size for p in paths.FIXTURE.rglob("*") if p.is_file())
|
|
print(f"고정 자료 {size / 1e6:.2f} MB")
|
|
for name in paths.PATHS:
|
|
print(name, got[name]["station_count"], got[name]["final_cumulative_m3"])
|