mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
docs: update API, deployment, and lessons for the new backend
- Updated API_SPEC.md with JWT auth and storage schema. - Updated DEPLOYMENT.md for the new uvicorn-based setup. - Added LESSONS.md pattern for worktree management. - Included new README, TODO, and OPERATIONS files.
This commit is contained in:
1 parent
b5b62e582e
commit
e952cea417
7 files changed
+281
-279
No files matched your search
@@ -0,0 +1,83 @@
|
||||
# SkiPredictor Operations Guide
|
||||
|
||||
This guide covers common administrative and maintenance tasks for the SkiPredictor system.
|
||||
|
||||
## 🗄️ Database Management
|
||||
|
||||
The authoritative data source is the SQLite database at `data/processed/skipredictor.db`.
|
||||
|
||||
### Inspecting latest predictions
|
||||
```bash
|
||||
sqlite3 data/processed/skipredictor.db "SELECT * FROM current_forecasts ORDER BY station_id, prediction_date LIMIT 10;"
|
||||
```
|
||||
|
||||
### Checking system status via CLI
|
||||
```bash
|
||||
.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
|
||||
|
||||
While the FastAPI backend handles the schedule via APScheduler, you can trigger cycles manually:
|
||||
|
||||
### Run a full prediction cycle now
|
||||
```bash
|
||||
.venv/bin/python scripts/collect_daily_data.py
|
||||
```
|
||||
|
||||
### Scrape today's actual results
|
||||
```bash
|
||||
.venv/bin/python data_sources/station_scraper.py
|
||||
```
|
||||
|
||||
## 🧠 ML Model Operations
|
||||
|
||||
### Force manual retraining
|
||||
```bash
|
||||
.venv/bin/python scripts/retrain_model.py
|
||||
```
|
||||
|
||||
### 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
|
||||
|
||||
### Running the bot standalone
|
||||
```bash
|
||||
export TELEGRAM_BOT_TOKEN='your_token'
|
||||
.venv/bin/python bot/telegram_bot.py
|
||||
```
|
||||
|
||||
### 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
|
||||
|
||||
### Missing forecasts?
|
||||
1. Check `data/pipeline.log`.
|
||||
2. Verify Open-Meteo connectivity: `curl "https://api.open-meteo.com/v1/forecast?latitude=43.05&longitude=-5.77&daily=snowfall_sum"`
|
||||
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.
|
||||
Reference in new issue
Block a user