mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
- Remove references to deprecated bot commands (/pajares, /sanisidro, /fuentes, /all) - Document new /suscribir and /desuscribir subscription commands - Add push notification system description and usage - Document admin accuracy reports with environment variable setup - Add sky_condition and snow_type fields to API spec and database schema - Update scheduled task description (training day changed from Monday to Sunday) - Add notification_subscribers table to schema - Update DEPLOYMENT.md with ADMIN_TELEGRAM_IDS environment variable - Mark completed milestones in TODO.md
2.8 KiB
2.8 KiB
Ski Predictor - Deployment and Operations Guide
Quick Start
git clone https://git.dariosevilla.es/dasemu/skipredictor.git
cd skipredictor
./start.sh --cron --collect-now --bot
Requirements
- Python 3.11+
- ~2 GB disk (YOLO model downloads on first run)
- Internet access (Open-Meteo API, infonieve.es scraping, Telegram API)
- Environment Variables:
TELEGRAM_BOT_TOKEN: Required for the Telegram bot.JWT_SECRET_KEY: Required for the FastAPI backend authentication.ADMIN_TELEGRAM_IDS(optional): Comma-separated Telegram user IDs for daily accuracy reports (e.g.,123456789,987654321).
ML Training
First-time training (full historical dataset)
This downloads 16+ seasons of station data from infonieve.es, fetches matching historical weather from Open-Meteo, builds features, and trains all 3 models:
# 1. Download historical station data from infonieve.es
.venv/bin/python data_sources/infonieve_historical.py
# 2. Build the full dataset (weather + station merge) and train models
.venv/bin/python scripts/build_full_dataset.py
Output:
data/processed/skipredictor.db: SQLite database with all data.ml/models/*.joblib: Trained models.
Retraining with accumulated data
.venv/bin/python scripts/retrain_model.py
FastAPI Backend & Scheduler
The backend uses FastAPI and includes an internal APScheduler to:
- Run forecast cycles at 05:00, 10:00, 15:00, and 20:00 (Europe/Madrid)
- At 20:00 specifically: send push notifications to subscribed users and accuracy reports to admins
- Retrain ML models weekly on Sundays at 21:00
- Manage the Telegram bot as in-process polling
Running the Backend
export TELEGRAM_BOT_TOKEN='...'
export JWT_SECRET_KEY='...'
export ADMIN_TELEGRAM_IDS='123456789,987654321' # Optional
.venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
Systemd Service Setup
Create /etc/systemd/system/skipredictor.service:
[Unit]
Description=SkiPredictor Backend & Bot
After=network.target
[Service]
Type=simple
User=dasemu
WorkingDirectory=/path/to/skipredictor
Environment=TELEGRAM_BOT_TOKEN=your_token
Environment=JWT_SECRET_KEY=your_secret
Environment=ADMIN_TELEGRAM_IDS=123456789,987654321
ExecStart=/path/to/skipredictor/.venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
Restart=on-failure
[Install]
WantedBy=multi-user.target
Legacy Cron Jobs (Optional)
If you prefer not to use the internal scheduler, you can still use standard cron jobs for daily collection and retraining. See OPERATIONS.md for details.
Monitoring
- Logs:
data/pipeline.log,data/retrain.log,data/bot.log. - API Status:
GET /api/v1/status(requires auth). - Health:
GET /api/v1/health(public).
Project Structure
See README.md for the full directory tree.