Product-ai / test_deployment.py
Parimal Kalpande
deploy
db70c95
#!/usr/bin/env python3
"""
Test script to check if all dependencies can be imported for Hugging Face deployment
"""
import sys
def test_imports():
"""Test all required imports"""
print("πŸ§ͺ Testing deployment readiness...")
failed_imports = []
# Test core dependencies
try:
import gradio
print("βœ… gradio")
except ImportError as e:
failed_imports.append(f"gradio: {e}")
print("❌ gradio")
try:
import groq
print("βœ… groq")
except ImportError as e:
failed_imports.append(f"groq: {e}")
print("❌ groq")
try:
import whisper
print("βœ… openai-whisper")
except ImportError as e:
failed_imports.append(f"openai-whisper: {e}")
print("❌ openai-whisper")
try:
import pydub
print("βœ… pydub")
except ImportError as e:
failed_imports.append(f"pydub: {e}")
print("❌ pydub")
try:
import soundfile
print("βœ… soundfile")
except ImportError as e:
failed_imports.append(f"soundfile: {e}")
print("❌ soundfile")
try:
import fitz # PyMuPDF
print("βœ… PyMuPDF")
except ImportError as e:
failed_imports.append(f"PyMuPDF: {e}")
print("❌ PyMuPDF")
try:
import docx
print("βœ… python-docx")
except ImportError as e:
failed_imports.append(f"python-docx: {e}")
print("❌ python-docx")
try:
import reportlab
print("βœ… reportlab")
except ImportError as e:
failed_imports.append(f"reportlab: {e}")
print("❌ reportlab")
try:
import speech_recognition
print("βœ… speechrecognition")
except ImportError as e:
failed_imports.append(f"speechrecognition: {e}")
print("❌ speechrecognition")
try:
import matplotlib
print("βœ… matplotlib")
except ImportError as e:
failed_imports.append(f"matplotlib: {e}")
print("❌ matplotlib")
try:
import numpy
print("βœ… numpy")
except ImportError as e:
failed_imports.append(f"numpy: {e}")
print("❌ numpy")
# Test module imports
print("\nπŸ“¦ Testing custom modules...")
try:
import config
print("βœ… config")
except ImportError as e:
failed_imports.append(f"config: {e}")
print("❌ config")
try:
from modules.llm_handler import generate_coaching_question
print("βœ… modules.llm_handler")
except ImportError as e:
failed_imports.append(f"modules.llm_handler: {e}")
print("❌ modules.llm_handler")
try:
from modules.doc_processor import extract_text_from_document
print("βœ… modules.doc_processor")
except ImportError as e:
failed_imports.append(f"modules.doc_processor: {e}")
print("❌ modules.doc_processor")
try:
from modules.report_generator import generate_pdf_report
print("βœ… modules.report_generator")
except ImportError as e:
failed_imports.append(f"modules.report_generator: {e}")
print("❌ modules.report_generator")
# Summary
print("\n" + "="*50)
if failed_imports:
print(f"❌ {len(failed_imports)} import failures found:")
for failure in failed_imports:
print(f" - {failure}")
print("\n🚨 App may not work properly on Hugging Face!")
return False
else:
print("βœ… All imports successful!")
print("πŸš€ Ready for Hugging Face deployment!")
return True
if __name__ == "__main__":
success = test_imports()
sys.exit(0 if success else 1)