Skip to content

Commit

Permalink
fix: extra log info on raw-data-api FAILURE response
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Feb 3, 2025
1 parent 8f36035 commit cf9128b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 3 additions & 1 deletion osm_rawdata/pgasync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python3

# Copyright (c) 2024 Humanitarian OpenStreetMap Team
# Copyright (c) Humanitarian OpenStreetMap Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand All @@ -19,6 +19,8 @@
# 1100 13th Street NW Suite 800 Washington, D.C. 20005
# <info@hotosm.org>

# NOTE this module may be out of sync with postgres.py

import argparse
import asyncio
import json
Expand Down
19 changes: 11 additions & 8 deletions osm_rawdata/postgres.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python3

# Copyright (c) 2022, 2023, 2024 Humanitarian OpenStreetMap Team
# Copyright (c) Humanitarian OpenStreetMap Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -580,6 +580,7 @@ def queryRemote(
if response_status == "FAILURE":
# NOTE bug we must override task_info as it's set to a string
task_info = {}
log.error(f"Raw-data-api task FAILURE. Details: {task_query_url}")
break

# response_status options: STARTED, PENDING, SUCCESS
Expand Down Expand Up @@ -749,6 +750,7 @@ def execQuery(
if isinstance(boundary, str):
boundary = json.loads(boundary)

# If multiple geoms are passed, unary_union them
if (geom_type := boundary.get("type")) == "FeatureCollection":
# Convert each feature into a Shapely geometry
geometries = [
Expand All @@ -763,14 +765,15 @@ def execQuery(
else:
merged_geom = shape(boundary)

if isinstance(merged_geom, MultiPolygon):
aoi_shape = MultiPolygon(
[Polygon(poly.exterior) for poly in merged_geom.geoms]
)
elif isinstance(merged_geom, Polygon):
aoi_shape = Polygon(merged_geom.exterior)

if self.dbshell:
# If a multipolygon is passed, attempt a merge
if isinstance(merged_geom, MultiPolygon):
aoi_shape = MultiPolygon(
[Polygon(poly.exterior) for poly in merged_geom.geoms]
)
elif isinstance(merged_geom, Polygon):
aoi_shape = Polygon(merged_geom.exterior)

log.info("Extracting features from Postgres...")
if not customsql:
sql = self.createSQL(self.qc, allgeom)
Expand Down

0 comments on commit cf9128b

Please sign in to comment.