File size: 4,323 Bytes
ae31891
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208adf4
9c8de54
ef22967
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
# 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
}