nathanael-fijalkow commited on
Commit
dbdb0ce
·
1 Parent(s): dd66ec8

fix leaderboard format issues

Browse files
Files changed (1) hide show
  1. app.py +7 -91
app.py CHANGED
@@ -366,10 +366,8 @@ which adds the required metadata to the README.md file.
366
  new_entry = {
367
  "model_id": model_id,
368
  "user_id": user_id,
369
- "n_parameters": result.n_parameters,
370
- "legal_rate_first_try": result.legal_rate_first_try,
371
  "legal_rate": result.legal_rate,
372
- "games_played": result.games_played,
373
  "last_updated": datetime.now().strftime("%Y-%m-%d %H:%M"),
374
  }
375
 
@@ -467,9 +465,13 @@ with gr.Blocks(
467
  git clone https://huggingface.co/spaces/LLM-course/Chess1MChallenge
468
  ```
469
 
470
- 2. **Check the example solution** in the `example_solution/` folder for reference
 
 
 
 
 
471
 
472
- 3. **Train your model** using the provided training script or your own approach
473
 
474
  4. **Submit using the official script**:
475
  ```bash
@@ -564,91 +566,5 @@ with gr.Blocks(
564
  refresh_btn.click(refresh_leaderboard, outputs=leaderboard_html)
565
 
566
 
567
- # =============================================================================
568
- # Webhook Endpoint (mounted on Gradio's FastAPI app)
569
- # =============================================================================
570
-
571
- from fastapi import Request
572
- from fastapi.responses import JSONResponse
573
-
574
- @demo.app.post("/webhook")
575
- async def handle_webhook(request: Request):
576
- """
577
- Handle HuggingFace webhook events for automatic model evaluation.
578
-
579
- Triggered on model creation and update events in the organization.
580
- """
581
- # Verify webhook signature
582
- body = await request.body()
583
- signature = request.headers.get("X-Webhook-Signature")
584
-
585
- if not verify_webhook_signature(body, signature):
586
- print("[Webhook] Invalid signature")
587
- return JSONResponse({"error": "Invalid signature"}, status_code=401)
588
-
589
- try:
590
- payload = json.loads(body)
591
- except json.JSONDecodeError:
592
- return JSONResponse({"error": "Invalid JSON"}, status_code=400)
593
-
594
- event = payload.get("event", {})
595
- repo = payload.get("repo", {})
596
-
597
- action = event.get("action")
598
- scope = event.get("scope")
599
- repo_type = repo.get("type")
600
- repo_name = repo.get("name", "")
601
-
602
- print(f"[Webhook] Received: action={action}, scope={scope}, type={repo_type}, repo={repo_name}")
603
-
604
- # Only process model repos in our organization
605
- if repo_type != "model":
606
- return JSONResponse({"status": "ignored", "reason": "not a model"})
607
-
608
- if not repo_name.startswith(f"{ORGANIZATION}/"):
609
- return JSONResponse({"status": "ignored", "reason": "not in organization"})
610
-
611
- # Only process create and update actions
612
- if action not in ("create", "update"):
613
- return JSONResponse({"status": "ignored", "reason": f"action {action} not handled"})
614
-
615
- # Check if it looks like a chess model
616
- if not is_chess_model(repo_name):
617
- return JSONResponse({"status": "ignored", "reason": "not a chess model"})
618
-
619
- # Check if already queued or running
620
- with eval_lock:
621
- current_status = eval_status.get(repo_name)
622
- if current_status == "running":
623
- return JSONResponse({"status": "ignored", "reason": "evaluation already running"})
624
- if current_status == "queued":
625
- return JSONResponse({"status": "ignored", "reason": "already in queue"})
626
- eval_status[repo_name] = "queued"
627
-
628
- # Queue the model for evaluation
629
- eval_queue.put(repo_name)
630
- queue_size = eval_queue.qsize()
631
-
632
- print(f"[Webhook] Queued {repo_name} for evaluation (queue size: {queue_size})")
633
-
634
- return JSONResponse({
635
- "status": "queued",
636
- "model_id": repo_name,
637
- "queue_position": queue_size,
638
- })
639
-
640
-
641
- @demo.app.get("/webhook/status")
642
- async def webhook_status():
643
- """Get the current status of the evaluation queue."""
644
- with eval_lock:
645
- status_copy = dict(eval_status)
646
-
647
- return JSONResponse({
648
- "queue_size": eval_queue.qsize(),
649
- "evaluations": status_copy,
650
- })
651
-
652
-
653
  if __name__ == "__main__":
654
  demo.launch(server_name="0.0.0.0", server_port=7860)
 
366
  new_entry = {
367
  "model_id": model_id,
368
  "user_id": user_id,
 
 
369
  "legal_rate": result.legal_rate,
370
+ "legal_rate_first_try": result.legal_rate_first_try,
371
  "last_updated": datetime.now().strftime("%Y-%m-%d %H:%M"),
372
  }
373
 
 
465
  git clone https://huggingface.co/spaces/LLM-course/Chess1MChallenge
466
  ```
467
 
468
+ 2. **Check an example solution** in the `example_solution/` folder for reference
469
+
470
+ 3. **Train your model** using the provided training script or your own approach, and evaluate it locally:
471
+ ```bash
472
+ python -m src --model ./my_model
473
+ ```
474
 
 
475
 
476
  4. **Submit using the official script**:
477
  ```bash
 
566
  refresh_btn.click(refresh_leaderboard, outputs=leaderboard_html)
567
 
568
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
  if __name__ == "__main__":
570
  demo.launch(server_name="0.0.0.0", server_port=7860)