Spaces:
Sleeping
Sleeping
Add .gitattributes and sync script for GitHub + HF
Browse files- .gitattributes +3 -0
- sync.ps1 +65 -0
.gitattributes
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
* text=auto
|
| 2 |
+
*.sh text eol=lf
|
| 3 |
+
setup.sh text eol=lf
|
sync.ps1
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# sync.ps1 - Push local changes to BOTH GitHub and the HuggingFace Space.
|
| 2 |
+
#
|
| 3 |
+
# Usage:
|
| 4 |
+
# .\sync.ps1 "commit message" # commit + push to GitHub + upload to HF
|
| 5 |
+
# .\sync.ps1 # push + upload only (no new commit)
|
| 6 |
+
# .\sync.ps1 -DeployHfOnly # upload to HF only (skip GitHub)
|
| 7 |
+
#
|
| 8 |
+
# Requirements:
|
| 9 |
+
# - Git installed, authenticated for GitHub (git push)
|
| 10 |
+
# - HF CLI (venv\Scripts\hf.exe) authenticated (hf auth login)
|
| 11 |
+
|
| 12 |
+
param(
|
| 13 |
+
[string]$Message = "",
|
| 14 |
+
[switch]$DeployHfOnly
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
$ErrorActionPreference = "Stop"
|
| 18 |
+
$root = $PSScriptRoot
|
| 19 |
+
$hfCli = Join-Path $root "venv\Scripts\hf.exe"
|
| 20 |
+
$space = "aryaa-05/llm-hallucination"
|
| 21 |
+
|
| 22 |
+
Write-Host "=== Sync: $root ===" -ForegroundColor Cyan
|
| 23 |
+
|
| 24 |
+
# 0) Fresh venv hf CLI?
|
| 25 |
+
if (-not (Test-Path $hfCli)) {
|
| 26 |
+
Write-Warning "HF CLI not found at $hfCli"
|
| 27 |
+
$hfCli = "hf"
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
# 1) Optionally commit
|
| 31 |
+
if ($Message) {
|
| 32 |
+
git -C $root add -A
|
| 33 |
+
if (-not $Message) { $Message = "Update" }
|
| 34 |
+
git -C $root commit -m $Message
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
# 2) Push to GitHub (skip if not configured / DeployHfOnly)
|
| 38 |
+
if (-not $DeployHfOnly) {
|
| 39 |
+
$ghRemote = git -C $root remote
|
| 40 |
+
if ($ghRemote -match "origin") {
|
| 41 |
+
Write-Host "Pushing to GitHub (origin/main)..." -ForegroundColor Cyan
|
| 42 |
+
git -C $root push origin main
|
| 43 |
+
} else {
|
| 44 |
+
Write-Warning "No 'origin' remote configured; skipping GitHub push. Add one with: git remote add origin <url>"
|
| 45 |
+
}
|
| 46 |
+
} else {
|
| 47 |
+
Write-Host "Skipping GitHub push (DeployHfOnly)." -ForegroundColor Yellow
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
# 3) Upload to HF Space (file-level upload, triggers rebuild)
|
| 51 |
+
Write-Host "Uploading to HF Space $space ..." -ForegroundColor Cyan
|
| 52 |
+
& $hfCli upload $space $root "." --repo-type space `
|
| 53 |
+
--exclude ".git/*" `
|
| 54 |
+
--exclude "venv/*" `
|
| 55 |
+
--exclude "__pycache__/*" `
|
| 56 |
+
--exclude "*.pyc" `
|
| 57 |
+
--exclude "*.log" `
|
| 58 |
+
--exclude ".env" `
|
| 59 |
+
--exclude ".env.*" `
|
| 60 |
+
--commit-message "sync: $Message from local"
|
| 61 |
+
|
| 62 |
+
if ($LASTEXITCODE -ne 0) {
|
| 63 |
+
Write-Error "HF upload failed"
|
| 64 |
+
}
|
| 65 |
+
Write-Host "Done. HF Space will rebuild." -ForegroundColor Green
|