Datasets:
Download tools/clone.sh from AtomicChat/calib-corpora: direct link, hf CLI and curl.
- Browser
- Download file 4.41 kB
-
https://huggingface.co/datasets/AtomicChat/calib-corpora/resolve/main/tools/clone.sh
- Command line
-
hf download hf://datasets/AtomicChat/calib-corpora/tools/clone.sh
-
curl -L -o clone.sh https://huggingface.co/datasets/AtomicChat/calib-corpora/resolve/main/tools/clone.sh
4.41 kB
| # Shallow-clone the repositories the calibration pool is harvested from. | |
| # | |
| # bash tools/clone.sh # into $CALIB_RAW, or ./raw | |
| # bash tools/clone.sh /path/to/raw | |
| # JOBS=12 bash tools/clone.sh /mnt/big/raw | |
| # | |
| # Nothing is pinned. Repositories move forward and that is wanted: fresher | |
| # upstream code is better calibration material. Builds are already reproducible | |
| # from the committed pool, not from these clones, so freezing them would buy | |
| # nothing and cost freshness. | |
| # | |
| # What does matter is knowing what you got. clone-manifest.tsv records the | |
| # commit and its date for every repository, and harvest.py copies that into the | |
| # provenance of each unit it creates. | |
| set -u | |
| RAW="${1:-${CALIB_RAW:-$PWD/raw}}" | |
| JOBS="${JOBS:-6}" | |
| # name | url | licence | |
| # | |
| # The licence column is not decoration. harvest.py reads this manifest and | |
| # refuses to put anything into the pool whose licence is not permissive. | |
| # thebookofshaders is all-rights-reserved: it is cloned so its structure can be | |
| # inspected, and it must never reach pool/. | |
| REPOS=" | |
| three.js|https://github.com/mrdoob/three.js|MIT | |
| drei|https://github.com/pmndrs/drei|MIT | |
| react-three-fiber|https://github.com/pmndrs/react-three-fiber|MIT | |
| gl-matrix|https://github.com/toji/gl-matrix|MIT | |
| webgpu-samples|https://github.com/webgpu/webgpu-samples|BSD-3-Clause | |
| webgl-fundamentals|https://github.com/gfxfundamentals/webgl-fundamentals|BSD-3-Clause | |
| thebookofshaders|https://github.com/patriciogonzalezvivo/thebookofshaders|ALL-RIGHTS-RESERVED | |
| webgl-noise|https://github.com/stegu/webgl-noise|MIT | |
| pixijs|https://github.com/pixijs/pixijs|MIT | |
| tween.js|https://github.com/tweenjs/tween.js|MIT | |
| glTF-Sample-Viewer|https://github.com/KhronosGroup/glTF-Sample-Viewer|Apache-2.0 | |
| ripgrep|https://github.com/BurntSushi/ripgrep|MIT | |
| serde|https://github.com/serde-rs/serde|MIT | |
| fmt|https://github.com/fmtlib/fmt|MIT | |
| json-cpp|https://github.com/nlohmann/json|MIT | |
| requests|https://github.com/psf/requests|Apache-2.0 | |
| flask|https://github.com/pallets/flask|BSD-3-Clause | |
| vite|https://github.com/vitejs/vite|MIT | |
| " | |
| TOTAL=$(echo "$REPOS" | grep -c '|') | |
| PARTS="$RAW/.manifest.d" | |
| echo "target : $RAW" | |
| echo "repos : $TOTAL" | |
| echo "parallel : $JOBS" | |
| echo | |
| mkdir -p "$PARTS" || { echo "cannot write to $RAW"; exit 1; } | |
| rm -f "$PARTS"/*.tsv | |
| export RAW PARTS | |
| # One repository. Clones it if absent, fast-forwards it if present, then writes | |
| # a single manifest line. Each worker writes its own file, so parallel runs | |
| # cannot interleave inside a line. | |
| clone_one() { | |
| name=$1 | |
| url=$2 | |
| lic=$3 | |
| dst="$RAW/$name" | |
| if [ -d "$dst/.git" ]; then | |
| if git -C "$dst" fetch --depth 1 -q origin 2>/dev/null \ | |
| && git -C "$dst" reset -q --hard FETCH_HEAD 2>/dev/null; then | |
| state=updated | |
| else | |
| state=STALE | |
| fi | |
| else | |
| rm -rf "$dst" | |
| if git clone --depth 1 --single-branch -q "$url" "$dst" 2>/dev/null; then | |
| state=cloned | |
| else | |
| state=FAILED | |
| fi | |
| fi | |
| if [ "$state" = "FAILED" ]; then | |
| printf '%-22s %-9s %s\n' "$name" "$state" "$url" | |
| return | |
| fi | |
| sha=$(git -C "$dst" rev-parse HEAD 2>/dev/null) | |
| when=$(git -C "$dst" log -1 --format=%cs 2>/dev/null) | |
| size=$(du -sh "$dst" 2>/dev/null | cut -f1) | |
| printf '%s\t%s\t%s\t%s\t%s\n' "$name" "$url" "$lic" "${sha:0:12}" "$when" \ | |
| > "$PARTS/$name.tsv" | |
| printf '%-22s %-9s %-14s %-12s %s\n' "$name" "$state" "${sha:0:12}" "$when" "$size" | |
| } | |
| export -f clone_one | |
| printf '%-22s %-9s %-14s %-12s %s\n' repo state commit date size | |
| printf '%-22s %-9s %-14s %-12s %s\n' ---- ----- ------ ---- ---- | |
| echo "$REPOS" | grep '|' | tr '|' '\n' \ | |
| | xargs -P "$JOBS" -n 3 bash -c 'clone_one "$0" "$1" "$2"' | |
| { | |
| printf '# repo\turl\tlicence\tcommit\tcommit_date\n' | |
| printf '# cloned %s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" | |
| cat "$PARTS"/*.tsv 2>/dev/null | sort | |
| } > "$RAW/clone-manifest.tsv" | |
| rm -rf "$PARTS" | |
| GOT=$(grep -vc '^#' "$RAW/clone-manifest.tsv") | |
| echo | |
| echo "$GOT of $TOTAL repositories on disk, $(du -sh "$RAW" 2>/dev/null | cut -f1)" | |
| echo "manifest: $RAW/clone-manifest.tsv" | |
| if [ "$GOT" -lt "$TOTAL" ]; then | |
| echo | |
| echo "Some repositories are missing. Rerun this script: the ones already" | |
| echo "here are fast-forwarded rather than recloned, so a retry is cheap." | |
| fi | |
| echo | |
| echo "next: python tools/harvest.py --raw $RAW --wiki <wiki-dir>" | |