完全移除预热(prewarm)功能
- 删除 src/utils/prewarm_dashboard.py - 删除 scripts/prewarm_dashboard_cache.py、prewarm_dashboard_worker.py - docker-compose.yml 移除 polyweather_prewarm 服务 - runtime_coordinator.py 移除预热循环启动逻辑 - web/core.py 移除 prewarm status 上报 - web/routers/system.py 移除 /api/system/prewarm 端点 - web/services/system_api.py 移除 run_system_prewarm - city_runtime.py DEFAULT_PREWARM_CITIES 改名为 DEFAULT_STATUS_CITIES - 清理 env.example、测试、VPS .env 中的预热配置
This commit is contained in:
@@ -6,7 +6,6 @@ import web.routes as routes
|
||||
import web.scan_terminal_cache as scan_terminal_cache
|
||||
import web.scan_terminal_service as scan_terminal_service
|
||||
from web.scan_terminal_cache import scan_terminal_cache_key
|
||||
from src.database.db_manager import DBManager
|
||||
from src.database.runtime_state import TruthRecordRepository, TrainingFeatureRecordRepository
|
||||
|
||||
|
||||
@@ -38,7 +37,6 @@ def test_system_status_returns_summary_shape():
|
||||
assert payload['probability']['rollout']['decision']['decision'] in {'hold', 'observe', 'promote'}
|
||||
assert 'training_data' in payload
|
||||
assert 'station_networks' in payload
|
||||
assert 'prewarm' in payload
|
||||
assert 'truth_records' in payload['training_data']
|
||||
assert 'training_features' in payload['training_data']
|
||||
assert 'city_coverage' in payload['training_data']
|
||||
@@ -46,55 +44,9 @@ def test_system_status_returns_summary_shape():
|
||||
assert 'artifacts' in payload['training_data']
|
||||
assert 'metar_entries' in payload['cache']
|
||||
assert 'nmc_entries' in payload['cache']
|
||||
assert 'runtime' in payload['prewarm']
|
||||
assert 'last_summary_ok' in payload['prewarm']['runtime']
|
||||
assert 'cities_count' in payload
|
||||
|
||||
|
||||
def test_system_status_reads_shared_prewarm_runtime(monkeypatch):
|
||||
monkeypatch.setenv("POLYWEATHER_DASHBOARD_PREWARM_ENABLED", "true")
|
||||
monkeypatch.setenv("POLYWEATHER_PREWARM_INTERVAL_SEC", "300")
|
||||
monkeypatch.setenv("POLYWEATHER_PREWARM_JITTER_SEC", "20")
|
||||
|
||||
DBManager().set_payment_runtime_state(
|
||||
"dashboard_prewarm",
|
||||
{
|
||||
"cycle_count": 3,
|
||||
"success_count": 3,
|
||||
"failure_count": 0,
|
||||
"last_started_at": "2026-04-08T12:00:00",
|
||||
"last_finished_at": "2026-04-08T12:00:05",
|
||||
"last_duration_sec": 5.0,
|
||||
"last_success": True,
|
||||
"last_http_status": 200,
|
||||
"last_error": None,
|
||||
"last_requested_cities": ["shanghai", "beijing"],
|
||||
"last_requested_city_count": 2,
|
||||
"last_include_detail": True,
|
||||
"last_include_market": True,
|
||||
"last_force_refresh": False,
|
||||
"last_warmed_count": 2,
|
||||
"last_summary_ok": 2,
|
||||
"last_detail_ok": 2,
|
||||
"last_market_ok": 2,
|
||||
"last_failed_count": 0,
|
||||
"last_heartbeat_ts": __import__("time").time(),
|
||||
"writer_mode": "standalone_process",
|
||||
"writer_pid": 12345,
|
||||
"writer_thread_name": "MainThread",
|
||||
},
|
||||
)
|
||||
|
||||
response = client.get('/api/system/status')
|
||||
|
||||
assert response.status_code == 200
|
||||
payload = response.json()
|
||||
assert payload["prewarm"]["enabled"] is True
|
||||
assert payload["prewarm"]["thread_alive"] is True
|
||||
assert payload["prewarm"]["runtime"]["cycle_count"] >= 3
|
||||
assert payload["prewarm"]["runtime"]["last_summary_ok"] == 2
|
||||
|
||||
|
||||
def test_metrics_endpoint_returns_prometheus_payload():
|
||||
response = client.get('/metrics')
|
||||
assert response.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user