Fix build
This commit is contained in:
317
COMMANDES.md
Normal file
317
COMMANDES.md
Normal file
@@ -0,0 +1,317 @@
|
||||
# 📝 Commandes Essentielles - Audio Classifier
|
||||
|
||||
## 🚀 Démarrage
|
||||
|
||||
### Lancer tous les services
|
||||
```bash
|
||||
cd "/Users/benoit/Documents/code/Audio Classifier"
|
||||
docker-compose -f docker-compose.dev.yml up -d
|
||||
```
|
||||
|
||||
### Vérifier le statut
|
||||
```bash
|
||||
docker-compose -f docker-compose.dev.yml ps
|
||||
docker-compose -f docker-compose.dev.yml logs -f backend
|
||||
```
|
||||
|
||||
### Lancer le frontend
|
||||
```bash
|
||||
cd frontend
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## 🔍 Vérifications
|
||||
|
||||
### Health check
|
||||
```bash
|
||||
curl http://localhost:8001/health
|
||||
```
|
||||
|
||||
### Stats base de données
|
||||
```bash
|
||||
curl http://localhost:8001/api/stats | python3 -m json.tool
|
||||
```
|
||||
|
||||
### Liste des pistes
|
||||
```bash
|
||||
curl http://localhost:8001/api/tracks?limit=5 | python3 -m json.tool
|
||||
```
|
||||
|
||||
## 🎵 Analyse audio
|
||||
|
||||
### Analyser un dossier
|
||||
```bash
|
||||
curl -X POST http://localhost:8001/api/analyze/folder \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"path": "/audio",
|
||||
"recursive": true
|
||||
}'
|
||||
```
|
||||
|
||||
Retourne un `job_id`
|
||||
|
||||
### Vérifier la progression
|
||||
```bash
|
||||
# Remplacer JOB_ID par l'ID retourné
|
||||
curl http://localhost:8001/api/analyze/status/JOB_ID | python3 -m json.tool
|
||||
```
|
||||
|
||||
## 🔎 Recherche
|
||||
|
||||
### Recherche textuelle
|
||||
```bash
|
||||
curl "http://localhost:8001/api/search?q=jazz&limit=10" | python3 -m json.tool
|
||||
```
|
||||
|
||||
### Filtrer par BPM
|
||||
```bash
|
||||
curl "http://localhost:8001/api/tracks?bpm_min=120&bpm_max=140&limit=20" | python3 -m json.tool
|
||||
```
|
||||
|
||||
### Filtrer par genre
|
||||
```bash
|
||||
curl "http://localhost:8001/api/tracks?genre=electronic&limit=10" | python3 -m json.tool
|
||||
```
|
||||
|
||||
### Filtrer par énergie
|
||||
```bash
|
||||
curl "http://localhost:8001/api/tracks?energy_min=0.7&limit=10" | python3 -m json.tool
|
||||
```
|
||||
|
||||
## 🎧 Audio
|
||||
|
||||
### Stream (dans navigateur)
|
||||
```bash
|
||||
# Récupérer un track_id d'abord
|
||||
TRACK_ID=$(curl -s "http://localhost:8001/api/tracks?limit=1" | python3 -c "import sys, json; print(json.load(sys.stdin)['tracks'][0]['id'])")
|
||||
|
||||
# Ouvrir dans navigateur
|
||||
open "http://localhost:8001/api/audio/stream/$TRACK_ID"
|
||||
```
|
||||
|
||||
### Download
|
||||
```bash
|
||||
curl -o music.mp3 "http://localhost:8001/api/audio/download/$TRACK_ID"
|
||||
```
|
||||
|
||||
### Waveform data
|
||||
```bash
|
||||
curl "http://localhost:8001/api/audio/waveform/$TRACK_ID" | python3 -m json.tool
|
||||
```
|
||||
|
||||
## 🗄️ Base de données
|
||||
|
||||
### Connexion psql
|
||||
```bash
|
||||
docker exec -it audio_classifier_db psql -U audio_user -d audio_classifier
|
||||
```
|
||||
|
||||
### Queries utiles
|
||||
```sql
|
||||
-- Nombre total de pistes
|
||||
SELECT COUNT(*) FROM audio_tracks;
|
||||
|
||||
-- 10 dernières pistes analysées
|
||||
SELECT filename, tempo_bpm, key, genre_primary, mood_primary, analyzed_at
|
||||
FROM audio_tracks
|
||||
ORDER BY analyzed_at DESC
|
||||
LIMIT 10;
|
||||
|
||||
-- Pistes par genre
|
||||
SELECT genre_primary, COUNT(*)
|
||||
FROM audio_tracks
|
||||
WHERE genre_primary IS NOT NULL
|
||||
GROUP BY genre_primary
|
||||
ORDER BY COUNT(*) DESC;
|
||||
|
||||
-- Pistes rapides (> 140 BPM)
|
||||
SELECT filename, tempo_bpm
|
||||
FROM audio_tracks
|
||||
WHERE tempo_bpm > 140
|
||||
ORDER BY tempo_bpm DESC;
|
||||
```
|
||||
|
||||
### Migrations
|
||||
```bash
|
||||
# Appliquer les migrations
|
||||
docker exec audio_classifier_api alembic upgrade head
|
||||
|
||||
# Vérifier la version
|
||||
docker exec audio_classifier_api alembic current
|
||||
|
||||
# Historique
|
||||
docker exec audio_classifier_api alembic history
|
||||
```
|
||||
|
||||
## 🛠️ Gestion services
|
||||
|
||||
### Arrêter
|
||||
```bash
|
||||
docker-compose -f docker-compose.dev.yml stop
|
||||
```
|
||||
|
||||
### Redémarrer
|
||||
```bash
|
||||
docker-compose -f docker-compose.dev.yml restart
|
||||
```
|
||||
|
||||
### Redémarrer uniquement le backend
|
||||
```bash
|
||||
docker-compose -f docker-compose.dev.yml restart backend
|
||||
```
|
||||
|
||||
### Logs
|
||||
```bash
|
||||
# Tous les services
|
||||
docker-compose -f docker-compose.dev.yml logs -f
|
||||
|
||||
# Backend seulement
|
||||
docker-compose -f docker-compose.dev.yml logs -f backend
|
||||
|
||||
# PostgreSQL
|
||||
docker-compose -f docker-compose.dev.yml logs -f postgres
|
||||
```
|
||||
|
||||
### Rebuild
|
||||
```bash
|
||||
docker-compose -f docker-compose.dev.yml build backend
|
||||
docker-compose -f docker-compose.dev.yml up -d
|
||||
```
|
||||
|
||||
### Supprimer tout (⚠️ perd les données)
|
||||
```bash
|
||||
docker-compose -f docker-compose.dev.yml down -v
|
||||
```
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Modifier le dossier audio
|
||||
```bash
|
||||
# Éditer .env
|
||||
nano .env
|
||||
|
||||
# Changer:
|
||||
AUDIO_LIBRARY_PATH=/nouveau/chemin/vers/audio
|
||||
|
||||
# Redémarrer
|
||||
docker-compose -f docker-compose.dev.yml restart backend
|
||||
```
|
||||
|
||||
### Changer le nombre de workers
|
||||
```bash
|
||||
# Éditer .env
|
||||
ANALYSIS_NUM_WORKERS=8
|
||||
|
||||
# Redémarrer
|
||||
docker-compose -f docker-compose.dev.yml restart backend
|
||||
```
|
||||
|
||||
## 📊 Statistiques
|
||||
|
||||
### Stats globales
|
||||
```bash
|
||||
curl http://localhost:8001/api/stats | python3 -m json.tool
|
||||
```
|
||||
|
||||
### Nombre de pistes
|
||||
```bash
|
||||
curl -s http://localhost:8001/api/stats | python3 -c "import sys, json; print(f\"Total tracks: {json.load(sys.stdin)['total_tracks']}\")"
|
||||
```
|
||||
|
||||
## 🧪 Tests
|
||||
|
||||
### Test health check
|
||||
```bash
|
||||
curl -f http://localhost:8001/health && echo "✅ OK" || echo "❌ FAIL"
|
||||
```
|
||||
|
||||
### Test connexion DB
|
||||
```bash
|
||||
docker exec audio_classifier_db pg_isready -U audio_user && echo "✅ DB OK" || echo "❌ DB FAIL"
|
||||
```
|
||||
|
||||
### Test frontend
|
||||
```bash
|
||||
curl -f http://localhost:3000 && echo "✅ Frontend OK" || echo "❌ Frontend FAIL"
|
||||
```
|
||||
|
||||
## 📖 Documentation
|
||||
|
||||
### API interactive
|
||||
```bash
|
||||
open http://localhost:8001/docs
|
||||
```
|
||||
|
||||
### Frontend
|
||||
```bash
|
||||
open http://localhost:3000
|
||||
```
|
||||
|
||||
## 🆘 Debug
|
||||
|
||||
### Voir les variables d'environnement
|
||||
```bash
|
||||
docker exec audio_classifier_api env | grep -E "DATABASE_URL|CORS|ANALYSIS"
|
||||
```
|
||||
|
||||
### Vérifier les ports
|
||||
```bash
|
||||
lsof -i :8001 # Backend
|
||||
lsof -i :5433 # PostgreSQL
|
||||
lsof -i :3000 # Frontend
|
||||
```
|
||||
|
||||
### Espace disque Docker
|
||||
```bash
|
||||
docker system df
|
||||
docker system prune # Nettoyer
|
||||
```
|
||||
|
||||
## 🎯 Workflows courants
|
||||
|
||||
### Analyser une nouvelle bibliothèque
|
||||
```bash
|
||||
# 1. Configurer le chemin
|
||||
echo 'AUDIO_LIBRARY_PATH=/path/to/music' >> .env
|
||||
|
||||
# 2. Redémarrer
|
||||
docker-compose -f docker-compose.dev.yml restart backend
|
||||
|
||||
# 3. Lancer l'analyse
|
||||
curl -X POST http://localhost:8001/api/analyze/folder \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"path": "/audio", "recursive": true}'
|
||||
|
||||
# 4. Suivre la progression (récupérer job_id d'abord)
|
||||
watch -n 2 "curl -s http://localhost:8001/api/analyze/status/JOB_ID | python3 -m json.tool"
|
||||
```
|
||||
|
||||
### Rechercher et écouter
|
||||
```bash
|
||||
# 1. Rechercher
|
||||
curl "http://localhost:8001/api/search?q=upbeat" | python3 -m json.tool
|
||||
|
||||
# 2. Copier un track_id
|
||||
|
||||
# 3. Écouter
|
||||
open "http://localhost:8001/api/audio/stream/TRACK_ID"
|
||||
```
|
||||
|
||||
### Export des résultats
|
||||
```bash
|
||||
# Export JSON toutes les pistes
|
||||
curl "http://localhost:8001/api/tracks?limit=10000" > tracks.json
|
||||
|
||||
# Export CSV (simple)
|
||||
curl -s "http://localhost:8001/api/tracks?limit=10000" | \
|
||||
python3 -c "import sys, json, csv; data = json.load(sys.stdin)['tracks']; writer = csv.DictWriter(sys.stdout, fieldnames=['filename', 'tempo_bpm', 'key', 'genre_primary']); writer.writeheader(); [writer.writerow({k: track.get(k) or track['features'].get(k) or track['classification']['genre'].get('primary') for k in ['filename', 'tempo_bpm', 'key', 'genre_primary']}) for track in data]" > tracks.csv
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Rappel des URLs** :
|
||||
- Backend API : http://localhost:8001
|
||||
- API Docs : http://localhost:8001/docs
|
||||
- Frontend : http://localhost:3000
|
||||
- PostgreSQL : localhost:5433
|
||||
Reference in New Issue
Block a user