Skip to main content

Utilities for MyLaps Event Results API.

Project description

speedhive-tools

CLI toolkit and Python library for the MyLaps Speedhive Event Results API.

Install

pip install speedhive-tools

For local development:

git clone https://github.com/ncrosty58/speedhive-tools.git
cd speedhive-tools
python -m venv .venv && source .venv/bin/activate
pip install -e .

Quick CLI Usage

# Run analysis directly from the primary SQLite cache
speedhive report-consistency --org 30476 --db-path ./web_data/speedhive.db --top 10
speedhive extract-driver-laps --org 30476 --driver "Firstname Lastname" --db-path ./web_data/speedhive.db
speedhive extract-track-records --org 30476 --db-path ./web_data/speedhive.db

# Export a raw offline NDJSON dump
speedhive export-dump --org 30476 --output ./output

# Import raw offline NDJSON dumps into the primary SQLite cache
speedhive import-dump --org 30476 --dump-dir ./output --db-path ./web_data/speedhive.db

# Legacy offline dump analysis still works as a fallback when no primary DB is available
speedhive report-consistency --org 30476 --dump-dir ./output
speedhive extract-driver-laps --org 30476 --driver "Firstname Lastname" --dump-dir ./output
speedhive extract-track-records --org 30476 --dump-dir ./output

# Sync organization data into the primary SQLite cache
speedhive sync-org --org 30476 --db-path ./web_data/speedhive.db --mode incremental --recent-backfill-events 3

Run speedhive --help for the full command list.

Python Usage

from speedhive.wrapper import SpeedhiveClient

client = SpeedhiveClient.create(token="your-api-token")
events = client.get_events(org_id=30476, limit=5)

Preferred Workflow

  1. Sync data into the primary SQLite cache: Use the web app sync flow or your own pipeline to populate ./web_data/speedhive.db.

  2. Run analysis against the primary cache:

    speedhive report-consistency --org 30476 --db-path ./web_data/speedhive.db
    speedhive extract-driver-laps --org 30476 --driver "Firstname Lastname" --db-path ./web_data/speedhive.db
    speedhive extract-track-records --org 30476 --db-path ./web_data/speedhive.db
    

Offline Workflow

  1. Export a raw data dump: Downloads events, sessions, results, laps, and announcements to local NDJSON files.

    speedhive export-dump --org 30476 --output ./output
    
  2. Import raw dumps into the primary SQLite cache: Imports all NDJSON files under ./output/30476/ into your main cache database.

    speedhive import-dump --org 30476 --dump-dir ./output --db-path ./web_data/speedhive.db
    
  3. Run offline analysis against the database:

    speedhive report-consistency --org 30476 --dump-dir ./output
    speedhive extract-driver-laps --org 30476 --driver "Firstname Lastname" --dump-dir ./output
    

Output Format

export-dump creates raw NDJSON snapshots in output/<org_id>/:

output/30476/
├── events.ndjson.gz
├── sessions.ndjson.gz
├── laps.ndjson.gz
├── announcements.ndjson.gz
├── results.ndjson.gz
└── .checkpoint.json

import-dump imports those files into the primary cache database, for example:

web_data/
└── speedhive.db

Project Structure

Canonical implementation lives in src/speedhive/:

src/speedhive/
├── client.py
├── wrapper.py
├── generated/           # Auto-generated API client bindings
├── cli/                 # CLI entry point and dynamic discovery
│   ├── discovery.py
│   └── main.py
├── exporters/           # Scrapers and cache sync modules
│   ├── export_org_cache.py
│   ├── export_full_dump.py
│   └── ...
├── analyzers/           # Performance and lap analysis
│   ├── analyze_consistency.py
│   └── analyze_driver_laps.py
└── processing/          # SQLite ETL and track record compilation
    ├── process_sqlite_import.py
    ├── process_track_records.py
    ├── process_lap_analysis.py
    └── ndjson.py

Notes

  • SQLite Backend: All CSV storage workflows have been deprecated. Relational querying is fully powered by a local, indexed SQLite database file.
  • Packaging is configured via pyproject.toml (PEP 621 + setuptools backend).
  • The generated API client uses attrs; no Pydantic dependency.

License

MIT © Nathan Crosty

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

speedhive_tools-0.6.0.tar.gz (88.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

speedhive_tools-0.6.0-py3-none-any.whl (191.3 kB view details)

Uploaded Python 3

File details

Details for the file speedhive_tools-0.6.0.tar.gz.

File metadata

  • Download URL: speedhive_tools-0.6.0.tar.gz
  • Upload date:
  • Size: 88.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for speedhive_tools-0.6.0.tar.gz
Algorithm Hash digest
SHA256 d470b061bf4aaaae035504d00783984ee95f7ad997cd77f8b4534d27dd84e231
MD5 bf99fbdd50d512e307a567aca71a6871
BLAKE2b-256 44d2e22dcf506688c0c026c6e8c01b448c6e5dc1f10b1955c3b17d24438efedf

See more details on using hashes here.

File details

Details for the file speedhive_tools-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for speedhive_tools-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cef15e14b87c76ca4299d406f5417ffb7d763a6e628432eb4b98c6020c08d87
MD5 521cc536e0efcddd6cfa75ec5eb5cfd4
BLAKE2b-256 fa9a7aa6e3db2b043aaf984bfe545d9eb60087e278317c36fc52687bdc46a2f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page