#!/usr/bin/env bash
# Real demos for P195 "Google Colab: Full Tutorial for Beginners".
# Joe's notebook, sent cell by cell to real Google Colab runtimes with Google's colab CLI (~/.venvs/colab, signed in
# on the main Mac): runtime 1 CPU, runtime 2 T4 GPU, runtime 3 CPU (root, apt, a chart, sample data). Each cell's
# code and output go to lab/raw_output.json; lab/tidy.py writes demo_output.json (progress bars, traceback rules,
# the CLI's local image path and the account balance dropped). lab/shots.py and lab/chart_shot.py capture Colab's
# public pages (signed out) and the chart Colab drew. A `colab exec` sometimes never returns after the cell finished
# (the kernel goes idle): cells now time out after 300 s without output and are retried; runtime 2's last cells can
# be finished on the same session with `gpu_tail`.
set -euo pipefail
cd "$(dirname "$0")"
python3 lab/make_swaps.py
python3 lab/colab_lab.py              # runtimes 1 and 2
python3 lab/colab_lab.py extra --resume
cp demo_output.json lab/raw_output.json
python3 lab/tidy.py
cd ../.. && python3 videos/google-colab-tutorial/lab/shots.py && python3 videos/google-colab-tutorial/lab/chart_shot.py
