#!/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}"