ggml
[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)
Brought by drakestapleton
| 1 | #!/usr/bin/env bash |
| 2 | # List GitHub Actions workflow runs that are not finished yet, grouped by status. |
| 3 | |
| 4 | set -euo pipefail |
| 5 | |
| 6 | usage() { |
| 7 | echo "usage: $(basename "$0") [-r owner/repo] [-s status]... [-b branch] [-w regex] [-t regex] [-f regex] [--kill [-y]]" |
| 8 | echo " -r, --repo repository (default: current)" |
| 9 | echo " -s, --status run status to include, repeatable (default: the not-finished ones)" |
| 10 | echo " -b, --branch branch to fetch runs for; exact match, handled by the API" |
| 11 | echo " -w, --workflow case-insensitive regex matched against the workflow name (client-side)" |
| 12 | echo " -t, --title case-insensitive regex matched against the run title (client-side)" |
| 13 | echo " -f, --filter case-insensitive regex matched against the branch name (client-side)" |
| 14 | echo " --kill cancel the selected runs (requires -b, -w, -t or -f)" |
| 15 | echo " -y, --yes skip the confirmation prompt of --kill" |
| 16 | } |
| 17 | |
| 18 | repo="" |
| 19 | branch="" |
| 20 | workflow="" |
| 21 | title="" |
| 22 | filter="" |
| 23 | kill=false |
| 24 | assume_yes=false |
| 25 | statuses=() |
| 26 | need_value() { echo "missing value for $1" >&2; exit 1; } |
| 27 | while [[ $# -gt 0 ]]; do |
| 28 | case "$1" in |
| 29 | -r|--repo) [[ $# -ge 2 ]] || need_value "$1"; repo="$2"; shift 2 ;; |
| 30 | -s|--status) [[ $# -ge 2 ]] || need_value "$1"; statuses+=("$2"); shift 2 ;; |
| 31 | -b|--branch) [[ $# -ge 2 ]] || need_value "$1"; branch="$2"; shift 2 ;; |
| 32 | -w|--workflow) [[ $# -ge 2 ]] || need_value "$1"; workflow="$2"; shift 2 ;; |
| 33 | -t|--title) [[ $# -ge 2 ]] || need_value "$1"; title="$2"; shift 2 ;; |
| 34 | -f|--filter) [[ $# -ge 2 ]] || need_value "$1"; filter="$2"; shift 2 ;; |
| 35 | --kill) kill=true; shift ;; |
| 36 | -y|--yes) assume_yes=true; shift ;; |
| 37 | -h|--help) usage; exit 0 ;; |
| 38 | *) echo "unknown argument: $1" >&2; exit 1 ;; |
| 39 | esac |
| 40 | done |
| 41 | |
| 42 | # one request per status: the API does not accept multiple statuses at once |
| 43 | [[ ${#statuses[@]} -gt 0 ]] || statuses=(in_progress queued pending waiting requested) |
| 44 | |
| 45 | [[ -n "$repo" ]] || repo=$(gh repo view --json nameWithOwner -q .nameWithOwner) |
| 46 | |
| 47 | query=("repos/$repo/actions/runs" -f per_page=100) |
| 48 | [[ -z "$branch" ]] || query+=(-f branch="$branch") |
| 49 | |
| 50 | selected=$( |
| 51 | for status in "${statuses[@]}"; do |
| 52 | gh api --paginate --method GET "${query[@]}" -f status="$status" -q '.workflow_runs[]' |
| 53 | done | jq -sr --arg branch "$branch" --arg workflow "$workflow" --arg title "$title" --arg filter "$filter" ' |
| 54 | unique_by(.id) |
| 55 | | map( |
| 56 | .age = ((now - (.run_started_at // .created_at | fromdate)) / 60 | floor) |
| 57 | | select( |
| 58 | ($branch == "" or .head_branch == $branch) and |
| 59 | ($workflow == "" or (.name | test($workflow; "i"))) and |
| 60 | ($title == "" or (.display_title | test($title; "i"))) and |
| 61 | ($filter == "" or (.head_branch | test($filter; "i"))) |
| 62 | ) |
| 63 | ) |
| 64 | | sort_by(.status, -.age)' |
| 65 | ) |
| 66 | |
| 67 | tsv=$(jq -r '.[] | [ .status, (.age | tostring) + "m", .name, .head_branch, .display_title, .html_url ] | @tsv' <<< "$selected") |
| 68 | |
| 69 | if [[ -z "$tsv" ]]; then |
| 70 | echo "no active runs in $repo" |
| 71 | exit 0 |
| 72 | fi |
| 73 | |
| 74 | printf 'STATUS\tAGE\tWORKFLOW\tBRANCH\tTITLE\tURL\n%s\n' "$tsv" | column -t -s $'\t' |
| 75 | echo |
| 76 | printf '%s:' "$repo" |
| 77 | for status in "${statuses[@]}"; do |
| 78 | printf ' %s=%s' "$status" "$(awk -F'\t' -v s="$status" '$1 == s' <<< "$tsv" | wc -l | tr -d ' ')" |
| 79 | done |
| 80 | echo |
| 81 | |
| 82 | if [[ "$kill" == false ]]; then |
| 83 | exit 0 |
| 84 | fi |
| 85 | |
| 86 | if [[ -z "$branch$workflow$title$filter" ]]; then |
| 87 | echo "refusing to cancel everything: pass -b, -w, -t or -f to select the runs to cancel" >&2 |
| 88 | exit 1 |
| 89 | fi |
| 90 | |
| 91 | count=$(wc -l <<< "$tsv" | tr -d ' ') |
| 92 | if [[ "$assume_yes" == false ]]; then |
| 93 | printf 'cancel %s run(s)? [y/N] ' "$count" |
| 94 | read -r reply </dev/tty || { echo; echo "aborted: no terminal to confirm on" >&2; exit 1; } |
| 95 | [[ "$reply" == [yY]* ]] || { echo "aborted"; exit 1; } |
| 96 | fi |
| 97 | |
| 98 | jq -r '.[] | [ .id, .status ] | @tsv' <<< "$selected" | |
| 99 | while IFS=$'\t' read -r id status; do |
| 100 | gh run cancel "$id" --repo "$repo" || echo "failed to cancel run $id (status: $status)" |
| 101 | done |