Spaces:
Sleeping
Sleeping
File size: 7,329 Bytes
de63014 | 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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | # ===========================================
# Script de déploiement final pour Hugging Face Spaces
# HOLOKIA-AVATAR - Avatar 3D Interactif
# ===========================================
param(
[switch]$Help,
[string]$HuggingFaceToken = ""
)
# Configuration
$HF_USERNAME = "DataSage12"
$SPACE_NAME = "avatar-v2"
$REPO_URL = "https://huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME"
# Fonctions utilitaires
function Write-Info {
param([string]$Message)
Write-Host "[INFO] $Message" -ForegroundColor Blue
}
function Write-Success {
param([string]$Message)
Write-Host "[SUCCESS] $Message" -ForegroundColor Green
}
function Write-Warning {
param([string]$Message)
Write-Host "[WARNING] $Message" -ForegroundColor Yellow
}
function Write-Error {
param([string]$Message)
Write-Host "[ERROR] $Message" -ForegroundColor Red
}
# Aide
if ($Help) {
Write-Host "Usage: .\deploy_to_hf_final.ps1 [OPTIONS]"
Write-Host ""
Write-Host "Options:"
Write-Host " -Help Afficher cette aide"
Write-Host " -HuggingFaceToken <token> Token d'accès Hugging Face (optionnel)"
Write-Host ""
Write-Host "Ce script déploie HOLOKIA-AVATAR sur Hugging Face Spaces."
Write-Host ""
Write-Host "Variables d'environnement requises:"
Write-Host " GROQ_API_KEY Clé API Groq"
Write-Host ""
exit 0
}
# Vérifications préliminaires
function Test-Requirements {
Write-Info "Vérification des prérequis..."
# Vérifier Git
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Error "Git n'est pas installé"
exit 1
}
# Vérifier Git LFS
if (-not (Get-Command git-lfs -ErrorAction SilentlyContinue)) {
Write-Error "Git LFS n'est pas installé"
Write-Info "Installez Git LFS: winget install Git.Git-LFS"
exit 1
}
# Vérifier la clé API Groq
$groqKey = $env:GROQ_API_KEY
if (-not $groqKey) {
Write-Error "GROQ_API_KEY n'est pas définie"
Write-Info "Définissez votre clé API avec: `$env:GROQ_API_KEY = 'your_key_here'"
exit 1
}
Write-Success "Tous les prérequis sont satisfaits"
Write-Info "Clé API Groq: $($groqKey.Substring(0, 10))..."
}
# Vérifier la structure du projet
function Test-ProjectStructure {
Write-Info "Vérification de la structure du projet..."
$requiredFiles = @(
"Dockerfile",
"app.py",
"requirements.txt",
"Back-end\start_services.py",
"Back-end\services\tts_service.py",
"Back-end\services\stt_service.py",
"Back-end\services\llm_service.py",
"Back-end\services\live_stream_service.py",
"frontend\package.json",
"frontend\src\App.jsx"
)
$missingFiles = @()
foreach ($file in $requiredFiles) {
if (-not (Test-Path $file)) {
$missingFiles += $file
}
}
if ($missingFiles.Count -gt 0) {
Write-Error "Fichiers manquants:"
foreach ($file in $missingFiles) {
Write-Host " - $file" -ForegroundColor Red
}
exit 1
}
Write-Success "Structure du projet validée"
}
# Configuration Git
function Set-GitConfiguration {
Write-Info "Configuration Git..."
# Vérifier si le remote HF existe
$existingRemote = git remote get-url origin 2>$null
if ($existingRemote) {
Write-Info "Remote existant: $existingRemote"
if ($existingRemote -ne $REPO_URL) {
Write-Info "Mise à jour du remote..."
git remote set-url origin $REPO_URL
}
} else {
Write-Info "Ajout du remote Hugging Face..."
git remote add origin $REPO_URL
}
# Configurer l'authentification si un token est fourni
if ($HuggingFaceToken) {
Write-Info "Configuration de l'authentification..."
$authUrl = $REPO_URL -replace "https://", "https://$HuggingFaceToken@"
git remote set-url origin $authUrl
}
Write-Success "Configuration Git terminée"
}
# Test de l'image Docker
function Test-DockerImage {
Write-Info "Test de l'image Docker localement..."
# Vérifier Docker
if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
Write-Warning "Docker n'est pas installé, test ignoré"
return
}
try {
# Construire l'image
Write-Info "Construction de l'image Docker..."
docker build -t holokia-avatar:test .
# Tester l'image
Write-Info "Test de l'image..."
$containerId = docker run -d -p 7860:7860 -e GROQ_API_KEY=$env:GROQ_API_KEY holokia-avatar:test
# Attendre le démarrage
Write-Info "Attente du démarrage du service..."
Start-Sleep -Seconds 60
# Vérifier la santé
try {
$response = Invoke-WebRequest -Uri "http://localhost:7860/health" -TimeoutSec 10
if ($response.StatusCode -eq 200) {
Write-Success "Test local réussi"
} else {
Write-Warning "Test local: code de statut $($response.StatusCode)"
}
} catch {
Write-Warning "Test local: service non accessible"
}
# Nettoyer
docker stop $containerId
docker rm $containerId
docker rmi holokia-avatar:test
} catch {
Write-Warning "Erreur lors du test Docker: $($_.Exception.Message)"
}
}
# Déploiement
function Deploy-ToHuggingFace {
Write-Info "Déploiement sur Hugging Face Spaces..."
# Ajouter tous les fichiers
git add .
# Commit
$commitMessage = "Deploy to Hugging Face Spaces - $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
git commit -m $commitMessage
# Push vers HF
Write-Info "Push vers Hugging Face..."
git push -u origin main
Write-Success "Déploiement terminé!"
}
# Affichage des informations
function Show-Info {
Write-Info "Informations de déploiement:"
Write-Host " - Utilisateur HF: $HF_USERNAME"
Write-Host " - Nom du Space: $SPACE_NAME"
Write-Host " - URL du Space: $REPO_URL"
Write-Host " - Clé API Groq: $($env:GROQ_API_KEY.Substring(0, 10))..."
Write-Host ""
}
# Fonction principale
function Main {
Write-Host "🚀 HOLOKIA-AVATAR - Déploiement sur Hugging Face Spaces" -ForegroundColor Cyan
Write-Host "=====================================================" -ForegroundColor Cyan
Write-Host ""
Show-Info
# Vérifications
Test-Requirements
Test-ProjectStructure
# Test Docker (optionnel)
Test-DockerImage
# Configuration Git
Set-GitConfiguration
# Déploiement
Deploy-ToHuggingFace
Write-Host ""
Write-Success "🎉 Déploiement terminé avec succès!"
Write-Host ""
Write-Info "Votre Space sera disponible à:"
Write-Host " $REPO_URL"
Write-Host ""
Write-Info "N'oubliez pas d'ajouter votre clé API Groq dans les secrets du Space:"
Write-Host " - Nom: GROQ_API_KEY"
Write-Host " - Valeur: $env:GROQ_API_KEY"
Write-Host ""
Write-Info "Le Space va automatiquement se construire et démarrer dans quelques minutes."
}
# Exécution
Main
|