# Testing Guide - OPTION A Ensemble Este guia mostra como testar o sistema OPTION A em diferentes ambientes. ## đŸ§Ș OpçÔes de Teste ### 1. Teste Local (Mais RĂĄpido) Testa a estrutura sem carregar modelos pesados: ```bash python test_local.py ``` **Vantagens**: - ✅ RĂĄpido (~10 segundos) - ✅ NĂŁo precisa de GPU - ✅ Testa imports e estrutura **LimitaçÔes**: - ❌ NĂŁo carrega modelos reais - ❌ NĂŁo testa inferĂȘncia --- ### 2. Teste Completo Local Testa com carregamento de modelos (requer download de ~3GB): ```bash python scripts/test/test_quick.py ``` **Testes incluĂ­dos**: 1. Model loading 2. Single audio annotation 3. Batch processing (5 samples) 4. Balanced mode (OPTION A - 3 models) 5. Performance benchmark **Tempo estimado**: - Primeira execução: ~10-15 min (download de modelos) - ExecuçÔes seguintes: ~2-5 min **Requisitos**: - RAM: 8GB mĂ­nimo (4GB pode funcionar com quick mode) - Disk: ~5GB para modelos - CPU: Qualquer (GPU nĂŁo necessĂĄria para teste) --- ### 3. Docker (Isolado) Testa em container Docker isolado: ```bash # Build docker build -f Dockerfile.test -t ensemble-test . # Run docker run ensemble-test ``` **Vantagens**: - ✅ Ambiente limpo e reproduzĂ­vel - ✅ NĂŁo afeta sistema local - ✅ FĂĄcil de compartilhar --- ### 4. Google Cloud Spot Instance (Mais Barato) Testa em mĂĄquina cloud baratinha (~$0.01/hora): ```bash bash scripts/test/launch_gcp_spot.sh ``` **Custo estimado**: - `e2-micro`: $0.0025/hr (1GB RAM) - SĂł para teste de estrutura - `e2-medium`: $0.01/hr (4GB RAM) - ⭐ Recomendado para teste completo - `e2-standard-2`: $0.02/hr (8GB RAM) - Para teste com balanced mode **O que faz**: 1. Busca zona mais barata 2. Lança instĂąncia spot/preemptible 3. Instala dependĂȘncias automaticamente 4. Roda testes 5. Fornece comandos para SSH e cleanup **Comandos Ășteis**: ```bash # Listar instĂąncias gcloud compute instances list # SSH na instĂąncia gcloud compute ssh ensemble-test-XXX --zone=us-central1-a # Deletar instĂąncia gcloud compute instances delete ensemble-test-XXX --zone=us-central1-a --quiet ``` --- ### 5. AWS Spot Instance Alternativa usando AWS (geralmente mais caro que GCP): ```bash bash scripts/test/launch_spot_test.sh ``` **Custo estimado**: - `t3a.medium`: ~$0.009/hr (4GB RAM) ⭐ Mais barato - `t3.medium`: ~$0.01/hr (4GB RAM) - `t3a.large`: ~$0.018/hr (8GB RAM) --- ## 📊 NĂ­veis de Teste ### NĂ­vel 1: Estrutura (test_local.py) ``` ✓ Imports ✓ Annotator creation ✓ Model structure ``` **Tempo**: ~10s | **RAM**: <1GB ### NĂ­vel 2: Quick Mode (test_quick.py --mode quick) ``` ✓ Load 2 models (emotion2vec + SenseVoice) ✓ Single annotation ✓ Batch processing ``` **Tempo**: ~2-5min | **RAM**: ~4GB ### NĂ­vel 3: Balanced Mode (test_quick.py --mode balanced) ``` ✓ Load 3 models (OPTION A) ✓ Full annotation pipeline ✓ Performance benchmark ``` **Tempo**: ~5-10min | **RAM**: ~6GB ### NĂ­vel 4: Production Test ``` ✓ Annotate real dataset (100 samples) ✓ Evaluation with ground truth ✓ Performance metrics ``` **Tempo**: ~15-30min | **RAM**: ~8GB --- ## 🎯 RecomendaçÔes por Caso de Uso ### Para Desenvolvimento ```bash python test_local.py # Validar mudanças rĂĄpido ``` ### Para CI/CD ```bash docker run ensemble-test # Testes automatizados ``` ### Para Validação Pre-Produção ```bash python scripts/test/test_quick.py --mode balanced ``` ### Para Benchmark de Performance ```bash bash scripts/test/launch_gcp_spot.sh # Ambiente limpo e controlado ``` --- ## ❌ Troubleshooting ### Out of Memory ```bash # Usar quick mode (2 modelos) python scripts/test/test_quick.py --mode quick # Ou testar sem carregar modelos python test_local.py ``` ### Models nĂŁo baixam ```bash # Limpar cache rm -rf ~/.cache/huggingface/ # Tentar novamente python scripts/test/test_quick.py ``` ### Timeout em cloud ```bash # Aumentar tipo de mĂĄquina # Em GCP: e2-medium → e2-standard-2 # Em AWS: t3.medium → t3.large ``` --- ## 📈 Resultados Esperados ### test_local.py ``` ✅ ALL LOCAL TESTS PASSED! imports: ✅ PASS create_annotator: ✅ PASS model_structure: ✅ PASS ``` ### test_quick.py (Quick Mode) ``` ✅ ALL TESTS PASSED! model_loading: ✅ PASS (2 models) single_annotation: ✅ PASS (~2s) batch_processing: ✅ PASS (~8s for 5 samples) ``` ### test_quick.py (Balanced Mode - OPTION A) ``` ✅ ALL TESTS PASSED! model_loading: ✅ PASS (3 models) single_annotation: ✅ PASS (~3s) balanced_mode: ✅ PASS (3 predictions) benchmark: ✅ PASS ``` --- ## 💰 Custo Estimado de Teste | Ambiente | Custo/Teste | Tempo | Notas | |----------|-------------|-------|-------| | **Local** | $0 | 2-10min | Melhor para dev | | **Docker** | $0 | 5-15min | Build inicial demora | | **GCP Spot (e2-medium)** | $0.001-0.003 | 10-20min | ⭐ Melhor custo-benefĂ­cio | | **AWS Spot (t3a.medium)** | $0.003-0.005 | 10-20min | Alternativa | **Exemplo de custo real**: - Teste completo em GCP e2-medium: $0.01/hr × 0.3hr = **$0.003** (menos de 1 centavo!) --- ## 🚀 Quick Start **Para começar rĂĄpido**: ```bash # 1. Teste local (validar estrutura) python test_local.py # 2. Se passou, teste completo python scripts/test/test_quick.py # 3. Se quer testar em cloud barato bash scripts/test/launch_gcp_spot.sh ``` --- ## 📝 Logs e Debugging ### Ver logs detalhados ```bash python test_local.py 2>&1 | tee test.log ``` ### Apenas erros ```bash python scripts/test/test_quick.py 2>&1 | grep -E "(ERROR|FAIL|❌)" ``` ### Com timestamp ```bash python scripts/test/test_quick.py 2>&1 | ts ``` --- ## ✅ Checklist Pre-Produção Antes de usar em produção, execute: - [ ] `python test_local.py` → Passa - [ ] `python scripts/test/test_quick.py --mode quick` → Passa - [ ] `python scripts/test/test_quick.py --mode balanced` → Passa - [ ] Teste com ĂĄudio real (nĂŁo sintĂ©tico) - [ ] Evaluation com ground truth - [ ] Performance benchmark --- **Desenvolvido para OPTION A - Ensemble otimizado de 3 modelos** 🎯