File size: 1,831 Bytes
dcd2bd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# Push this repo to Hugging Face Hub. Loads HF_TOKEN from .env (never printed).
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

if [[ ! -f .env ]]; then
  echo "Missing .env with HF_TOKEN in $ROOT"
  exit 1
fi

set -a
# shellcheck disable=SC1091
source .env
set +a

if [[ -z "${HF_TOKEN:-}" ]]; then
  echo "HF_TOKEN is not set in .env"
  exit 1
fi

REPO_ID="psidharth567/personal_math"

if [[ ! -d .git ]]; then
  git init
fi

command -v git-lfs >/dev/null && git lfs install
command -v git-lfs >/dev/null && git lfs track "*.pth" || true

git config user.email "${GIT_USER_EMAIL:-psidharth567@users.noreply.huggingface.co}"
git config user.name "${GIT_USER_NAME:-psidharth567}"

git add -A
if git diff --cached --quiet; then
  echo "Nothing new to commit."
else
  git commit -m "Initial commit: math denoising experiments, checkpoints, logs"
fi

# Hugging Face CLI auth for git
if command -v hf >/dev/null 2>&1; then
  hf auth login --token "$HF_TOKEN" --add-to-git-credential
  hf repos create "$REPO_ID" --repo-type model --exist-ok --token "$HF_TOKEN" || true
else
  echo "hf CLI not found; install: pip install -U huggingface_hub"
  exit 1
fi

if ! git remote get-url origin >/dev/null 2>&1; then
  git remote add origin "https://huggingface.co/${REPO_ID}"
fi

git branch -M main 2>/dev/null || true

# Avoid broken IDE/git-credential helpers in headless environments: push with token URL once.
AUTH_REMOTE="https://oauth2:${HF_TOKEN}@huggingface.co/${REPO_ID}.git"

echo "[*] Pushing to https://huggingface.co/${REPO_ID} (this may take a long time for large checkpoints)..."
# Disable helpers that may point at VS Code / missing sockets
GIT_TERMINAL_PROMPT=0 git -c credential.helper= push -u "$AUTH_REMOTE" main

echo "[+] Done: https://huggingface.co/${REPO_ID}"