Download .github/workflows/updraft-keepalive.yml from s-ttp/updraft: direct link, hf CLI and curl.
- Browser
- Download file 1.69 kB
-
https://huggingface.co/spaces/s-ttp/updraft/resolve/main/.github/workflows/updraft-keepalive.yml
- Command line
-
hf download hf://spaces/s-ttp/updraft/.github/workflows/updraft-keepalive.yml
-
curl -L -o updraft-keepalive.yml https://huggingface.co/spaces/s-ttp/updraft/resolve/main/.github/workflows/updraft-keepalive.yml
1.69 kB
| name: Updraft keep-alive and check | |
| # Daily (incl. weekends) so the free Space never reaches HF's 48-hour sleep, and so the ranking is rebuilt each | |
| # morning. Fails the run (= an email from GitHub) if the Space reports a problem: missing keys, a ranking older | |
| # than 3 days, or a data-build error. | |
| on: | |
| schedule: | |
| - cron: "30 12 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| check: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Wake and check | |
| env: | |
| URL: ${{ secrets.UPDRAFT_URL || 'https://s-ttp-updraft.hf.space' }} | |
| run: | | |
| for i in $(seq 1 40); do | |
| CODE=$(curl -s -o /tmp/h.json -w '%{http_code}' --max-time 30 "$URL/api/health" || echo 000) | |
| [ "$CODE" = "200" ] && break; echo "attempt $i: $CODE"; sleep 15 | |
| done | |
| [ "$CODE" = "200" ] || { echo "::error::Space not reachable"; exit 1; } | |
| cat /tmp/h.json; echo | |
| curl -s --max-time 120 "$URL/api/ranking" -o /tmp/r.json | |
| python3 - <<'PY' | |
| import json, sys | |
| h, r = json.load(open("/tmp/h.json")), json.load(open("/tmp/r.json")) | |
| problems = [k for k in ("data_key", "alpaca_keys", "rebalance_enabled") if not h.get(k)] | |
| err = (h.get("ranking_state") or {}).get("error") | |
| if err: problems.append("ranking build error: " + err) | |
| if r.get("age_hours", 0) > 72 and not r.get("building"): problems.append(f"ranking {r.get('age_hours')} h old") | |
| print("prices to", r.get("prices_as_of"), "· pool", r.get("pool"), "· top 3", [x["ticker"] for x in (r.get("ranked") or [])[:3]]) | |
| if problems: | |
| print("::error::" + "; ".join(problems)); sys.exit(1) | |
| PY | |