Model/backend/condition/local_runner.py
2026-02-04 12:14:42 +00:00

41 lines
1.2 KiB
Python

from pathlib import Path
from backend.condition.lookups.uprn_lookup_csv import UprnLookupLocal
from backend.condition.processor import process_file
def main() -> None:
try:
# Works in scripts / debugger / pytest
ROOT_DIR = Path(__file__).resolve().parents[1]
except NameError:
# __file__ is not defined in notebooks
ROOT_DIR = Path.cwd()
path: Path = ROOT_DIR / "condition" / "sample_data"
# TODO: get these from s3, maybe as part of devcontainer init
lbwf_path: Path = path / "lbwf" / "LBWF - Example Asset Data September 2025.xlsx"
peabody_path: Path = (
path
/ "peabody"
/ "2026_01_06 - Peabody - Stock Condition Data - Survey Records - D Lower.xlsx"
)
peabody_uprn_lookup_path: Path = (
path / "peabody" / "PeabodyPropertymatched_Dec25_propref_UPRN.csv"
)
# filepaths = [lbwf_path, peabody_path]
# filepaths = [lbwf_path]
filepaths = [peabody_path]
uprn_lookup = UprnLookupLocal(csv_path=peabody_uprn_lookup_path.as_posix())
for fp in filepaths:
with fp.open("rb") as f:
process_file(
file_stream=f, source_key=fp.as_posix(), uprn_lookup=uprn_lookup
)
if __name__ == "__main__":
main()