Support runtime EMOS auto-retrain outputs

This commit is contained in:
2569718930@qq.com
2026-04-19 04:16:12 +08:00
parent 7c3b8ec459
commit 260550763f
3 changed files with 43 additions and 3 deletions
+3
View File
@@ -60,6 +60,9 @@ POLYWEATHER_EMOS_AUTO_MIN_SAMPLES=50
POLYWEATHER_EMOS_AUTO_MAX_DELTA_CRPS=0
POLYWEATHER_EMOS_AUTO_MAX_DELTA_MAE=0.05
POLYWEATHER_EMOS_AUTO_MIN_DELTA_BUCKET_HIT_RATE=-0.05
# Optional: set this to a writable runtime path if you want auto retrain to
# promote new EMOS parameters without rebuilding the image.
# POLYWEATHER_PROBABILITY_CALIBRATION_FILE=/var/lib/polyweather/probability_calibration/default.json
POLYWEATHER_LGBM_ENABLED=false
POLYWEATHER_LGBM_MODEL_PATH=/app/artifacts/models/lgbm_daily_high.txt
POLYWEATHER_LGBM_SCHEMA_PATH=/app/artifacts/models/lgbm_daily_high_schema.json
+26 -1
View File
@@ -117,7 +117,13 @@ python scripts\auto_retrain_probability_calibration.py
候选产物默认写入:
```text
artifacts/probability_calibration/candidates/<version>/
/var/lib/polyweather/probability_calibration/candidates/<version>/
```
最新自动训练报告默认写入:
```text
/var/lib/polyweather/probability_calibration/auto_retrain_report.json
```
允许门禁通过后自动发布:
@@ -146,12 +152,31 @@ Docker 手动触发:
docker compose exec -T polyweather_web python scripts/auto_retrain_probability_calibration.py
```
查看最新报告:
```text
docker compose exec -T polyweather_web cat /var/lib/polyweather/probability_calibration/auto_retrain_report.json
```
Docker 允许门禁发布:
```text
docker compose exec -T polyweather_web python scripts/auto_retrain_probability_calibration.py --promote-if-passed --run-tests
```
如果希望自动发布不需要重建镜像,需要在 `.env` 中指定可写参数文件:
```text
POLYWEATHER_PROBABILITY_CALIBRATION_FILE=/var/lib/polyweather/probability_calibration/default.json
```
首次启用该路径前,先用当前镜像内置参数初始化一次:
```text
docker compose exec -T polyweather_web mkdir -p /var/lib/polyweather/probability_calibration
docker compose exec -T polyweather_web cp /app/artifacts/probability_calibration/default.json /var/lib/polyweather/probability_calibration/default.json
```
建议后续挂到宿主机 `cron` 或 systemd timer
```text
@@ -15,8 +15,20 @@ from src.analysis.probability_calibration import DEFAULT_CALIBRATION_FILE # noq
ARTIFACT_DIR = os.path.join(PROJECT_ROOT, "artifacts", "probability_calibration")
DEFAULT_CANDIDATE_ROOT = os.path.join(ARTIFACT_DIR, "candidates")
DEFAULT_DECISION_REPORT = os.path.join(ARTIFACT_DIR, "auto_retrain_report.json")
def _runtime_calibration_dir() -> str:
runtime_dir = str(os.getenv("POLYWEATHER_RUNTIME_DATA_DIR") or "").strip()
if runtime_dir:
return os.path.join(runtime_dir, "probability_calibration")
return ARTIFACT_DIR
DEFAULT_CANDIDATE_ROOT = os.path.join(_runtime_calibration_dir(), "candidates")
DEFAULT_DECISION_REPORT = os.path.join(
_runtime_calibration_dir(),
"auto_retrain_report.json",
)
def _sf(value: Any) -> Optional[float]: