ecg-fm-api / deploy_to_hf_spaces.ps1
mystic_CBK
Deploy ECG-FM Dual Model API v2.0.0
31b6ae7
raw
history blame
4.2 kB
# πŸš€ ECG-FM Dual Model Deployment to HF Spaces
# PowerShell script to deploy the optimized dual-model ECG-FM API
Write-Host "πŸš€ DEPLOYING ECG-FM DUAL MODEL API TO HF SPACES" -ForegroundColor Green
Write-Host "=" * 60 -ForegroundColor Green
# Configuration
$SPACE_NAME = "mystic-cbk-ecg-fm-api"
$REPO_URL = "https://huggingface.co/spaces/mystic-cbk/$SPACE_NAME"
$LOCAL_DIR = "."
$BRANCH = "main"
Write-Host "πŸ“‹ Deployment Configuration:" -ForegroundColor Yellow
Write-Host " Space Name: $SPACE_NAME" -ForegroundColor White
Write-Host " Repository: $REPO_URL" -ForegroundColor White
Write-Host " Local Directory: $LOCAL_DIR" -ForegroundColor White
Write-Host " Branch: $BRANCH" -ForegroundColor White
Write-Host ""
# Check if git is available
try {
$gitVersion = git --version
Write-Host "βœ… Git available: $gitVersion" -ForegroundColor Green
} catch {
Write-Host "❌ Git not available. Please install Git first." -ForegroundColor Red
exit 1
}
# Check if we're in a git repository
if (-not (Test-Path ".git")) {
Write-Host "πŸ”„ Initializing git repository..." -ForegroundColor Yellow
git init
git add .
git commit -m "Initial commit: ECG-FM Dual Model API"
}
# Check current git status
Write-Host "πŸ“Š Current Git Status:" -ForegroundColor Yellow
git status
# Add all changes
Write-Host "πŸ”„ Adding all changes to git..." -ForegroundColor Yellow
git add .
# Commit changes
$commitMessage = "πŸš€ Deploy ECG-FM Dual Model API v2.0.0 - $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
Write-Host "πŸ’Ύ Committing changes: $commitMessage" -ForegroundColor Yellow
git commit -m $commitMessage
# Check if remote exists
$remotes = git remote -v
if ($remotes -match $SPACE_NAME) {
Write-Host "βœ… Remote already exists: $SPACE_NAME" -ForegroundColor Green
} else {
Write-Host "πŸ”„ Adding remote repository..." -ForegroundColor Yellow
git remote add origin $REPO_URL
}
# Push to HF Spaces
Write-Host "πŸš€ Pushing to Hugging Face Spaces..." -ForegroundColor Green
Write-Host " This will trigger automatic deployment..." -ForegroundColor White
Write-Host ""
try {
git push -u origin $BRANCH --force
Write-Host "βœ… Successfully pushed to HF Spaces!" -ForegroundColor Green
Write-Host ""
Write-Host "🌐 Your API will be available at:" -ForegroundColor Cyan
Write-Host " https://huggingface.co/spaces/mystic-cbk/$SPACE_NAME" -ForegroundColor White
Write-Host ""
Write-Host "πŸ“Š Monitor deployment progress at:" -ForegroundColor Cyan
Write-Host " https://huggingface.co/spaces/mystic-cbk/$SPACE_NAME/settings" -ForegroundColor White
Write-Host ""
Write-Host "⏱️ Deployment typically takes 5-10 minutes..." -ForegroundColor Yellow
Write-Host " Models will be downloaded automatically on first startup" -ForegroundColor White
} catch {
Write-Host "❌ Error pushing to HF Spaces: $_" -ForegroundColor Red
Write-Host ""
Write-Host "πŸ”§ Troubleshooting:" -ForegroundColor Yellow
Write-Host " 1. Check your HF token is set: git config --global credential.helper store" -ForegroundColor White
Write-Host " 2. Verify repository permissions" -ForegroundColor White
Write-Host " 3. Check internet connection" -ForegroundColor White
exit 1
}
Write-Host ""
Write-Host "πŸŽ‰ DEPLOYMENT INITIATED SUCCESSFULLY!" -ForegroundColor Green
Write-Host "=" * 60 -ForegroundColor Green
Write-Host ""
Write-Host "πŸ“‹ Next Steps:" -ForegroundColor Yellow
Write-Host " 1. Monitor deployment at HF Spaces" -ForegroundColor White
Write-Host " 2. Wait for models to download (5-10 minutes)" -ForegroundColor White
Write-Host " 3. Test API endpoints when ready" -ForegroundColor White
Write-Host " 4. Run batch analysis scripts" -ForegroundColor White
Write-Host ""
Write-Host "πŸ”— API Endpoints:" -ForegroundColor Cyan
Write-Host " β€’ /health - Health check" -ForegroundColor White
Write-Host " β€’ /analyze - Full ECG analysis (both models)" -ForegroundColor White
Write-Host " β€’ /extract_features - Feature extraction (pretrained model)" -ForegroundColor White
Write-Host " β€’ /assess_quality - Signal quality assessment" -ForegroundColor White