TranscriptWriting / prepare_for_spaces.py
jmisak's picture
Upload 13 files
56589d3 verified
raw
history blame
2.8 kB
#!/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()