Spaces:
Paused
Paused
| #!/usr/bin/env python3 | |
| """ | |
| Simple Deployment Validation | |
| =========================== | |
| Quick validation for Hugging Face Spaces deployment. | |
| """ | |
| import os | |
| import sys | |
| def main(): | |
| print("π Legal Dashboard OCR - Simple Deployment Validation") | |
| print("=" * 60) | |
| # Check essential files | |
| essential_files = [ | |
| "huggingface_space/app.py", | |
| "huggingface_space/Spacefile", | |
| "huggingface_space/README.md", | |
| "requirements.txt", | |
| "app/services/ocr_service.py", | |
| "app/services/ai_service.py", | |
| "app/services/database_service.py", | |
| "data/sample_persian.pdf" | |
| ] | |
| print("π Checking essential files...") | |
| all_files_exist = True | |
| for file_path in essential_files: | |
| if os.path.exists(file_path): | |
| print(f"β {file_path}") | |
| else: | |
| print(f"β {file_path}") | |
| all_files_exist = False | |
| # Check requirements.txt for gradio | |
| print("\nπ Checking requirements.txt...") | |
| try: | |
| with open("requirements.txt", "r", encoding="utf-8") as f: | |
| content = f.read() | |
| if "gradio" in content: | |
| print("β gradio found in requirements.txt") | |
| else: | |
| print("β gradio missing from requirements.txt") | |
| all_files_exist = False | |
| except Exception as e: | |
| print(f"β Error reading requirements.txt: {e}") | |
| all_files_exist = False | |
| # Check Spacefile | |
| print("\nπ Checking Spacefile...") | |
| try: | |
| with open("huggingface_space/Spacefile", "r", encoding="utf-8") as f: | |
| content = f.read() | |
| if "gradio" in content and "python" in content: | |
| print("β Spacefile properly configured") | |
| else: | |
| print("β Spacefile missing required configurations") | |
| all_files_exist = False | |
| except Exception as e: | |
| print(f"β Error reading Spacefile: {e}") | |
| all_files_exist = False | |
| # Final result | |
| print("\n" + "=" * 60) | |
| if all_files_exist: | |
| print("π All checks passed! Ready for deployment.") | |
| print("\nπ Deployment Steps:") | |
| print("1. Create Space on https://huggingface.co/spaces") | |
| print("2. Upload huggingface_space/ directory") | |
| print("3. Set HF_TOKEN environment variable") | |
| print("4. Deploy and test") | |
| return 0 | |
| else: | |
| print("β οΈ Some checks failed. Please fix issues before deployment.") | |
| return 1 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |