Spaces:
Running on Zero
Running on Zero
Download dev/agent/scoreboard/example_run.py from jjerlee/rinklytics: direct link, hf CLI and curl.
- Browser
- Download file 3.21 kB
-
https://huggingface.co/spaces/jjerlee/rinklytics/resolve/main/dev/agent/scoreboard/example_run.py
- Command line
-
hf download hf://spaces/jjerlee/rinklytics/dev/agent/scoreboard/example_run.py
-
curl -L -o example_run.py https://huggingface.co/spaces/jjerlee/rinklytics/resolve/main/dev/agent/scoreboard/example_run.py
3.21 kB
| """ | |
| example_run.py β Demonstration script for the Scoreboard Agent Framework. | |
| Runs end-to-end extraction, statistical milestone detection, and journalistic narration | |
| for a multi-game slate and deep-dives into a thrilling single matchup. | |
| """ | |
| import os | |
| import sys | |
| from pathlib import Path | |
| # Add current directory and repo root to Python path | |
| current_dir = Path(__file__).parent | |
| if str(current_dir) not in sys.path: | |
| sys.path.insert(0, str(current_dir)) | |
| repo_root = current_dir.parent.parent.parent | |
| if str(repo_root) not in sys.path: | |
| sys.path.insert(0, str(repo_root)) | |
| try: | |
| from dev.agent.scoreboard.agent import ScoreboardAgent | |
| except (ImportError, ValueError): | |
| from agent import ScoreboardAgent | |
| def run_demonstration(): | |
| print("=" * 75) | |
| print("π NHL SCOREBOARD AGENT FRAMEWORK β DEMONSTRATION") | |
| print("=" * 75) | |
| agent = ScoreboardAgent() | |
| # 1. Detect latest slate date (or test with 2026-10-13) | |
| target_date = "2026-10-13" | |
| print(f"\n[Step 1] Ingesting and collectively analyzing slate for {target_date}...") | |
| slate = agent.analyze_slate(target_date, save_report=True) | |
| print(f"\nπ Slate Overview ({slate.date}):") | |
| print(f" β’ Total Matchups: {slate.total_games}") | |
| print(f" β’ Total Goals Scored: {slate.total_goals} (Avg {slate.avg_goals_per_game:.1f} per game)") | |
| print(f" β’ Outcome Distribution: {slate.home_wins} Home Wins, {slate.away_wins} Road Wins") | |
| print(f" β’ Overtime/Shootout Drama: {slate.ot_so_games} games went beyond regulation") | |
| print("\nπ League-Wide Three Stars of the Night:") | |
| for star in slate.slate_three_stars: | |
| print(f" β Star #{star.star}: {star.name} ({star.team_abbrev} - {star.position}) | {star.stat_summary}") | |
| print("\nπ₯ Key Slate Milestones Detected:") | |
| for n in slate.slate_notables[:4]: | |
| print(f" β’ [{n.category.upper()}] {n.title}: {n.description}") | |
| # 2. Deep Dive into Single Thriller Game | |
| sample_game_id = 2026020090 # NJD @ DET (5-4 OT) | |
| print(f"\n[Step 2] Running deep-dive narrative analysis for Game {sample_game_id} (NJD @ DET)...") | |
| game = agent.analyze_game(sample_game_id, save_report=True) | |
| print(f"\nπ° Generated Headline:") | |
| print(f" \"{game.headline}\"") | |
| print(f"\nπ Narrative Recap:") | |
| for p in game.recap_narrative.split("\n\n"): | |
| print(f" {p}") | |
| print(f"\nβ Game Three Stars:") | |
| for s in game.three_stars: | |
| print(f" β’ Star {s.star}: {s.name} ({s.team_abbrev}) - {s.stat_summary}") | |
| print(f"\nπ Head-to-Head Team Sheet:") | |
| print(f" β’ {game.away_team.team_abbrev}: {game.away_team.score} Goals | {game.away_team.sog} SOG | PP: {game.away_team.power_play_conv} | {game.away_team.hits} Hits | {game.away_team.faceoff_pct:.1f}% FO") | |
| print(f" β’ {game.home_team.team_abbrev}: {game.home_team.score} Goals | {game.home_team.sog} SOG | PP: {game.home_team.power_play_conv} | {game.home_team.hits} Hits | {game.home_team.faceoff_pct:.1f}% FO") | |
| print("\n" + "=" * 75) | |
| print(f"β Success! Reports generated and saved in:") | |
| print(f" π {agent.output_dir}") | |
| print("=" * 75) | |
| if __name__ == "__main__": | |
| run_demonstration() | |