soyailabs / upload_to_hf.ps1
SOY NV AI
Fix Ollama communication error and update Railway PostgreSQL setup guide
ef22967
raw
history blame
4.32 kB
# Hugging Face Spaces μ—…λ‘œλ“œ 슀크립트
# μ‚¬μš©λ²•: .\upload_to_hf.ps1 -HFSpacePath "C:\path\to\huggingface\space"
param(
[Parameter(Mandatory=$true)]
[string]$HFSpacePath
)
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Hugging Face Spaces μ—…λ‘œλ“œ μ€€λΉ„" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
# 경둜 확인
if (-not (Test-Path $HFSpacePath)) {
Write-Host "였λ₯˜: Hugging Face Spaces 디렉토리λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€: $HFSpacePath" -ForegroundColor Red
Write-Host "λ¨Όμ € 'git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME' λͺ…λ ΉμœΌλ‘œ ν΄λ‘ ν•˜μ„Έμš”." -ForegroundColor Yellow
exit 1
}
Write-Host "`nλŒ€μƒ 디렉토리: $HFSpacePath" -ForegroundColor Green
# ν˜„μž¬ 디렉토리 확인
$currentDir = Get-Location
Write-Host "ν˜„μž¬ 디렉토리: $currentDir" -ForegroundColor Green
# ν•„μˆ˜ 파일 확인
$requiredFiles = @("app.py", "Dockerfile", "requirements.txt", "README_HF.md")
$missingFiles = @()
foreach ($file in $requiredFiles) {
if (-not (Test-Path $file)) {
$missingFiles += $file
}
}
if ($missingFiles.Count -gt 0) {
Write-Host "`n였λ₯˜: λ‹€μŒ ν•„μˆ˜ 파일이 μ—†μŠ΅λ‹ˆλ‹€:" -ForegroundColor Red
foreach ($file in $missingFiles) {
Write-Host " - $file" -ForegroundColor Red
}
exit 1
}
# ν•„μˆ˜ 디렉토리 확인
$requiredDirs = @("app", "templates", "static")
$missingDirs = @()
foreach ($dir in $requiredDirs) {
if (-not (Test-Path $dir)) {
$missingDirs += $dir
}
}
if ($missingDirs.Count -gt 0) {
Write-Host "`n였λ₯˜: λ‹€μŒ ν•„μˆ˜ 디렉토리가 μ—†μŠ΅λ‹ˆλ‹€:" -ForegroundColor Red
foreach ($dir in $missingDirs) {
Write-Host " - $dir" -ForegroundColor Red
}
exit 1
}
Write-Host "`nν•„μˆ˜ 파일 및 디렉토리 확인 μ™„λ£Œ!" -ForegroundColor Green
# 파일 볡사 μ‹œμž‘
Write-Host "`n파일 볡사 μ‹œμž‘..." -ForegroundColor Yellow
try {
# ν•„μˆ˜ 파일 볡사
Write-Host "`n[1/4] ν•„μˆ˜ 파일 볡사 쀑..." -ForegroundColor Cyan
Copy-Item "app.py" "$HFSpacePath\" -Force
Copy-Item "Dockerfile" "$HFSpacePath\" -Force
Copy-Item "requirements.txt" "$HFSpacePath\" -Force
Copy-Item "README_HF.md" "$HFSpacePath\README.md" -Force
Write-Host " βœ“ ν•„μˆ˜ 파일 볡사 μ™„λ£Œ" -ForegroundColor Green
# app 디렉토리 볡사
Write-Host "`n[2/4] app 디렉토리 볡사 쀑..." -ForegroundColor Cyan
if (Test-Path "$HFSpacePath\app") {
Remove-Item "$HFSpacePath\app" -Recurse -Force
}
Copy-Item -Recurse "app" "$HFSpacePath\app" -Force
Write-Host " βœ“ app 디렉토리 볡사 μ™„λ£Œ" -ForegroundColor Green
# templates 디렉토리 볡사
Write-Host "`n[3/4] templates 디렉토리 볡사 쀑..." -ForegroundColor Cyan
if (Test-Path "$HFSpacePath\templates") {
Remove-Item "$HFSpacePath\templates" -Recurse -Force
}
Copy-Item -Recurse "templates" "$HFSpacePath\templates" -Force
Write-Host " βœ“ templates 디렉토리 볡사 μ™„λ£Œ" -ForegroundColor Green
# static 디렉토리 볡사
Write-Host "`n[4/4] static 디렉토리 볡사 쀑..." -ForegroundColor Cyan
if (Test-Path "$HFSpacePath\static") {
Remove-Item "$HFSpacePath\static" -Recurse -Force
}
Copy-Item -Recurse "static" "$HFSpacePath\static" -Force
Write-Host " βœ“ static 디렉토리 볡사 μ™„λ£Œ" -ForegroundColor Green
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host "파일 볡사 μ™„λ£Œ!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "`nλ‹€μŒ 단계:" -ForegroundColor Yellow
Write-Host "1. Hugging Face Spaces λ””λ ‰ν† λ¦¬λ‘œ 이동: cd $HFSpacePath" -ForegroundColor White
Write-Host "2. Git 컀밋: git add ." -ForegroundColor White
Write-Host "3. Git 컀밋: git commit -m 'Initial deployment'" -ForegroundColor White
Write-Host "4. Git ν‘Έμ‹œ: git push" -ForegroundColor White
Write-Host "`nλ˜λŠ” Hugging Face μ›Ή μΈν„°νŽ˜μ΄μŠ€μ—μ„œ νŒŒμΌμ„ ν™•μΈν•˜κ³  μ»€λ°‹ν•˜μ„Έμš”." -ForegroundColor White
} catch {
Write-Host "`n였λ₯˜ λ°œμƒ: $_" -ForegroundColor Red
exit 1
}