mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
feat: unified architecture and webcam archive optimization
- Refactor backend into a single process (FastAPI + APScheduler + Telegram Bot) - Implement 'current_forecasts' and 'past_forecasts' architecture in storage - Optimize historical webcam collector with date range discovery for Pajares, San Isidro, and Fuentes - Clean up legacy scripts and tables (prediction_runs, prediction_stations) - Update tests and operations documentation
This commit is contained in:
1 parent
a70eff3e45
commit
f6a65f41d9
14 files changed
+563
-660
No files matched your search
+39
-31
@@ -2,7 +2,18 @@
|
||||
|
||||
This guide covers common administrative and maintenance tasks for the SkiPredictor system.
|
||||
|
||||
## 🗄️ Database Management
|
||||
## Architecture
|
||||
|
||||
Single unified process: FastAPI + APScheduler + Telegram Bot (in-process).
|
||||
|
||||
**Scheduled tasks:**
|
||||
- Standard (5h, 10h, 15h): archive forecasts, collect weather, generate predictions
|
||||
- Extended (20h): same + webcam snapshot + crowd analysis + actuals scraping
|
||||
- Training (Sunday 21h): retrain ML models
|
||||
|
||||
**Single source of truth:** `current_forecasts` / `past_forecasts` tables in SQLite.
|
||||
|
||||
## Database Management
|
||||
|
||||
The authoritative data source is the SQLite database at `data/processed/skipredictor.db`.
|
||||
|
||||
@@ -16,9 +27,26 @@ sqlite3 data/processed/skipredictor.db "SELECT * FROM current_forecasts ORDER BY
|
||||
.venv/bin/python -c "from storage import SQLiteStore; s=SQLiteStore(); print(f'DB Size: {s.db_path.stat().st_size/1024/1024:.2f} MB')"
|
||||
```
|
||||
|
||||
## 🔄 Manual Forecast Cycles
|
||||
## Setup (first time)
|
||||
|
||||
While the FastAPI backend handles the schedule via APScheduler, you can trigger cycles manually:
|
||||
```bash
|
||||
./setup.sh
|
||||
```
|
||||
|
||||
This creates a venv, installs dependencies, downloads historical data, trains models, and collects webcam snapshots.
|
||||
|
||||
## Starting the unified daemon
|
||||
|
||||
```bash
|
||||
source .venv/bin/activate
|
||||
export TELEGRAM_BOT_TOKEN='your_token'
|
||||
export JWT_SECRET_KEY='your_secret'
|
||||
uvicorn app.main:app --host 0.0.0.0 --port 8000
|
||||
```
|
||||
|
||||
This starts FastAPI (REST API), APScheduler (scheduled tasks), and the Telegram bot (in-process polling).
|
||||
|
||||
## Manual Forecast Cycles
|
||||
|
||||
### Run a full prediction cycle now
|
||||
```bash
|
||||
@@ -30,7 +58,7 @@ While the FastAPI backend handles the schedule via APScheduler, you can trigger
|
||||
.venv/bin/python data_sources/station_scraper.py
|
||||
```
|
||||
|
||||
## 🧠 ML Model Operations
|
||||
## ML Model Operations
|
||||
|
||||
### Force manual retraining
|
||||
```bash
|
||||
@@ -38,39 +66,19 @@ While the FastAPI backend handles the schedule via APScheduler, you can trigger
|
||||
```
|
||||
|
||||
### Inspecting model metrics
|
||||
The metrics from the last training run are stored in the `training_runs` table:
|
||||
```bash
|
||||
sqlite3 data/processed/skipredictor.db "SELECT metrics_json FROM training_runs ORDER BY completed_at DESC LIMIT 1;"
|
||||
```
|
||||
|
||||
## 🤖 Telegram Bot
|
||||
## Telegram Bot
|
||||
|
||||
### Running the bot standalone
|
||||
### Running the bot standalone (dev)
|
||||
```bash
|
||||
export TELEGRAM_BOT_TOKEN='your_token'
|
||||
.venv/bin/python bot/telegram_bot.py
|
||||
.venv/bin/python -m bot.telegram_bot
|
||||
```
|
||||
|
||||
### Monitoring bot logs
|
||||
```bash
|
||||
tail -f data/bot.log
|
||||
```
|
||||
|
||||
## 🌐 FastAPI Backend
|
||||
|
||||
### Running the API server (Production)
|
||||
```bash
|
||||
export TELEGRAM_BOT_TOKEN='your_token'
|
||||
export JWT_SECRET_KEY='your_secret'
|
||||
.venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
|
||||
```
|
||||
|
||||
### Running the API server (Development/Reload)
|
||||
```bash
|
||||
uvicorn app.main:app --reload
|
||||
```
|
||||
|
||||
## 🛠️ Troubleshooting
|
||||
## Troubleshooting
|
||||
|
||||
### Missing forecasts?
|
||||
1. Check `data/pipeline.log`.
|
||||
@@ -78,6 +86,6 @@ uvicorn app.main:app --reload
|
||||
3. Ensure models exist in `ml/models/`.
|
||||
|
||||
### Bot not responding?
|
||||
1. Check if the subprocess is alive via `GET /api/v1/status`.
|
||||
2. Check `data/bot.log` for API errors (e.g., Invalid Token).
|
||||
3. Ensure `TELEGRAM_BOT_TOKEN` is correctly exported in the environment where the backend is running.
|
||||
1. Check if the bot is active via `GET /api/v1/status`.
|
||||
2. Ensure `TELEGRAM_BOT_TOKEN` is correctly exported in the environment.
|
||||
3. Check uvicorn logs for bot startup errors.
|
||||
Reference in new issue
Block a user