Spaces:
Running
on
Zero
Running
on
Zero
File size: 2,300 Bytes
19b19f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
#!/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) |