Bootstrap missing training actual history
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import web.training_settlement_service as training_settlement_service
|
||||
from web.training_settlement_service import run_training_settlement_cycle
|
||||
|
||||
|
||||
@@ -75,3 +76,25 @@ def test_training_settlement_cycle_skips_reconcile_for_non_reconcile_sources():
|
||||
assert calls["analysis"] == ["taipei"]
|
||||
assert calls["reconcile"] == []
|
||||
assert result["items"][0]["reconcile"]["reason"] == "unsupported_reconcile_source"
|
||||
|
||||
|
||||
def test_default_actual_reconciler_bootstraps_missing_history(monkeypatch):
|
||||
calls = []
|
||||
|
||||
def bootstrapper(city, *, lookback_days):
|
||||
calls.append((city, lookback_days))
|
||||
return {"ok": True, "seeded": 8, "updated": 8}
|
||||
|
||||
monkeypatch.setattr(
|
||||
training_settlement_service,
|
||||
"bootstrap_recent_daily_history_if_missing",
|
||||
bootstrapper,
|
||||
)
|
||||
|
||||
result = training_settlement_service._default_actual_reconciler(
|
||||
"shanghai",
|
||||
lookback_days=10,
|
||||
)
|
||||
|
||||
assert result == {"ok": True, "seeded": 8, "updated": 8}
|
||||
assert calls == [("shanghai", 10)]
|
||||
|
||||
@@ -6,7 +6,7 @@ from typing import Any, Callable, Dict, Iterable, Mapping, Optional, Sequence
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from src.analysis.deb_algorithm import reconcile_recent_actual_highs
|
||||
from src.analysis.deb_algorithm import bootstrap_recent_daily_history_if_missing
|
||||
from src.data_collection.city_registry import CITY_REGISTRY
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ def _default_analysis_runner(city: str) -> Mapping[str, Any]:
|
||||
|
||||
|
||||
def _default_actual_reconciler(city: str, *, lookback_days: int) -> Mapping[str, Any]:
|
||||
return reconcile_recent_actual_highs(city, lookback_days=lookback_days)
|
||||
return bootstrap_recent_daily_history_if_missing(city, lookback_days=lookback_days)
|
||||
|
||||
|
||||
def run_training_settlement_cycle(
|
||||
|
||||
Reference in New Issue
Block a user