Spaces:
Sleeping
Sleeping
File size: 3,576 Bytes
ea2b6ec | 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | # Git deployment script for Hugging Face Spaces
# This script adds, commits, and pushes all necessary files
Write-Host "=== Preparing files for Hugging Face Spaces deployment ===" -ForegroundColor Cyan
# Change to project directory
Set-Location $PSScriptRoot
# Step 1: Remove git lock file if exists (in case of previous failed operations)
if (Test-Path .git\index.lock) {
Write-Host "Removing git lock file..." -ForegroundColor Yellow
Remove-Item .git\index.lock -Force -ErrorAction SilentlyContinue
}
# Step 2: Add core application files (required for API to work)
Write-Host "`nAdding core application files..." -ForegroundColor Green
git add app.py
git add preprocessing.py
git add model_utils.py
git add requirements.txt
git add Dockerfile
# Step 3: Add configuration files
Write-Host "Adding configuration files..." -ForegroundColor Green
git add .dockerignore
git add .gitignore
# Step 4: Add documentation files
Write-Host "Adding documentation files..." -ForegroundColor Green
git add README_HF_SPACE.md
git add DEPLOYMENT.md
git add DEPLOYMENT_SUMMARY.md
git add README.md
# Step 5: Add models directory (if exists and not in .gitignore)
if (Test-Path models) {
Write-Host "Checking models directory..." -ForegroundColor Yellow
# Check if models/ is in .gitignore
$gitignoreContent = Get-Content .gitignore -ErrorAction SilentlyContinue
if ($gitignoreContent -notmatch "^models/") {
Write-Host "Adding models directory..." -ForegroundColor Green
git add models/
} else {
Write-Host "WARNING: models/ is in .gitignore. You may need to force add it:" -ForegroundColor Yellow
Write-Host " git add -f models/" -ForegroundColor Yellow
}
}
# Step 6: Show status
Write-Host "`n=== Files staged for commit ===" -ForegroundColor Cyan
git status --short
# Step 7: Commit
Write-Host "`n=== Committing changes ===" -ForegroundColor Cyan
$commitMessage = "Deploy to Hugging Face Spaces: Add application files and dependencies
- Add FastAPI application (app.py)
- Add preprocessing module (preprocessing.py)
- Add model utilities (model_utils.py)
- Add Dockerfile for HF Spaces deployment
- Add requirements.txt
- Add deployment documentation
- Add configuration files"
git commit -m $commitMessage
if ($LASTEXITCODE -eq 0) {
Write-Host "`n=== Commit successful! ===" -ForegroundColor Green
# Step 8: Push
Write-Host "`n=== Pushing to remote ===" -ForegroundColor Cyan
Write-Host "Note: You may need to authenticate for push" -ForegroundColor Yellow
git push
if ($LASTEXITCODE -eq 0) {
Write-Host "`n=== Deployment files pushed successfully! ===" -ForegroundColor Green
Write-Host "Next steps:" -ForegroundColor Cyan
Write-Host "1. Go to your Hugging Face Space" -ForegroundColor White
Write-Host "2. Wait for automatic rebuild" -ForegroundColor White
Write-Host "3. Check logs if build fails" -ForegroundColor White
} else {
Write-Host "`n=== Push failed ===" -ForegroundColor Red
Write-Host "You may need to:" -ForegroundColor Yellow
Write-Host "1. Set up authentication (git credential or token)" -ForegroundColor White
Write-Host "2. Check remote URL: git remote -v" -ForegroundColor White
Write-Host "3. Try: git push origin main" -ForegroundColor White
}
} else {
Write-Host "`n=== Commit failed ===" -ForegroundColor Red
Write-Host "Check git status and resolve any conflicts" -ForegroundColor Yellow
}
Write-Host "`n=== Script completed ===" -ForegroundColor Cyan
|