Spaces:
Running
Running
File size: 3,890 Bytes
eda8578 |
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 95 96 97 98 99 100 101 102 103 104 105 |
# π ECG-FM Hugging Face Spaces Deployment Script (PowerShell)
# This script automates the deployment process to HF Spaces on Windows
param(
[string]$HFUsername = "",
[string]$SpaceName = "ecg-fm-api"
)
# Error handling
$ErrorActionPreference = "Stop"
Write-Host "π Starting ECG-FM deployment to Hugging Face Spaces..." -ForegroundColor Cyan
# Check if HF username is provided
if ([string]::IsNullOrEmpty($HFUsername)) {
Write-Host "β ERROR: Please provide your Hugging Face username" -ForegroundColor Red
Write-Host "Usage: .\deploy_to_hf.ps1 -HFUsername 'your_username'" -ForegroundColor Yellow
Write-Host "Or set the HFUsername parameter in the script" -ForegroundColor Yellow
exit 1
}
Write-Host "π Deploying to: $HFUsername/$SpaceName" -ForegroundColor Blue
# Check if HF Space repository exists
if (Test-Path $SpaceName) {
Write-Host "β οΈ Directory $SpaceName already exists. Removing..." -ForegroundColor Yellow
Remove-Item -Recurse -Force $SpaceName
}
# Clone the HF Space repository
Write-Host "π₯ Cloning Hugging Face Space repository..." -ForegroundColor Blue
git clone "https://huggingface.co/spaces/$HFUsername/$SpaceName"
Set-Location $SpaceName
# Copy essential files from parent directory
Write-Host "π Copying migration files..." -ForegroundColor Blue
Copy-Item "..\app.py" .
Copy-Item "..\server.py" .
Copy-Item "..\requirements.txt" .
Copy-Item "..\Dockerfile" .
Copy-Item "..\README.md" .
Copy-Item "..\.gitattributes" .
Copy-Item "..\test_imports.py" .
Copy-Item "..\test_client.py" .
Copy-Item "..\HF_DEPLOYMENT_GUIDE.md" .
# Verify essential files are present
Write-Host "β
Verifying essential files..." -ForegroundColor Blue
$requiredFiles = @("app.py", "server.py", "requirements.txt", "Dockerfile")
foreach ($file in $requiredFiles) {
if (-not (Test-Path $file)) {
Write-Host "β ERROR: Required file $file is missing!" -ForegroundColor Red
exit 1
}
}
Write-Host "β
All required files copied successfully!" -ForegroundColor Green
# Add all files to git
Write-Host "π Adding files to git..." -ForegroundColor Blue
git add .
# Commit with descriptive message
Write-Host "πΎ Committing changes..." -ForegroundColor Blue
$commitMessage = @"
Complete ECG-FM migration with robust fairseq fallback system
- Migrated from fairseq-signals to main fairseq package
- Implemented 4-level fallback system
- Enhanced error handling and monitoring
- Ready for production deployment
Migration includes:
β
Robust import logic with multiple fallback levels
β
Enhanced error handling and real-time status reporting
β
Docker optimization for HF Spaces environment
β
Comprehensive testing and validation scripts
"@
git commit -m $commitMessage
# Push to trigger automatic build
Write-Host "π Pushing to Hugging Face Spaces..." -ForegroundColor Blue
git push origin main
Write-Host "β
Deployment initiated successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "π Your ECG-FM API is now being deployed to Hugging Face Spaces!" -ForegroundColor Cyan
Write-Host ""
Write-Host "π Next steps:" -ForegroundColor White
Write-Host "1. Monitor build progress at: https://huggingface.co/spaces/$HFUsername/$SpaceName" -ForegroundColor White
Write-Host "2. Wait for build completion (10-15 minutes for first build)" -ForegroundColor White
Write-Host "3. Test your API endpoints once deployed" -ForegroundColor White
Write-Host "4. Check the /healthz endpoint for system status" -ForegroundColor White
Write-Host ""
Write-Host "π Your API will be available at: https://$HFUsername-$SpaceName.hf.space" -ForegroundColor White
Write-Host ""
Write-Host "π For troubleshooting, see: HF_DEPLOYMENT_GUIDE.md" -ForegroundColor White
Write-Host ""
Write-Host "β
Deployment script completed! π" -ForegroundColor Green
# Return to parent directory
Set-Location ..
|