# Hugging Face Spaces Debugging Guide ## Issue: Validation Button Not Working If the validation button is not responding when deployed to Hugging Face Spaces, follow these debugging steps: ### 1. Run the Debug Script First, run the comprehensive debugging script to identify the issue: ```bash python debug_hf_spaces.py ``` This will create a `debug.log` file with detailed information about: - Environment information - Network connectivity - Module imports - Model validator functionality - Data manager functionality ### 2. Check Common Issues #### Network Connectivity Hugging Face Spaces might have different network policies. The debug script tests: - Basic HTTP requests - Ollama.com connectivity - Hugging Face Hub connectivity #### Timeout Issues The validation process now includes: - 30-second timeout for Ollama requests - Retry logic with exponential backoff - Fallback mechanism for network failures #### Import Issues Check if all modules are importing correctly: - `model_validator` - `data_manager` - `api_service` - UI modules ### 3. Fallback Mechanism If validation fails due to network issues, the system now provides a fallback: - Shows a warning message - Still allows model submission - User can proceed with manual verification ### 4. Manual Testing You can test individual components: ```bash # Test basic connectivity python -c "import requests; print(requests.get('https://ollama.com').status_code)" # Test model validator python -c "from model_validator import model_validator; print(model_validator.validate_ollama_model('llama2', '7b'))" # Test data manager python -c "from data_manager import data_manager; print(data_manager.check_model_exists('llama2', '7b'))" ``` ### 5. Environment Variables Check if these environment variables are set in your Hugging Face Space: - `HF_TOKEN` (if needed for dataset access) - `API_BASE_URL` (for model submission) ### 6. Logs Check the application logs in Hugging Face Spaces: - Look for error messages - Check for timeout errors - Verify import statements ### 7. Quick Fixes If the issue persists: 1. **Increase timeouts**: The system now uses 30-second timeouts 2. **Use fallback mode**: The validation will show a warning but allow submission 3. **Check network policies**: Ensure Ollama.com is accessible from Hugging Face Spaces ### 8. Contact Support If the issue continues, provide: - The output from `debug_hf_spaces.py` - The contents of `debug.log` - Any error messages from Hugging Face Spaces logs ## Files Modified for HF Spaces Compatibility 1. **`model_validator.py`**: Added retry logic and increased timeouts 2. **`ui_submit_model.py`**: Added fallback mechanism and better error handling 3. **`data_manager.py`**: Improved error handling for dataset loading 4. **`app.py`**: Added comprehensive logging and error handling 5. **`debug_hf_spaces.py`**: Comprehensive debugging script 6. **`test_hf_spaces.py`**: Basic functionality tests