Spaces:
Sleeping
Sleeping
File size: 1,267 Bytes
b3d8455 6938bba b3d8455 6938bba b3d8455 6938bba b3d8455 6938bba b3d8455 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | """Create the Hub webhook that triggers HubAudit auto-audits.
OPS TEMPLATE — run manually ONLY when activating (Jobs cost money once they run).
Edit WATCHLIST to repos YOU control, and fill in the Job/handler target. This file
is intentionally a template: it is NOT executed by the build.
PYTHONPATH=. python scripts/setup_webhook.py
"""
from __future__ import annotations
import os # noqa: F401 (used by the commented-out secret example below)
from huggingface_hub import HfApi
# Only repos you own / explicitly opt in. NEVER strangers' repos.
WATCHLIST = ["BBLHesham/hubaudit"]
# The audit Job to trigger on each event (preferred: no always-on handler / no
# sleeping-Space problem). Get this id from `hf jobs run -d ...` (see the runbook).
JOB_ID = "<paste-the-audit-Job-id>"
def main() -> None:
api = HfApi()
webhook = api.create_webhook(
job_id=JOB_ID,
watched=[{"type": "model", "name": r} for r in WATCHLIST],
domains=["repo"],
# secret=os.environ["HUBAUDIT_WEBHOOK_SECRET"], # optional shared secret
)
print("created webhook:", webhook.id, "-> job", JOB_ID)
print("Next: push to a watched repo; confirm in `hf jobs ps -a` + the repo's Discussions.")
if __name__ == "__main__":
main()
|