Spaces:
Running
on
Zero
Running
on
Zero
| #!/usr/bin/env python3 | |
| """ | |
| Test script to verify model loading functionality | |
| """ | |
| import os | |
| import sys | |
| import logging | |
| # Configure logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| def test_model_loading(): | |
| """Test the model loading functionality""" | |
| try: | |
| logger.info("Testing model loading...") | |
| # Import the app module to test model loading | |
| from app import load_model, check_local_model | |
| # Check if local model exists | |
| has_local = check_local_model() | |
| logger.info(f"Local model available: {has_local}") | |
| # Try to load the model | |
| success = load_model() | |
| logger.info(f"Model loading successful: {success}") | |
| return success | |
| except Exception as e: | |
| logger.error(f"Error testing model loading: {e}") | |
| return False | |
| def test_download_script(): | |
| """Test the download script""" | |
| try: | |
| logger.info("Testing download script...") | |
| # Import and run the download script | |
| from download_model import main as download_main | |
| success = download_main() | |
| logger.info(f"Download script successful: {success}") | |
| return success | |
| except Exception as e: | |
| logger.error(f"Error testing download script: {e}") | |
| return False | |
| def main(): | |
| """Main test function""" | |
| logger.info("Starting model loading tests...") | |
| # Test download script first | |
| logger.info("=== Testing Download Script ===") | |
| download_success = test_download_script() | |
| # Test model loading | |
| logger.info("=== Testing Model Loading ===") | |
| loading_success = test_model_loading() | |
| # Summary | |
| logger.info("=== Test Summary ===") | |
| logger.info(f"Download script: {'PASS' if download_success else 'FAIL'}") | |
| logger.info(f"Model loading: {'PASS' if loading_success else 'FAIL'}") | |
| overall_success = download_success and loading_success | |
| if overall_success: | |
| logger.info("All tests passed! Model is ready for deployment.") | |
| else: | |
| logger.error("Some tests failed. Please check the logs above.") | |
| return overall_success | |
| if __name__ == "__main__": | |
| success = main() | |
| sys.exit(0 if success else 1) |