flare-upstream-watch.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env bash
  2. # Watch NVIDIA/flare-local-inference upstream.
  3. #
  4. # FLARE moves several times a day (12+ commits in one night), and our clones,
  5. # the per-host agent binaries and the prepared packages all have to agree with
  6. # it: the RoCE proxy ABI is pinned in the repo, the model recipes change, and a
  7. # package prepared with one revision can be refused by another.
  8. #
  9. # scripts/flare-upstream-watch.sh # what changed since the pin
  10. # scripts/flare-upstream-watch.sh --bump # move the pin to current HEAD
  11. #
  12. # The pin lives next to this file's spec (specs/tech-architecture/
  13. # flare-upstream.pin) as a single line: <sha> <committer-date>.
  14. set -euo pipefail
  15. REPO="NVIDIA/flare-local-inference"
  16. ROOT="$(cd "$(dirname "$0")/.." && pwd)"
  17. PIN_FILE="$ROOT/specs/tech-architecture/flare-upstream.pin"
  18. API="https://api.github.com/repos/$REPO"
  19. pin_sha=""
  20. pin_date=""
  21. if [[ -f "$PIN_FILE" ]]; then
  22. read -r pin_sha pin_date <"$PIN_FILE" || true
  23. fi
  24. json="$(curl -fsS -m25 "$API/commits?per_page=40")"
  25. head_sha="$(printf '%s' "$json" | python3 -c 'import json,sys; print(json.load(sys.stdin)[0]["sha"])')"
  26. head_date="$(printf '%s' "$json" | python3 -c 'import json,sys; d=json.load(sys.stdin)[0]["commit"]["committer"]; print(d["date"][:16])')"
  27. echo "upstream: $REPO"
  28. echo " HEAD ${head_sha:0:10} $head_date"
  29. echo " pinned ${pin_sha:0:10} ${pin_date:-never}"
  30. if [[ "${1:-}" == "--bump" ]]; then
  31. printf '%s %s\n' "$head_sha" "$head_date" >"$PIN_FILE"
  32. echo " pin moved to ${head_sha:0:10}"
  33. exit 0
  34. fi
  35. if [[ -z "$pin_sha" ]]; then
  36. echo " no pin recorded — run with --bump after reviewing"
  37. exit 0
  38. fi
  39. if [[ "$pin_sha" == "$head_sha" ]]; then
  40. echo " up to date"
  41. exit 0
  42. fi
  43. echo
  44. echo "new commits since the pin:"
  45. TMP_JSON="$(mktemp)"
  46. trap 'rm -f "$TMP_JSON"' EXIT
  47. printf '%s' "$json" >"$TMP_JSON"
  48. python3 - "$pin_sha" "$TMP_JSON" <<'PY'
  49. import json, re, sys
  50. pin = sys.argv[1]
  51. commits = json.load(open(sys.argv[2]))
  52. SIGNIFICANT = re.compile(
  53. r"roce|abi|flashinfer pin|speculat|dspark|dflash|mtp|recipe|deepseek|glm"
  54. r"|mimo|qwen|kimi|package|prepare|export|agent|orbit",
  55. re.I,
  56. )
  57. stopped = False
  58. for c in commits:
  59. sha = c["sha"]
  60. if sha == pin:
  61. stopped = True
  62. break
  63. msg = c["commit"]["message"].splitlines()[0]
  64. date = c["commit"]["committer"]["date"][:16]
  65. flag = " ⚠" if SIGNIFICANT.search(msg) else " "
  66. print(f"{flag} {sha[:10]} {date} {msg[:110]}")
  67. if not stopped:
  68. print("(pin is older than the 40 commits listed — fetch more)")
  69. PY
  70. cat <<'EOF'
  71. Before re-running a FLARE experiment, pull and rebuild BOTH sides — the
  72. per-host `flare` agent binaries and the prepared packages must come from the
  73. same revision, or the runtime refuses (see the "proxy ABI" row in
  74. specs/tech-architecture/flare-bringup.md).
  75. EOF