No description
  • Python 89.2%
  • HTML 8.7%
  • Just 1%
  • Dockerfile 0.6%
  • Shell 0.5%
Find a file
Ryan Cheley 88724dc30a
🔧 Upgrade to Python 3.15 and refresh dependencies (#77)
- Bump Docker base image, requires-python, and CI to Python 3.15
- uv lock --upgrade to refresh all dependencies
- Fix lint/type findings from updated ruff/ty; noqa deliberate broad-except

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-20 18:16:39 -07:00
.claude/commands 🤖 help the robot 2026-04-19 18:20:14 -07:00
.github 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
docs added docs 2025-01-18 08:23:54 -08:00
plugins 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
tests 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
.dockerignore 🐳 dockerize the datasette app 2025-12-29 09:23:16 -08:00
.gitattributes allow diff of sqlite files 2025-01-18 08:24:42 -08:00
.gitignore 🙈 exclude backup sqlite db 2026-04-18 10:34:22 -07:00
CLAUDE.md 🔧 (ci): expand prek config with security hooks and workflow hardening (#76) 2026-10-11 08:24:16 -07:00
docker-compose.yml 🐳 update docker settings 2026-04-14 05:41:57 -07:00
docker-run.sh 🐳 dockerize the datasette app 2025-12-29 09:23:16 -08:00
Dockerfile 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
entrypoint.sh 🐳 (docker): handle db.sqlite3 created as directory on Coolify 2025-12-29 12:58:07 -08:00
hockeydb_scraper.py 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
justfile 🐛 (playoffs): fix predictor eliminations based on actual game results (#61) 2026-05-07 05:23:06 -07:00
metadata.json 🔧 (fix): Regenerate metadata.json with corrected game status patterns 2026-04-01 14:18:44 -07:00
metadata.yaml ✏️ update description for canned query 2026-04-15 05:35:17 -07:00
migrate_venue_coordinates.py 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
monte_carlo.py 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
playoff_predictor.py 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
playoff_simulations.py 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
prek.toml 🔧 (ci): expand prek config with security hooks and workflow hardening (#76) 2026-10-11 08:24:16 -07:00
program.py 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
pyproject.toml 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
README.md 📝 Remove dangling .env.example reference in README (#66) 2026-08-16 13:54:49 -07:00
retrain.py 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00
uv.lock 🔧 Upgrade to Python 3.15 and refresh dependencies (#77) 2026-10-20 18:16:39 -07:00

AHL Scraper

A Python web scraping application that collects comprehensive game data from the American Hockey League (AHL) and serves it through an interactive datasette interface.

Features

  • 42 Seasons of Historical Data — Complete game records from Season 49 through Season 91 (12,799+ games)
  • Current Season Coverage — Season 90 (2025-26) with 798 played games, including scores, attendance, goals, and penalties
  • Player Database — 9,013+ players with biographical information
  • Game Rosters — Complete roster data linking players to games (21,060+ entries)
  • Automated Updates — Daily scheduled scraping to keep data current
  • Interactive Analytics — Powered by datasette for SQL-based data exploration

Season 90 (2025-26) Analytics

Playoff Predictions

The application includes Monte Carlo-based playoff bracket predictions that update daily as the regular season progresses.

Features

  • Projected Brackets — Generate playoff predictions based on current standings for seasons before playoffs begin
  • Daily Updates — Update predictions as teams' records change throughout the season
  • Win Probabilities — Monte Carlo simulations show likelihood of each series outcome
  • Interactive Visualization — View brackets and predictions in the /playoffs datasette page

Quick Start

For ongoing season predictions:

# Generate or update projected playoffs for Season 90 (2025-26)
uv run playoff_predictor.py update --season-id 90 --projected

Once the playoff season is officially created:

# Update with actual playoff results
uv run playoff_predictor.py update --season-id 90

Configuration

The system uses environment variables to map regular seasons to playoff seasons. Create a .env file in the project root:

# .env
AHL_SEASON_PAIRS={"77": 80, "81": 84, "86": 88, "90": 92}

Default mapping (if no .env file):

  • Season 77 → Playoff 80 (2022-23)
  • Season 81 → Playoff 84 (2023-24)
  • Season 86 → Playoff 88 (2024-25)
  • Season 90 → Playoff 92 (2025-26, once created)

Use null for seasons where the playoff season hasn't been created yet:

AHL_SEASON_PAIRS={"77": 80, "81": 84, "86": 88, "90": null}

Deployment

Environment Variables:

  • Set AHL_SEASON_PAIRS as an environment variable on your deployment platform
  • Coolify: Add in dashboard → Variables
  • Docker Compose: Set in environment: section
  • GitHub Actions: Use repository secrets

Daily Cronjob:

# Add to your cronjob or CI/CD scheduler
0 2 * * * cd /path/to/ahl && AHL_SEASON_PAIRS='{"77": 80, "81": 84, "86": 88, "90": 92}' uv run playoff_predictor.py update --season-id 90 --projected

Commands

  • playoff_predictor.py init — Create playoff prediction tables
  • playoff_predictor.py update [--season-id N] [--projected] [--n-simulations 1000] — Generate/update predictions
  • playoff_predictor.py status [--season-id N] — Show last update time and prediction counts

Getting Started

Prerequisites

  • Python 3.14+
  • Just (recommended for command running)
  • Docker (optional, for containerized deployment)

Development Setup

  1. Clone the repository

    git clone https://github.com/ryancheley/ahl.git
    cd ahl
    
  2. Install dependencies

    uv sync              # Install dependencies from pyproject.toml
    
  3. Run the scraper

    just load            # Execute the main scraping script
    

Common Commands

Scraping & Data

  • just load — Execute the main scraping script
  • just game <game_id> — Get specific game data
  • just recent — Show most recent game ID

Datasette

  • just datasette — Install datasette dependencies and serve data locally

Testing

  • pytest — Run test suite

Docker (Deployment)

  • just build — Build Docker images
  • just up — Start Docker services
  • just down — Stop Docker services
  • just logs — View Docker service logs
  • just docker-test — Build, start, and test both endpoints

See CLAUDE.md for comprehensive development documentation.

Architecture

The project uses SQLite for data storage:

  • my_database.db — SQLite database with all scraped game data (games, goals, penalties, officials, players, game rosters, teams, arenas, conferences, divisions, seasons, dates)

Data Flow

  1. program.py scrapes the AHL website (lscluster.hockeytech.com)
  2. Updates my_database.db with raw game data
  3. Datasette provides interactive SQL interface at ahl-data.ryancheley.com

Code Quality

  • Formatter: ruff
  • Type Checker: ty
  • Testing: pytest-based test suite
  • Pre-commit Hooks: prek validates commit messages (emoji prefix), formatting, and requirements compilation