File size: 1,877 Bytes
4bd45bb
 
 
 
 
 
 
 
 
 
 
 
 
842ded5
 
 
 
4bd45bb
 
 
 
 
 
 
 
 
 
ac2363f
 
 
 
 
4bd45bb
 
ac2363f
 
 
4bd45bb
 
 
 
 
 
 
 
 
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
#!/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"