Skip to content

Commit e022ef2

Browse files
committed
Go CSAPI server compat: uid on datastreams, str Time fields, GeoJSON features lookup, OSH_BASE_URL override
1 parent 04ee03f commit e022ef2

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

publishers/bootstrap_helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,10 @@ def find_by_uid(base_url: str, auth: str, collection: str, uid: str) -> str | No
214214
return _uid_cache[cache_key]
215215

216216
result = api_get(base_url, f"{collection}?uid={uid}", auth)
217-
if result and "items" in result:
218-
for item in result["items"]:
217+
if result:
218+
# Support both GeoJSON (features) and flat JSON (items) collections
219+
items = result.get("items", []) or result.get("features", [])
220+
for item in items:
219221
props = item.get("properties", item)
220222
if props.get("uid") == uid:
221223
item_id = item.get("id") or props.get("id")

publishers/usgs_eq/bootstrap_usgs_eq.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ def _system_sml(config: dict) -> dict:
335335
def _datastream_schema() -> dict:
336336
"""SWE DataRecord schema for earthquake event datastream."""
337337
return {
338+
"uid": "urn:os4csapi:datastream:usgs-eq-feed:earthquakeEvent:v1",
338339
"outputName": DS_OUTPUT_NAME,
339340
"name": "Earthquake Events",
340341
"description": (

publishers/usgs_eq/usgs_eq_publisher.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def parse_earthquake(feature: dict) -> dict | None:
139139
"magnitude": float(mag) if mag is not None else "NaN",
140140
"magType": mag_type or "unknown",
141141
"place": place or "Unknown location",
142-
"eventTime": event_time_ms,
143-
"updatedTime": updated_ms,
142+
"eventTime": str(event_time_ms),
143+
"updatedTime": str(updated_ms),
144144
"latitude": float(lat),
145145
"longitude": float(lon),
146146
"depth_km": float(depth_km) if depth_km is not None else 0.0,
@@ -200,7 +200,10 @@ def __init__(self):
200200

201201
# REST config
202202
import base64
203-
self._base_url = f"https://{self.osh_address}/{self.osh_root}/api"
203+
self._base_url = os.environ.get(
204+
"OSH_BASE_URL",
205+
f"https://{self.osh_address}/{self.osh_root}/api",
206+
)
204207
self._auth = "Basic " + base64.b64encode(
205208
f"{self.osh_user}:{self.osh_pass}".encode()).decode()
206209

0 commit comments

Comments
 (0)