fix: close Walloon terrain provisioning
GeoIntel release gates / Compile, test, contracts and builds (push) Canceled after 0s
GeoIntel release gates / Python and npm vulnerability policy (push) Canceled after 0s
GeoIntel release gates / GIS image, SBOM and container scan (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-22 08:02:58 +02:00
parent 6808f3a12e
commit cc1b905ed3
7 changed files with 113 additions and 22 deletions
+22 -11
View File
@@ -56,12 +56,27 @@ class SpwTerrainService:
def _source_path(settings: Settings) -> Path:
return Path(settings.spw_terrain_source_dir) / SpwTerrainService.SOURCE_FILENAME
@staticmethod
def _source_sha256(settings: Settings) -> str | None:
checksum_path = (
Path(settings.spw_terrain_source_dir)
/ SpwTerrainService.SOURCE_SHA256_FILENAME
)
if not checksum_path.is_file():
return None
parts = checksum_path.read_text(encoding="ascii").strip().split()
digest = parts[0].lower() if parts else ""
if len(digest) != 64 or any(character not in "0123456789abcdef" for character in digest):
return None
return digest
@staticmethod
def list_products(*, settings: Settings | None = None) -> list[dict[str, Any]]:
resolved = settings or get_settings()
configured = (
resolved.spw_terrain_enabled
and SpwTerrainService._source_path(resolved).is_file()
and SpwTerrainService._source_sha256(resolved) is not None
)
product = SpwTerrainProductRead(
key=SpwTerrainService.PRODUCT_KEY,
@@ -338,12 +353,16 @@ class SpwTerrainService:
status_code=503,
)
source_path = SpwTerrainService._source_path(resolved)
if not source_path.is_file():
source_sha256 = SpwTerrainService._source_sha256(resolved)
if not source_path.is_file() or source_sha256 is None:
raise AppError(
code="SPW_TERRAIN_SOURCE_NOT_PROVISIONED",
message="The official SPW MNT source archive has not been provisioned on this runtime",
message="The official SPW MNT source and checksum have not been provisioned on this runtime",
details={
"expected_path": str(source_path),
"expected_checksum_path": str(
source_path.with_name(SpwTerrainService.SOURCE_SHA256_FILENAME)
),
"operator_command": "python scripts/provision_spw_terrain_source.py",
},
status_code=503,
@@ -390,14 +409,6 @@ class SpwTerrainService:
content, validation = SpwTerrainService._read_source_window(
source_path, scope, resolution, resolved
)
source_sha256_path = source_path.with_name(
SpwTerrainService.SOURCE_SHA256_FILENAME
)
source_sha256 = (
source_sha256_path.read_text(encoding="ascii").strip().split()[0]
if source_sha256_path.is_file()
else None
)
acquired_at = datetime.now(UTC)
dataset = DatasetService.import_raster_bytes(
db,
@@ -410,7 +421,7 @@ class SpwTerrainService:
observed_at=datetime(2022, 3, 5, 23, 59, 59, tzinfo=UTC),
valid_from=datetime(2021, 2, 19, tzinfo=UTC),
valid_to=datetime(2022, 3, 5, 23, 59, 59, tzinfo=UTC),
temporal_granularity="acquisition_period",
temporal_granularity="period",
source_version="RELIEF_WALLONIE_MNT_1M_2021_2022",
source_metadata={
"provider": SpwTerrainService.PROVIDER,