feat: add observation collector and source gate
This commit is contained in:
@@ -15,6 +15,7 @@ from typing import Any, Dict, Optional
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from src.data_collection.observation_source_gate import run_observation_source
|
||||
from src.utils.metrics import record_source_call
|
||||
|
||||
AMOS_BASE_URL = os.getenv("AMOS_BASE_URL", "").strip() or "https://global.amo.go.kr/amosobsnew/AmosRealTimeImage.do"
|
||||
@@ -469,6 +470,26 @@ class AmosStationSourceMixin:
|
||||
self,
|
||||
city: str,
|
||||
use_fahrenheit: bool = False,
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
city_key = str(city or "").strip().lower()
|
||||
interval_sec = max(
|
||||
30,
|
||||
int(os.getenv("POLYWEATHER_OBSERVATION_COLLECTOR_AMOS_SEC", "60") or "60"),
|
||||
)
|
||||
return run_observation_source(
|
||||
"amos",
|
||||
city_key,
|
||||
interval_sec,
|
||||
lambda: self._fetch_amos_official_current_uncached(
|
||||
city_key,
|
||||
use_fahrenheit=use_fahrenheit,
|
||||
),
|
||||
)
|
||||
|
||||
def _fetch_amos_official_current_uncached(
|
||||
self,
|
||||
city: str,
|
||||
use_fahrenheit: bool = False,
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Fetch AMOS runway-level observations for Seoul or Busan.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user