Skip to content

Commit 6f0a9da

Browse files
authored
Add daily health check for HuggingFace leaderboard space (#195)
1 parent 04abb96 commit 6f0a9da

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Check Leaderboard Status
2+
3+
on:
4+
schedule:
5+
- cron: "0 8 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
check:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
issues: write
13+
steps:
14+
- name: Check HuggingFace Space status
15+
id: check
16+
run: |
17+
SPACE_API="https://huggingface.co/api/spaces/nvidia/kvpress-leaderboard"
18+
SPACE_URL="https://nvidia-kvpress-leaderboard.hf.space"
19+
20+
STAGE=$(curl -sf "$SPACE_API" | python3 -c "import sys,json; print(json.load(sys.stdin)['runtime']['stage'])" 2>/dev/null || echo "UNREACHABLE")
21+
22+
HTTP_CODE=$(curl -so /dev/null -w "%{http_code}" --max-time 30 "$SPACE_URL" 2>/dev/null || echo "000")
23+
24+
echo "stage=$STAGE" >> "$GITHUB_OUTPUT"
25+
echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT"
26+
27+
if [ "$STAGE" = "RUNNING" ] && [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 400 ]; then
28+
echo "healthy=true" >> "$GITHUB_OUTPUT"
29+
else
30+
echo "healthy=false" >> "$GITHUB_OUTPUT"
31+
fi
32+
33+
- name: Check for existing open issue
34+
if: steps.check.outputs.healthy == 'false'
35+
id: existing
36+
env:
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
COUNT=$(gh issue list \
40+
--repo "${{ github.repository }}" \
41+
--label "leaderboard-down" \
42+
--state open \
43+
--json number \
44+
--jq 'length')
45+
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
46+
47+
- name: Open issue
48+
if: steps.check.outputs.healthy == 'false' && steps.existing.outputs.count == '0'
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
STAGE: ${{ steps.check.outputs.stage }}
52+
HTTP_CODE: ${{ steps.check.outputs.http_code }}
53+
run: |
54+
DATE=$(date -u +"%Y-%m-%d")
55+
56+
BODY="The [KVPress Leaderboard](https://huggingface.co/spaces/nvidia/kvpress-leaderboard) appears to be down.
57+
58+
- **HF Space runtime stage:** \`${STAGE}\` (expected \`RUNNING\`)
59+
- **HTTP status code:** \`${HTTP_CODE}\`
60+
- **Detected at:** ${DATE} (UTC)
61+
62+
You can restart the space from the HuggingFace settings page:
63+
https://huggingface.co/spaces/nvidia/kvpress-leaderboard/settings"
64+
65+
gh issue create \
66+
--repo "${{ github.repository }}" \
67+
--title "Leaderboard is down ($DATE)" \
68+
--label "leaderboard-down" \
69+
--body "$BODY"

0 commit comments

Comments
 (0)