ground-zero / scripts /push_to_kaggle.sh
jefffffff9
Fix Kaggle push: title slug + Windows UTF-8 encoding
842ded5
#!/usr/bin/env bash
# push_to_kaggle.sh — Push the master trainer notebook to Kaggle.
#
# Called automatically by .git/hooks/post-commit when the notebook changes,
# or run manually:
# bash scripts/push_to_kaggle.sh
#
# Requirements:
# pip install kaggle
# Place ~/.kaggle/kaggle.json (download from kaggle.com → Settings → API)
set -euo pipefail
# Force UTF-8 on Windows so the Kaggle CLI can read emoji in notebook cells
export PYTHONUTF8=1
export PYTHONIOENCODING=utf-8
NOTEBOOK_DIR="$(cd "$(dirname "$0")/../notebooks" && pwd)"
NOTEBOOK_FILE="$NOTEBOOK_DIR/kaggle_master_trainer.ipynb"
METADATA_FILE="$NOTEBOOK_DIR/kernel-metadata.json"
# ── Prerequisite check ────────────────────────────────────────────────────────
if ! command -v kaggle &>/dev/null; then
echo "kaggle CLI not found — run: pip install kaggle"
exit 1
fi
# Accept auth via either KAGGLE_API_TOKEN env var (new) or kaggle.json (legacy)
if [[ -z "${KAGGLE_API_TOKEN:-}" && ! -f "$HOME/.kaggle/kaggle.json" ]]; then
echo "Kaggle credentials not found."
echo "Set the environment variable: KAGGLE_API_TOKEN=<your token>"
echo "Or place kaggle.json at: ~/.kaggle/kaggle.json"
exit 1
fi
if [[ -f "$HOME/.kaggle/kaggle.json" ]]; then
chmod 600 "$HOME/.kaggle/kaggle.json"
fi
# ── Push ──────────────────────────────────────────────────────────────────────
echo "Pushing notebook to Kaggle..."
echo " Notebook : $NOTEBOOK_FILE"
echo " Metadata : $METADATA_FILE"
kaggle kernels push -p "$NOTEBOOK_DIR"
echo "✅ Done — view at: https://www.kaggle.com/code/ous-sow/sahel-voice-master-trainer"