mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Raise PostcodeNotFound for an unusable postcode 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
49becf1ada
commit
66b776e0aa
1 changed files with 8 additions and 2 deletions
|
|
@ -10,7 +10,10 @@ from datatypes.epc.domain.historic_epc_matching import (
|
|||
_map_historic_epc_pandas_row_to_domain,
|
||||
_sanitise_postcode,
|
||||
)
|
||||
from repositories.historic_epc.historic_epc_repository import HistoricEpcRepository
|
||||
from repositories.historic_epc.historic_epc_repository import (
|
||||
HistoricEpcRepository,
|
||||
PostcodeNotFound,
|
||||
)
|
||||
from utils.s3 import parse_s3_uri, read_csv_gz_from_s3
|
||||
|
||||
DEFAULT_S3_ROOT = "s3://retrofit-data-dev/historical_epc"
|
||||
|
|
@ -33,7 +36,10 @@ class HistoricEpcS3Repository(HistoricEpcRepository):
|
|||
self._s3_root = s3_root
|
||||
|
||||
def get_for_postcode(self, postcode: str) -> list[HistoricEpc]:
|
||||
pc = _sanitise_postcode(postcode)
|
||||
try:
|
||||
pc = _sanitise_postcode(postcode)
|
||||
except ValueError as e:
|
||||
raise PostcodeNotFound(str(e)) from e
|
||||
bucket, root_prefix = parse_s3_uri(self._s3_root)
|
||||
key = f"{root_prefix.rstrip('/')}/{pc}/data.csv.gz"
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue