feat(765-6): 초기값 사본에서 배수 공유 캐시 뺌 · 복원은 노선 몫만 갈음(캐시 제자리) · 복제가 설계 벌 묶음 안 지표면 id 고침

- common_util_initial_snapshot: 배수 사본 = 노선 몫만(하강장 · 도엽 좌표 · 강우 뺌 · 약 105 → 20 MB) · 복원은 폴더 통째 지우지 않음 · 캐시 든 옛 사본의 캐시 칸은 건너뜀
- common_util_project_copy._fix_files(통째 복제 · --replace 같은 길): design_sets/<지형>/ 의 db.json · 그 벌 초기값 · B06 표본 설정 · meta.json 지표면 id → 새 id · 노선 id 는 꺼낼 때 늘 새로 받아 안 고침 · 코리도 안 건드림
- 시험 test_765_design_sets 에 둘 덧

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-03 15:52:46 +09:00
co-authored by Claude Opus 5.5
parent 0dbe4d5f31
commit 9b12d4ff5d
3 changed files with 160 additions and 13 deletions
+50
View File
@@ -517,3 +517,53 @@ def test_비우기에_묶음_포함(tmp_path: Path) -> None:
removed = purge_output_folders(tmp_path, keep_preprocess=True)
assert SETS_DIR in removed and not (tmp_path / SETS_DIR).exists()
assert (tmp_path / "B04_PreProcess" / "models").is_dir()
# ── 765-6 초기값 사본 = 캐시 뺌 · 복제가 묶음 안 지표면 id 고침 ────────────
def test_초기값_사본은_배수_캐시를_빼고_복원은_캐시를_안_지움(tmp_path: Path) -> None:
from common_util import common_util_initial_snapshot as snap
_seed_files(tmp_path)
drainage = tmp_path / "B04_PreProcess" / "drainage"
(drainage / "rainfall_stations").mkdir()
(drainage / "rainfall_stations" / "a.json").write_text("st", encoding="utf-8")
target = tmp_path / "initial_snapshot" / "B04_PreProcess__drainage"
snap._save_drainage(drainage, target)
saved = sorted(p.name for p in target.iterdir())
assert saved == ["01_primary_region.geojson", "edits", "manifest.json"] # 캐시 없음
# 작업본이 바뀜 · 캐시는 새로 지어짐 · 옛 사본(캐시 듦) 꼴도 섞음
(drainage / "01_primary_region.geojson").write_text("edited", encoding="utf-8")
(drainage / "04_detailed_basins.geojson").write_text("new", encoding="utf-8")
(drainage / "descent_ab_cd.npz").write_text("d2", encoding="utf-8")
(target / "00_sheet_metric.pkl").write_text("old-cache", encoding="utf-8")
snap._restore_drainage(target, drainage)
live = {p.name: p for p in drainage.iterdir()}
assert live["01_primary_region.geojson"].read_text(encoding="utf-8") == "{}"
assert "04_detailed_basins.geojson" not in live # 초기값에 없던 노선 몫 = 지움
assert live["descent_ab_cd.npz"].read_text(encoding="utf-8") == "d2" # 캐시 그대로
assert live["00_sheet_metric.pkl"].read_text(encoding="utf-8") == "s" # 옛 사본 캐시 안 덮음
assert (live["rainfall_stations"] / "a.json").is_file()
assert (live["edits"] / "pipe_points.json").is_file()
def test_복제가_묶음_안_지표면_id_고침(tmp_path: Path) -> None:
from common_util.common_util_project_copy import _fix_design_sets
db = _seed_db()
_seed_files(tmp_path)
asyncio.run(sets.park_active_set(_Conn(db), tmp_path, PID, FP))
bundle = tmp_path / SETS_DIR / "las"
corridor = bundle / "files" / "B05_Profile" / "corridor" / "corridor_0011.json"
report = _fix_design_sets(tmp_path, {5: 905})
assert sorted(report["las"]) == ["db.json", "meta.json", "sampling"]
dump = json.loads((bundle / "db.json").read_text(encoding="utf-8"))
assert {r["surface_model_id"] for r in dump["routes"]} == {905}
assert [r["id"] for r in dump["routes"]] == [10, 11] # 노선 id 는 꺼낼 때 새로
assert sets.read_meta(tmp_path, "las")["model_id"] == 905
sampling = bundle / "files" / "B06_Section" / "sampling.json"
assert json.loads(sampling.read_text(encoding="utf-8")) == {"surface_model_id": 905}
assert corridor.is_file() # 코리도는 안 건드림
assert sets.bundle_ready(tmp_path, "las", FP) # 지문은 id 를 안 봄