| #!/usr/bin/env bash |
| |
| 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 |
| |
| 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 |
|
|
| |
| 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 |
|
|
| |
| 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)..." |
| |
| GIT_TERMINAL_PROMPT=0 git -c credential.helper= push -u "$AUTH_REMOTE" main |
|
|
| echo "[+] Done: https://huggingface.co/${REPO_ID}" |
|
|