diff --git a/common_util/common_util_lidar_upload.py b/common_util/common_util_lidar_upload.py index dd9f37985..bbb471da7 100644 --- a/common_util/common_util_lidar_upload.py +++ b/common_util/common_util_lidar_upload.py @@ -185,7 +185,12 @@ def drop_stale_filters(base: Path, built: list[str]) -> list[str]: *(processed / name for name in (f"mask_{key}.npy", f"ground_points_{key}.npz")), processed / f"preview_points_{key}.bin", ] + # 지은 필터가 이 이름을 앞머리로 품으면(`classification` ⊂ `classification_refine` · 766) + # 그 파일은 지은 필터 것 — 남김 + longer = [b for b in built if b.startswith(f"{key}_")] for path in paths: + if any(f"_{b}." in path.name or f"_{b}_" in path.name for b in longer): + continue if path.is_file(): path.unlink() if path.parent == models and path.suffix == ".npz": diff --git a/resources/tester/test_637_lidar.py b/resources/tester/test_637_lidar.py index baa43d32e..ec27bcea6 100644 --- a/resources/tester/test_637_lidar.py +++ b/resources/tester/test_637_lidar.py @@ -262,9 +262,28 @@ def test_B_뿌리_짓기_수치지형도_그대로_덮임(tmp_path: Path, monkey kept = _route_build(tmp_path, monkeypatch, [[200010, 500010], [200020, 500020]], target) assert kept["meta"]["selection"] == target assert {m["source_filter"] for m in kept["models"]} == {"classification"} - # 갈음 = 안 지은 필터(앞서 자동으로 지은 csf)는 옛 LAS 것 → 지움 · 수치지형도 그대로(637-3) - assert "B04_PreProcess/models/dtm_ptd.npz" in kept["dropped"] - assert not list((tmp_path / b05.MODELS).glob("*_csf*")) and sheet.read_bytes() == b"sheet" + # 갈음 = 안 지은 필터(앞서 자동으로 지은 다듬기 필터 · 766 기본)는 옛 LAS 것 → 지움 · + # 수치지형도 그대로(637-3) + assert "B04_PreProcess/models/dtm_ptd_refine.npz" in kept["dropped"] + assert not list((tmp_path / b05.MODELS).glob("*_refine*.npz")) and sheet.read_bytes() == b"sheet" + + +def test_옛_필터_지우기는_긴_이름_지은_필터를_안_건드림(tmp_path: Path) -> None: + """`classification` 을 지울 때 지은 `classification_refine` 모델은 남김(766 · 이음매).""" + models = tmp_path / "B04_PreProcess" / "models" + models.mkdir(parents=True) + names = [ + "dtm_classification.npz", + "dtm_classification_refine.npz", + "implicit_classification_refine_grid.npz", + "contour_classification_refine_dtm_1.0m.json", + "contour_classification_dtm_1.0m.json", + ] + for name in names: + (models / name).write_bytes(b"x") + gone = lidar_upload.drop_stale_filters(tmp_path, ["classification_refine"]) + assert gone == ["B04_PreProcess/models/dtm_classification.npz"] + assert sorted(p.name for p in models.iterdir()) == sorted(n for n in names if "refine" in n) def _stamps(root: Path) -> dict[str, str]: