Skip to content

Commit e7f792a

Browse files
committed
fix: per-station unique datastream UIDs for Go server bootstraps
1 parent 906ae33 commit e7f792a

6 files changed

Lines changed: 29 additions & 22 deletions

File tree

publishers/aviation_wx/bootstrap_aviation_wx.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def _system_sml(station: dict) -> dict:
320320
}
321321

322322

323-
def _datastream_schema() -> dict:
323+
def _datastream_schema(icao_id: str = "") -> dict:
324324
"""SWE DataRecord schema for METAR observation datastream.
325325
326326
AviationWeather METAR fields:
@@ -336,8 +336,9 @@ def _datastream_schema() -> dict:
336336
cloud_base_ft - Lowest cloud base (feet AGL)
337337
raw_metar - Raw METAR text
338338
"""
339+
uid_suffix = f":{icao_id.lower()}" if icao_id else ""
339340
return {
340-
"uid": "urn:os4csapi:datastream:awx-station:metarObs:v1",
341+
"uid": f"urn:os4csapi:datastream:awx{uid_suffix}:metarObs:v1",
341342
"outputName": DS_OUTPUT_NAME,
342343
"name": "METAR Observation",
343344
"description": (
@@ -532,7 +533,7 @@ def bootstrap(*, clean: bool = False, clean_only: bool = False,
532533

533534
if sys_id or dry_run:
534535
ensure_datastream(base_url, auth, sys_id or "pending", DS_OUTPUT_NAME,
535-
_datastream_schema(),
536+
_datastream_schema(st["icao_id"]),
536537
dry_run=dry_run, stats=stats)
537538

538539
# ── Deployment tree ───────────────────────────────────────────────

publishers/coops/bootstrap_coops.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def _system_sml(station: dict) -> dict:
518518
}
519519

520520

521-
def _datastream_schema() -> dict:
521+
def _datastream_schema(station_id: str = "") -> dict:
522522
"""SWE DataRecord schema for coastal observation datastream.
523523
524524
CO-OPS fields (metric units via API request):
@@ -532,8 +532,9 @@ def _datastream_schema() -> dict:
532532
wind_gust_ms - Wind gust (m/s)
533533
pressure_hpa - Barometric pressure (hPa / mb)
534534
"""
535+
uid_suffix = f":{station_id}" if station_id else ""
535536
return {
536-
"uid": "urn:os4csapi:datastream:coops-station:coopsCoastalObs:v1",
537+
"uid": f"urn:os4csapi:datastream:coops{uid_suffix}:coopsCoastalObs:v1",
537538
"outputName": DS_OUTPUT_NAME,
538539
"name": "Coastal Observation",
539540
"description": (
@@ -747,7 +748,7 @@ def bootstrap(*, clean: bool = False, clean_only: bool = False,
747748

748749
if sys_id or dry_run:
749750
ensure_datastream(base_url, auth, sys_id or "pending", DS_OUTPUT_NAME,
750-
_datastream_schema(),
751+
_datastream_schema(st["id"]),
751752
dry_run=dry_run, stats=stats)
752753

753754
# ── Deployment tree ───────────────────────────────────────────────

publishers/ndbc/bootstrap_ndbc.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def _system_sml(station: dict) -> dict:
416416
}
417417

418418

419-
def _datastream_schema() -> dict:
419+
def _datastream_schema(station_id: str = "") -> dict:
420420
"""SWE DataRecord schema for buoy observation datastream.
421421
422422
NDBC fields (SI units, already in source data):
@@ -435,8 +435,9 @@ def _datastream_schema() -> dict:
435435
PTDY - Pressure tendency (hPa)
436436
TIDE - Water level (ft)
437437
"""
438+
uid_suffix = f":{station_id}" if station_id else ""
438439
return {
439-
"uid": "urn:os4csapi:datastream:ndbc-buoy:ndbcBuoyObs:v1",
440+
"uid": f"urn:os4csapi:datastream:ndbc{uid_suffix}:ndbcBuoyObs:v1",
440441
"outputName": DS_OUTPUT_NAME,
441442
"name": "Buoy Observation",
442443
"description": (
@@ -549,10 +550,11 @@ def _datastream_schema() -> dict:
549550
}
550551

551552

552-
def _buoycam_datastream_schema() -> dict:
553+
def _buoycam_datastream_schema(station_id: str = "") -> dict:
553554
"""SWE DataRecord schema for BuoyCAM image-reference datastream."""
555+
uid_suffix = f":{station_id}" if station_id else ""
554556
return {
555-
"uid": "urn:os4csapi:datastream:ndbc-buoy:ndbcBuoyCamImage:v1",
557+
"uid": f"urn:os4csapi:datastream:ndbc{uid_suffix}:ndbcBuoyCamImage:v1",
556558
"outputName": BUOYCAM_DS_OUTPUT_NAME,
557559
"name": "BuoyCAM Image",
558560
"description": (
@@ -749,14 +751,14 @@ def bootstrap(*, clean: bool = False, clean_only: bool = False,
749751

750752
if sys_id or dry_run:
751753
ensure_datastream(base_url, auth, sys_id or "pending", DS_OUTPUT_NAME,
752-
_datastream_schema(),
754+
_datastream_schema(st["id"]),
753755
dry_run=dry_run, stats=stats)
754756

755757
# BuoyCAM datastream (only for camera-equipped stations)
756758
if st.get("has_buoycam"):
757759
ensure_datastream(base_url, auth, sys_id or "pending",
758760
BUOYCAM_DS_OUTPUT_NAME,
759-
_buoycam_datastream_schema(),
761+
_buoycam_datastream_schema(st["id"]),
760762
dry_run=dry_run, stats=stats)
761763

762764
# ── Deployment tree ───────────────────────────────────────────────

publishers/nws/bootstrap_nws.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,15 @@ def _system_sml(station: dict) -> dict:
334334
}
335335

336336

337-
def _datastream_schema() -> dict:
337+
def _datastream_schema(station_id: str = "") -> dict:
338338
"""SWE DataRecord schema for surface observation datastream.
339339
340340
Format must match CSAPI POST systems/{id}/datastreams spec:
341341
{ name, outputName, schema: { obsFormat, resultSchema: { ... } } }
342342
"""
343+
uid_suffix = f":{station_id}" if station_id else ""
343344
return {
344-
"uid": "urn:os4csapi:datastream:nws-station:nwsSurfaceObs:v1",
345+
"uid": f"urn:os4csapi:datastream:nws{uid_suffix}:nwsSurfaceObs:v1",
345346
"outputName": DS_OUTPUT_NAME,
346347
"name": "Surface Observation",
347348
"description": (
@@ -528,7 +529,7 @@ def bootstrap(*, clean: bool = False, clean_only: bool = False,
528529

529530
if sys_id or dry_run:
530531
ensure_datastream(base_url, auth, sys_id or "pending", DS_OUTPUT_NAME,
531-
_datastream_schema(),
532+
_datastream_schema(st["id"]),
532533
dry_run=dry_run, stats=stats)
533534

534535
# ── Deployment tree ───────────────────────────────────────────────

publishers/usgs_nims/bootstrap_usgs_nims.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def _imagery_datastream_schema(cam: dict) -> dict:
213213
timelapse_enabled = cam.get("TL_enabled", False)
214214

215215
return {
216-
"uid": "urn:os4csapi:datastream:usgs-nims:usgsNimsImage:v1",
216+
"uid": f"urn:os4csapi:datastream:usgs-nims:{cam_id}:usgsNimsImage:v1",
217217
"outputName": DS_OUTPUT_NAME,
218218
"name": "NIMS Station Image",
219219
"description": (

publishers/usgs_water/bootstrap_usgs_water.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,11 @@ def _system_sml(station: dict) -> dict:
528528
}
529529

530530

531-
def _discharge_datastream_schema() -> dict:
531+
def _discharge_datastream_schema(site_no: str = "") -> dict:
532532
"""SWE DataRecord schema for the discharge (streamflow) datastream."""
533+
uid_suffix = f":{site_no}" if site_no else ""
533534
return {
534-
"uid": "urn:os4csapi:datastream:usgs-water:usgsDischarge:v1",
535+
"uid": f"urn:os4csapi:datastream:usgs-water{uid_suffix}:usgsDischarge:v1",
535536
"outputName": DS_DISCHARGE_OUTPUT,
536537
"name": "Discharge",
537538
"description": (
@@ -596,10 +597,11 @@ def _discharge_datastream_schema() -> dict:
596597
}
597598

598599

599-
def _gage_height_datastream_schema() -> dict:
600+
def _gage_height_datastream_schema(site_no: str = "") -> dict:
600601
"""SWE DataRecord schema for the gage height (water level) datastream."""
602+
uid_suffix = f":{site_no}" if site_no else ""
601603
return {
602-
"uid": "urn:os4csapi:datastream:usgs-water:usgsGageHeight:v1",
604+
"uid": f"urn:os4csapi:datastream:usgs-water{uid_suffix}:usgsGageHeight:v1",
603605
"outputName": DS_GAGE_HEIGHT_OUTPUT,
604606
"name": "Gage Height",
605607
"description": (
@@ -838,14 +840,14 @@ def bootstrap(*, clean: bool = False, clean_only: bool = False,
838840
if "00060" in st.get("parameterCodes", []):
839841
ensure_datastream(base_url, auth, sys_id or "pending",
840842
DS_DISCHARGE_OUTPUT,
841-
_discharge_datastream_schema(),
843+
_discharge_datastream_schema(st["id"]),
842844
dry_run=dry_run, stats=stats)
843845

844846
# Create gage height datastream
845847
if "00065" in st.get("parameterCodes", []):
846848
ensure_datastream(base_url, auth, sys_id or "pending",
847849
DS_GAGE_HEIGHT_OUTPUT,
848-
_gage_height_datastream_schema(),
850+
_gage_height_datastream_schema(st["id"]),
849851
dry_run=dry_run, stats=stats)
850852

851853
# -- Deployment tree --

0 commit comments

Comments
 (0)