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

Related Projects

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

# Sync organization data into the primary SQLite cache (default database is ./web_data/speedhive.db)
speedhive sync-org --org 30476

# Run analysis directly from the SQLite cache
speedhive report-consistency --org 30476 --top 10
speedhive extract-driver-laps --org 30476 --driver "Firstname Lastname"
speedhive extract-track-records --org 30476
speedhive scan-track-records --org 30476
speedhive refresh-track-records --org 30476

# Offline utility commands (exporting raw dumps, then importing into cache)
speedhive export-dump --org 30476 --output ./output
speedhive import-dump --org 30476 --dump-dir ./output

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)

Standard CLI Workflow

All analysis commands query the central SQLite cache (./web_data/speedhive.db by default). There are two standard ways to populate this cache:

Option A: Direct Sync (Recommended)

Query the remote Mylaps Speedhive API directly to populate the cache:

speedhive sync-org --org 30476

Option B: Offline Export / Import Ingest

If you want to migrate data or run analysis offline:

  1. Export raw data dump:
    speedhive export-dump --org 30476 --output ./output
    
  2. Import raw dumps into the SQLite cache:
    speedhive import-dump --org 30476 --dump-dir ./output
    

Running Analysis

Once data is in the SQLite cache, run reports against the database:

speedhive report-consistency --org 30476
speedhive extract-driver-laps --org 30476 --driver "Firstname/Lastname"
speedhive extract-track-records --org 30476
speedhive scan-track-records --org 30476
speedhive refresh-track-records --org 30476

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

extract-track-records, export-lap-records, and export-db-dump emit NDJSON as well. extract-track-records writes a {"_meta": {...}} first line (org id, classification filter, generated-at timestamp) followed by one record per line.

Track-record curation lives in speedhive.curation:

  • run_sync_and_diff(...) assumes the SQLite cache is already populated and only performs extract/normalize/diff against curated and rejected records.
  • refresh_and_scan(...) is the orchestration helper used by the UI and CLI when they want to refresh the org cache first and then run the curation scan.
  • load_curated(...), save_curated(...), load_candidates(...), save_candidates(...), load_rejected(...), and save_rejected(...) all use the shared NDJSON storage helpers.

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
└── curation.py           # Track-record curation and review-state orchestration

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.9.0.tar.gz (100.7 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.9.0-py3-none-any.whl (203.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: speedhive_tools-0.9.0.tar.gz
  • Upload date:
  • Size: 100.7 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.9.0.tar.gz
Algorithm Hash digest
SHA256 5488c7e2ef19f6d6b18effae907ff2428559361638fc67b2b296986f0a36e253
MD5 8b0599dd71ad5be3df54bf9f238239a2
BLAKE2b-256 45d63630f93657ac7a1efa5fea93cd0c96c1f8a630ffc557015525340fbf010d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: speedhive_tools-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 203.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for speedhive_tools-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 721db7a63e601340c41152dae45955617ef860dc03e950d4bd56ded1d95080d3
MD5 640b6a8de4b2a11a1162b2182e86a4ed
BLAKE2b-256 2f37925d9ae3f640c2da7ad143b076ec2b1d7f6c6b49259e9ed18b1dbd2f35e5

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