Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Prepare files for HuggingFace Spaces deployment | |
| Copies only the required files to a clean directory | |
| """ | |
| import os | |
| import shutil | |
| from pathlib import Path | |
| # Required files for HuggingFace Spaces | |
| REQUIRED_FILES = [ | |
| # Core application | |
| 'app.py', | |
| # Processing modules | |
| 'llm.py', | |
| 'extractors.py', | |
| 'tagging.py', | |
| 'chunking.py', | |
| 'validation.py', | |
| 'reporting.py', | |
| 'dashboard.py', | |
| 'production_logger.py', | |
| # Optional but recommended | |
| 'quote_extractor.py', | |
| # Configuration | |
| 'requirements.txt', | |
| # Documentation (optional) | |
| 'README.md', | |
| 'HUGGINGFACE_SPACES_SETUP.md', | |
| ] | |
| def prepare_deployment(output_dir='./spaces_deployment'): | |
| """Copy required files to deployment directory""" | |
| # Create output directory | |
| output_path = Path(output_dir) | |
| if output_path.exists(): | |
| print(f"β οΈ Directory {output_dir} already exists") | |
| response = input("Delete and recreate? (y/n): ") | |
| if response.lower() != 'y': | |
| print("β Cancelled") | |
| return | |
| shutil.rmtree(output_path) | |
| output_path.mkdir(exist_ok=True) | |
| print(f"π Created directory: {output_dir}\n") | |
| # Copy files | |
| copied = [] | |
| missing = [] | |
| for filename in REQUIRED_FILES: | |
| src = Path(filename) | |
| if src.exists(): | |
| dst = output_path / filename | |
| shutil.copy2(src, dst) | |
| size_kb = src.stat().st_size / 1024 | |
| print(f" β {filename} ({size_kb:.1f} KB)") | |
| copied.append(filename) | |
| else: | |
| print(f" β οΈ {filename} - NOT FOUND (skipping)") | |
| missing.append(filename) | |
| # Summary | |
| print("\n" + "="*80) | |
| print("π SUMMARY") | |
| print("="*80) | |
| print(f"β Copied: {len(copied)} files") | |
| if missing: | |
| print(f"β οΈ Missing: {len(missing)} files") | |
| print(f" {', '.join(missing)}") | |
| print(f"\nπ¦ Deployment files ready in: {output_dir}/") | |
| print("\nπ Next steps:") | |
| print("1. Go to https://huggingface.co/new-space") | |
| print("2. Select Gradio SDK and GPU hardware") | |
| print("3. Upload all files from the deployment directory") | |
| print("4. Wait for model download (~2-5 min first time)") | |
| print("5. Test your Space!") | |
| # Check for .env file (should not be included) | |
| if (output_path / '.env').exists(): | |
| print("\nβ οΈ WARNING: .env file found in deployment directory!") | |
| print(" This should NOT be deployed to HuggingFace Spaces") | |
| os.remove(output_path / '.env') | |
| print(" β Removed .env file") | |
| print("\n⨠Deployment package ready!") | |
| if __name__ == '__main__': | |
| prepare_deployment() | |