mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
Add WMO weather_code from Open-Meteo to derive sky conditions (sunny/cloudy/foggy/storm) and infer snow type (powder/hard/wet/spring) from temperature and snowfall data. Both fields flow through the full pipeline: weather API, hybrid predictor, SQLite storage, REST API schemas, Telegram bot messages, and scheduler tasks.
114 lines
2.7 KiB
Python
114 lines
2.7 KiB
Python
"""Pydantic response models for the SkiPredictor REST API."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# -- Stations ---------------------------------------------------------------
|
|
|
|
class StationInfo(BaseModel):
|
|
station_id: str
|
|
name: str
|
|
max_km: float
|
|
latitude: float
|
|
longitude: float
|
|
altitude: int
|
|
wind_closure_threshold_kmh: int
|
|
min_snow_depth_cm: int
|
|
|
|
|
|
class StationsResponse(BaseModel):
|
|
stations: list[StationInfo]
|
|
|
|
|
|
# -- Forecasts ---------------------------------------------------------------
|
|
|
|
class DayForecast(BaseModel):
|
|
date: str
|
|
open_probability: float | None = None
|
|
open_label: str | None = None
|
|
km_open: float | None = None
|
|
max_km: float | None = None
|
|
crowd_level: str | None = None
|
|
sky_condition: str | None = None
|
|
snow_type: str | None = None
|
|
weather_summary: str | None = None
|
|
rule_notes: list[str] = Field(default_factory=list)
|
|
prediction_source: str | None = None
|
|
|
|
|
|
class StationForecast(BaseModel):
|
|
station_id: str
|
|
name: str
|
|
days: list[DayForecast]
|
|
|
|
|
|
class ForecastAllResponse(BaseModel):
|
|
generated_at: str | None = None
|
|
run_hour: int | None = None
|
|
stations: dict[str, StationForecast]
|
|
|
|
|
|
class ForecastStationResponse(BaseModel):
|
|
generated_at: str | None = None
|
|
run_hour: int | None = None
|
|
station_id: str
|
|
name: str
|
|
days: list[DayForecast]
|
|
|
|
|
|
# -- Forecast history --------------------------------------------------------
|
|
|
|
class ForecastHistoryRun(BaseModel):
|
|
generated_at: str
|
|
run_hour: int
|
|
prediction_date: str
|
|
station_id: str
|
|
open_probability: float | None = None
|
|
km_open: float | None = None
|
|
crowd_level: str | None = None
|
|
prediction_source: str | None = None
|
|
|
|
|
|
class ForecastHistoryResponse(BaseModel):
|
|
total: int
|
|
limit: int
|
|
offset: int
|
|
runs: list[ForecastHistoryRun]
|
|
|
|
|
|
# -- System ------------------------------------------------------------------
|
|
|
|
class HealthResponse(BaseModel):
|
|
status: str
|
|
timestamp: str
|
|
|
|
|
|
class StatusResponse(BaseModel):
|
|
last_forecast_run: str | None = None
|
|
next_forecast_run: str | None = None
|
|
last_training_run: str | None = None
|
|
next_training_run: str | None = None
|
|
models: dict[str, str] = Field(default_factory=dict)
|
|
telegram_bot_active: bool = False
|
|
stations_count: int = 0
|
|
database_size_mb: float = 0.0
|
|
|
|
|
|
# -- Auth -------------------------------------------------------------------
|
|
|
|
class UserCreate(BaseModel):
|
|
email: str = Field(..., min_length=3)
|
|
password: str = Field(..., min_length=8)
|
|
|
|
|
|
class UserResponse(BaseModel):
|
|
id: int
|
|
email: str
|
|
|
|
|
|
class TokenResponse(BaseModel):
|
|
access_token: str
|
|
token_type: str = "bearer"
|