annals-math-rl-sample / generator /image /fetch_mathlib.sh
bkhtmm's picture
Publish two-task AnnalsChallenge sample
9ff6f66 verified
Raw History Blame Contribute Delete
972 Bytes
#!/usr/bin/env bash
# Unpack Mathlib's prebuilt cache in batches and truncate the files that importing Mathlib never
# reads (generated C and .ilean editor indexes), keeping their .hash files so Lake still sees every
# module as built. Lean + full Mathlib otherwise needs ~11 GB, more than a 10 GB sandbox disk.
set -euo pipefail
cd /opt/lean-env
trim() {
find .lake/packages -path '*/.lake/build/*' \( -name '*.c' -o -name '*.ilean' \) -size +0 -exec truncate -s 0 {} +
}
# Keep downloaded archives between categories. Mathlib's cache tool checks
# archive presence, not installed oleans, when deciding whether to download.
# Deleting them here would refetch each shared dependency for every category.
for dir in .lake/packages/mathlib/Mathlib/*/; do
name=$(basename "$dir")
echo "== Mathlib/$name"
lake exe cache get ".lake/packages/mathlib/Mathlib/$name" >/dev/null
trim
df -h / | tail -1
done
lake exe cache get
trim
rm -rf "${HOME:-/root}/.cache/mathlib"