ggml
[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)
Brought by drakestapleton
ggml / .github / actions / ccache-buckets / action.yml
| 1 | name: "ccache-buckets" |
| 2 | description: "Save/restore latest GitHub Actions ccache matching a key prefix to/from HF buckets" |
| 3 | inputs: |
| 4 | key: |
| 5 | description: "Cache key prefix to match and load" |
| 6 | required: true |
| 7 | folder: |
| 8 | description: "Bucket folder containing ccache files" |
| 9 | required: true |
| 10 | evict-old-files: |
| 11 | description: "Corresponds to the ccache --evict-older-than AGE option, where AGE is the number of seconds or days followed by the 's' or 'd' suffix respectively." |
| 12 | default: '' |
| 13 | save: |
| 14 | description: "Save ccache" |
| 15 | required: false |
| 16 | default: false |
| 17 | type: boolean |
| 18 | hf_bucket: |
| 19 | description: 'Hugging Face buckets path' |
| 20 | required: true |
| 21 | |
| 22 | runs: |
| 23 | using: "composite" |
| 24 | steps: |
| 25 | - name: Install Hugging Face Hub CLI |
| 26 | shell: bash |
| 27 | run: | |
| 28 | python3 -m venv .venv-hf |
| 29 | .venv-hf/bin/pip install -U huggingface_hub==1.28.0 |
| 30 | |
| 31 | - name: Restore ccache from buckets |
| 32 | if: ${{ inputs.save != 'true' }} |
| 33 | shell: bash |
| 34 | run: | |
| 35 | set +e -uo pipefail |
| 36 | source .venv-hf/bin/activate |
| 37 | CCACHE_DIR=$(ccache -k cache_dir) |
| 38 | if [[ -d "$CCACHE_DIR" ]]; then |
| 39 | CACHE_PATH=$(hf buckets list "hf://buckets/${{ inputs.hf_bucket }}/${{ inputs.folder }}" --json | jq -r '[.[] | select(.type == "file") | select(.path | startswith("${{ inputs.folder }}/${{ inputs.key }}") and endswith(".tar.gz"))] | sort_by(.path) | last | .path // ""') |
| 40 | if [[ -n "$CACHE_PATH" ]]; then |
| 41 | echo "Restoring ccache from '$CACHE_PATH'." |
| 42 | hf buckets cp "hf://buckets/${{ inputs.hf_bucket }}/$CACHE_PATH" ccache_bucket.tar.gz |
| 43 | mkdir -p ccache_bucket |
| 44 | if tar -xzf ccache_bucket.tar.gz -C ccache_bucket; then |
| 45 | rm -rf "$CCACHE_DIR" |
| 46 | mv ccache_bucket "$CCACHE_DIR" |
| 47 | ccache -z |
| 48 | fi |
| 49 | rm ccache_bucket.tar.gz |
| 50 | else |
| 51 | echo "No ccache found." |
| 52 | fi |
| 53 | else |
| 54 | echo "'$CCACHE_DIR' not found." |
| 55 | fi |
| 56 | |
| 57 | - name: Save ccache to buckets |
| 58 | if: ${{ inputs.save == 'true' }} |
| 59 | shell: bash |
| 60 | run: | |
| 61 | if [[ -n "$HF_TOKEN" ]]; then |
| 62 | set +e -uo pipefail |
| 63 | source .venv-hf/bin/activate |
| 64 | CCACHE_DIR=$(ccache -k cache_dir) |
| 65 | if [[ -d "$CCACHE_DIR" ]]; then |
| 66 | ccache -s |
| 67 | if [[ -n "${{ inputs.evict-old-files }}" ]]; then |
| 68 | ccache --evict-older-than "${{ inputs.evict-old-files }}" |
| 69 | fi |
| 70 | DATESTAMP=$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 71 | CACHEFILE="${{ inputs.key }}-$DATESTAMP.tar.gz" |
| 72 | if tar -czf ccache_bucket.tar.gz -C "$CCACHE_DIR" .; then |
| 73 | hf buckets cp ccache_bucket.tar.gz "hf://buckets/${{ inputs.hf_bucket }}/${{ inputs.folder }}/$CACHEFILE" |
| 74 | fi |
| 75 | rm ccache_bucket.tar.gz |
| 76 | else |
| 77 | echo "'$CCACHE_DIR' not found." |
| 78 | fi |
| 79 | fi |
| 80 | |
| 81 | - name: Remove old ccache files from buckets |
| 82 | if: ${{ inputs.save == 'true' }} |
| 83 | shell: bash |
| 84 | run: | |
| 85 | if [[ -n "$HF_TOKEN" ]]; then |
| 86 | set +e -uo pipefail |
| 87 | source .venv-hf/bin/activate |
| 88 | CACHE_FILES=$(hf buckets list "hf://buckets/${{ inputs.hf_bucket }}/${{ inputs.folder }}" --json | jq -r '[.[] | select(.type == "file") | select((.uploaded_at | .[:19]+"Z" | fromdateiso8601) < (now - 5 * 60)) | select(.path | startswith("${{ inputs.folder }}/${{ inputs.key }}") and endswith(".tar.gz"))] | sort_by(.path)[:-1] | .[] | [.path // ""] | @tsv') |
| 89 | if [[ -n "$CACHE_FILES" ]]; then |
| 90 | echo "Removing old ccache files..." |
| 91 | while IFS=$'\t' read -r CACHE_PATH; do |
| 92 | hf buckets rm "hf://buckets/${{ inputs.hf_bucket }}/$CACHE_PATH" -y |
| 93 | done <<< "$CACHE_FILES" |
| 94 | fi |
| 95 | fi |