File size: 2,824 Bytes
d85c750
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Quick Deployment Script for Hugging Face Spaces
# Run this after cloning your HF Space repository

Write-Host "πŸš€ SegmentoPulse Backend - Hugging Face Spaces Deployment" -ForegroundColor Cyan
Write-Host ""

# Check if we're in the right directory
if (-not (Test-Path "app/main.py")) {
    Write-Host "❌ Error: app/main.py not found. Make sure you're in the SegmentoPulse/backend directory" -ForegroundColor Red
    exit 1
}

# Check for .env file and warn
if (Test-Path ".env") {
    Write-Host "⚠️  Warning: .env file found. This should NOT be committed to Git!" -ForegroundColor Yellow
    Write-Host "   Make sure .env is in .gitignore" -ForegroundColor Yellow
    Write-Host ""
}

# Clean up unnecessary files
Write-Host "🧹 Cleaning up..." -ForegroundColor Green
Get-ChildItem -Path "." -Recurse -Directory -Filter "__pycache__" | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
Get-ChildItem -Path "." -Recurse -Filter "*.pyc" | Remove-Item -Force -ErrorAction SilentlyContinue
Remove-Item -Path ".env" -ErrorAction SilentlyContinue

# Check required files
Write-Host "βœ… Checking required files..." -ForegroundColor Green
$required = @("Dockerfile", "README.md", "requirements.txt", "app/main.py", "app/config.py")
foreach ($file in $required) {
    if (Test-Path $file) {
        Write-Host "  βœ“ $file" -ForegroundColor Green
    } else {
        Write-Host "  βœ— $file MISSING" -ForegroundColor Red
    }
}
Write-Host ""

# Git status
Write-Host "πŸ“¦ Preparing for deployment..." -ForegroundColor Cyan
git status --short

Write-Host ""
Write-Host "πŸ“‹ Pre-Deployment Checklist:" -ForegroundColor Yellow
Write-Host "  [ ] Created HF Space with Docker SDK" -ForegroundColor White
Write-Host "  [ ] Cloned Space repository" -ForegroundColor White
Write-Host "  [ ] Copied backend files to Space directory" -ForegroundColor White
Write-Host "  [ ] Added API keys to HF Spaces Secrets" -ForegroundColor White
Write-Host ""

$confirm = Read-Host "Ready to commit and push to Hugging Face? (y/n)"
if ($confirm -eq 'y' -or $confirm -eq 'Y') {
    Write-Host ""
    Write-Host "πŸš€ Deploying to Hugging Face..." -ForegroundColor Cyan
    
    git add .
    git commit -m "Deploy SegmentoPulse backend to HF Spaces"
    git push
    
    Write-Host ""
    Write-Host "βœ… Deployment initiated!" -ForegroundColor Green
    Write-Host ""
    Write-Host "πŸ“Š Next steps:" -ForegroundColor Cyan
    Write-Host "  1. Monitor build logs in your HF Space" -ForegroundColor White
    Write-Host "  2. Test endpoints once deployed" -ForegroundColor White
    Write-Host "  3. Update frontend environment variable" -ForegroundColor White
    Write-Host "  4. Deploy frontend to production" -ForegroundColor White
    Write-Host ""
} else {
    Write-Host "Deployment cancelled." -ForegroundColor Yellow
}