SnoozeML Python SDK Documentation#

Welcome to the official Python SDK documentation for SnoozeML, the bare-metal, scale-to-zero deep learning and machine learning inference daemon written in Rust.

Note

Looking for server deployment, models.toml configuration, or Rust architecture guides? Visit the ← SnoozeML Core Service Documentation.

Key Capabilities#

  • Dual-Transport Client (SnoozeClient & AsyncSnoozeClient): Communicate with SnoozeML over HTTP REST (JSON) or high-throughput native gRPC (raw little-endian FP32 byte buffers) with automatic NumPy and PyTorch tensor serialization, dataset batch chunking (infer_dataset()), and transient 503 retry resilience.

  • Model Lifecycle & Scale-to-Zero Control (ModelsManager): List registered models, inspect live states (idle, loading, ready, busy), preload weights (load), pin critical models in memory (pin / unpin), explicitly evict models (evict / unload), and block until ready (wait_for_ready()).

  • One-Step Deployment & ML Converters (snoozeml.converters): Deploy trained models directly from Python memory or export fitted scikit-learn estimators/pipelines (export_sklearn()), PyTorch nn.Module networks (export_torch()), and XGBoost models (export_xgboost()) directly into SnoozeML-ready artifacts.

  • Authentication, RBAC & JWT Minting (snoozeml.auth): Mint and verify RFC 7519 HMAC JSON Web Tokens (HS256, HS384, HS512) matching SnoozeML’s 3-tier RBAC hierarchy (ReadOnly, Inference, Admin).

  • Event Streaming & Real-Time Ingestion (snoozeml.streams): Serialize streaming inference envelopes (StreamInferRequest, StreamInferResponse), test with MockStreamClient, and connect to live Redis Streams (RedisStreamClient).

  • Programmatic Config & Local Test Runner (snoozeml.config): Build models.toml declaratively with SnoozeConfig, scaffold process-isolated custom Python workers (scaffold_worker()), and run an ephemeral daemon in Python with SnoozeDaemon.

  • Telemetry & Prometheus Parsing (snoozeml.metrics): Scrape and parse exposition counters from GET /metrics with parse_prometheus_metrics() for monitoring success rates, latencies, and scale-to-zero memory events.

  • Structured Logging & Credential Sanitization (snoozeml.logging): Built-in RedactingFilter and StructuredFormatter guarantee that API keys and JWT Bearer tokens are never leaked in logs or repr() strings.