mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Return empty list for a postcode with no historic EPC shard 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6a095a2cf2
commit
88f4739ce8
1 changed files with 7 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
from collections.abc import Callable
|
||||
|
||||
import pandas as pd
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
from datatypes.epc.domain.historic_epc import HistoricEpc
|
||||
from datatypes.epc.domain.historic_epc_matching import (
|
||||
|
|
@ -35,5 +36,10 @@ class HistoricEpcS3Repository(HistoricEpcRepository):
|
|||
pc = _sanitise_postcode(postcode)
|
||||
bucket, root_prefix = parse_s3_uri(self._s3_root)
|
||||
key = f"{root_prefix.rstrip('/')}/{pc}/data.csv.gz"
|
||||
df = self._read_csv_gz(bucket, key)
|
||||
try:
|
||||
df = self._read_csv_gz(bucket, key)
|
||||
except ClientError as e:
|
||||
if e.response.get("Error", {}).get("Code") in ("NoSuchKey", "404"):
|
||||
return []
|
||||
raise
|
||||
return [_map_historic_epc_pandas_row_to_domain(row) for _, row in df.iterrows()]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue