Skip to main content

A C/S architecture test runner for heavy AI projects.

Project description

Sprintest

PyPI version License: MIT Python 3.10+

[English] | 简体中文

Sprintest is a high-performance Client-Server (C/S) architecture test runner specifically engineered for heavy AI/ML projects.

In projects involving large language models (LLMs), deep learning frameworks (PyTorch, TensorFlow), or massive datasets, standard test runners suffer from excruciatingly slow startup times (often 30s to several minutes) because they re-initialize the entire environment for every run. Sprintest solves this by keeping your heavy dependencies pre-loaded in memory.


🚀 Key Highlights

  • ⚡ Blazing Fast Feedback: Reduces test startup time from minutes to milliseconds by keeping heavy frameworks and models pre-loaded in a background daemon.
  • 🔄 Intelligent Hot-Reloading: Features a "Nuke Engine" that surgically unloads only your project's modified modules, ensuring you always test against the latest code without losing the pre-loaded state.
  • 🔌 Unified Transport Layer: Automatically chooses between Unix Domain Sockets (UDS) for zero-latency local communication and TCP for maximum compatibility.
  • 🛠️ Decoupled Architecture: Built with a robust service layer and atomic state management, ensuring stable communication even during heavy test execution.
  • 🤖 Agent-Optimized: Designed for AI coding agents (like Antigravity or Cursor) with clean, ANSI-free output and reliable status tracking.
  • 🎯 Configurable Strategy: Fine-tune hot-reloading with ignore_patterns in your pyproject.toml to prevent specific heavy modules from being reloaded.

⚡ Performance Comparison

For AI/ML projects with heavy dependencies (torch, transformers, etc.), Sprintest provides a massive speedup by eliminating redundant initialization.

Run Type Total Time
Pytest (Standard) ~6.0s
Sprintest (First Run) ~7.0s
Sprintest (Warm Start) ~2.0s

Numbers above are measured on examples/test_ai_model.py and are provided for reference only. In heavier real-world projects, speedups typically reach 5x - 10x—for example, in my other project engram-peft, unit test total wall time improved by 7.8x (integration tests not included).


🏗️ Architecture

Sprintest uses a decoupled architecture to ensure the daemon remains responsive even when running heavy tests.

graph TD
    Client[Client CLI] -->|HTTP over UDS/TCP| Daemon[FastAPI Daemon]
    Daemon -->|Lifespan| Preloader[Package Preloader]
    Daemon --> Service[Test Service]
    Service -->|Atomic Lock| Service
    Service --> Nuke[Nuke Engine]
    Nuke -->|Strategy| PySys[sys.modules]
    Service --> Runner[Pytest Runner]
    Runner -->|Redirect IO| Tests[User Tests]
    Daemon -.-> Status[(status.json)]
    Client -.-> Status

📦 Installation

pip install sprintest

📖 Quick Start

  1. Run a test: Simply run stest followed by your test file. If the daemon isn't running, it will start automatically.

    stest tests/test_model_loading.py
    
  2. Check Daemon status:

    stest status
    
  3. Stop the Daemon:

    stest stop
    

⚙️ Configuration

Environment Variables & Isolation

  • SPRINTEST_TARGET_PKG: The name of the package you are developing. Sprintest will prioritize hot-reloading this package.
  • SPRINTEST_FORCE_TCP: Set to 1 to bypass Unix Sockets and force TCP communication.
  • SPRINTEST_PORT: Customize the TCP port (default: 8000).
  • SPRINTEST_DIR: Override the default .sprintest directory (useful for multi-project isolation or CI environments).
  • SPRINTEST_LOCK_FILE: Override the daemon lock file path.
  • SPRINTEST_LOG_LEVEL: Set log level (DEBUG, INFO, WARNING, ERROR).

Advanced: pyproject.toml

You can prevent specific modules from being "nuked" during hot-reload by adding them to the ignore list:

[tool.sprintest]
ignore = [
    "torch.*",
    "transformers.*",
    "heavy_module_to_keep"
]

🧪 Testing the Runner

Standard Unit Tests

uv run pytest tests

Self-Hosting (Bootstrap) Test

Sprintest can reliably run its own test suite through its own daemon to verify infrastructure stability:

stest tests

📄 License

MIT License. See LICENSE for details.

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

sprintest-1.0.3.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

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

sprintest-1.0.3-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file sprintest-1.0.3.tar.gz.

File metadata

  • Download URL: sprintest-1.0.3.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sprintest-1.0.3.tar.gz
Algorithm Hash digest
SHA256 b0eb4a3888a32c578d19f8a316f43ca4b5163d67507c5b21784c5db6fd39af06
MD5 18e7be7f00cbf4a3eb260809670fb4ec
BLAKE2b-256 2161e7d5b39647213df8ec12d887aba84579b05356ec624d76d57c36b59f99fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for sprintest-1.0.3.tar.gz:

Publisher: publish.yml on QingGo/sprintest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sprintest-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: sprintest-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sprintest-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 22b3b30b5a1c162ea6381f2be7ffc415a0e51ae4f548d39d13f26be7a20a992b
MD5 7cdc421be9ec11c464e00b3316e9cbf9
BLAKE2b-256 21a816f4ecba4b21deb5c304799caa3f47b65eba121314c9f3494d3b4dc8cb29

See more details on using hashes here.

Provenance

The following attestation bundles were made for sprintest-1.0.3-py3-none-any.whl:

Publisher: publish.yml on QingGo/sprintest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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