Skip to main content

aiSSEMBLE Inference Common Test Utilities

Reusable MLServer test utilities for aiSSEMBLE Inference modules and examples.

Overview

This module provides consolidated MLServer lifecycle management utilities to eliminate code duplication across test suites. It offers two primary usage patterns:

  1. Simple mode: For examples with static model directories
  2. Dynamic mode: For module tests with temporary config generation

Installation

# As a test dependency in pyproject.toml
[dependency-groups]
test = [
    "aissemble-inference-common-test",
]

[tool.uv.sources]
aissemble-inference-common-test = { path = "../aissemble-inference-common-test", editable = true }

Usage

Simple Mode (Examples)

For tests that use pre-configured model directories:

# tests/features/environment.py
from pathlib import Path
from aissemble_inference_common_test.behave_helpers import (
    setup_mlserver_simple,
    teardown_mlserver,
)

def before_all(context):
    example_dir = Path(__file__).parent.parent.parent
    models_dir = example_dir / "models"

    setup_mlserver_simple(context, models_dir=models_dir, port=8080)
    context.mlserver_fixture.start()

def after_all(context):
    teardown_mlserver(context)

Dynamic Mode (Module Tests)

For tests that generate model configurations dynamically:

# tests/features/environment.py
from aissemble_inference_common_test.behave_helpers import (
    setup_mlserver_dynamic,
    teardown_mlserver,
    start_mlserver_with_model,
)

def before_all(context):
    setup_mlserver_dynamic(context)

def after_scenario(context, scenario):
    if hasattr(context, "mlserver_fixture") and context.mlserver_fixture.process:
        context.mlserver_fixture.stop()

def after_all(context):
    teardown_mlserver(context)

# In your step definitions:
start_mlserver_with_model(
    context,
    model_name="yolo",
    runtime="aissemble_inference_yolo.YOLORuntime",
    model="yolov8n.pt"
)

Features

  • Process Management: Robust MLServer subprocess handling with zombie process detection
  • Health Checking: Automatic polling of /v2/health/ready endpoint
  • Graceful Shutdown: Terminate with timeout, then kill if needed (with safety timeouts)
  • Dynamic Port Allocation: Automatic free port discovery
  • Config Generation: JSON settings and model-settings creation
  • Context Manager Support: Automatic cleanup with Python with statement
  • Error Logging: Detailed warnings for cleanup and shutdown failures
  • Backward Compatible: Drop-in replacement for existing test code

API Reference

MLServerFixture

Main fixture class for MLServer lifecycle management.

Basic Usage

from aissemble_inference_common_test import MLServerFixture

# Simple mode
fixture = MLServerFixture.simple(port=8080, models_dir=Path("models"))
fixture.start()

# Dynamic mode
fixture = MLServerFixture.dynamic()
fixture.start_with_model(
    model_name="yolo",
    runtime="aissemble_inference_yolo.YOLORuntime",
    model="yolov8n.pt"
)

# Cleanup
fixture.stop()
fixture.cleanup()

Context Manager Usage (Recommended)

For automatic cleanup even when tests fail:

from aissemble_inference_common_test import MLServerFixture
from pathlib import Path

# Simple mode with context manager
with MLServerFixture.simple(port=8080, models_dir=Path("models")) as fixture:
    fixture.start()
    # Run tests...
    # Automatic cleanup on exit

# Dynamic mode with context manager
with MLServerFixture.dynamic() as fixture:
    fixture.start_with_model(
        model_name="yolo",
        runtime="aissemble_inference_yolo.YOLORuntime",
        model="yolov8n.pt"
    )
    # Run tests...
    # Automatic stop() and cleanup() on exit, even if exception occurs

Behave Helpers

  • setup_mlserver_simple(context, models_dir, port) - Initialize simple fixture
  • setup_mlserver_dynamic(context) - Initialize dynamic fixture
  • start_mlserver_with_model(context, model_name, runtime, **params) - Start with config
  • teardown_mlserver(context) - Cleanup and shutdown

License

Apache 2.0

Metadata

Release files for aissemble-inference-common-test 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aissemble-inference-common-test 1.5.0
File Size Uploaded Provenance Actions
aissemble_inference_common_test-1.5.0.tar.gz 151.8 kB Without provenance Details for aissemble_inference_common_test-1.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aissemble-inference-common-test 1.5.0
File Interpreter ABI Platform Actions
aissemble_inference_common_test-1.5.0-py3-none-any.whl Python 3 none any Details for aissemble_inference_common_test-1.5.0-py3-none-any.whl

Total release size: 166.2 kB

Release files / aissemble_inference_common_test-1.5.0.tar.gz

Download URL aissemble_inference_common_test-1.5.0.tar.gz
Size 151.8 kB
Tags Source
SHA-256 checksum
How to use checksums
faa1976a6faaa9377329ef3c196a6f71a0290f0227abbf9bfe8a0eb566c9ac58
BLAKE2b-256 checksum
How to use checksums
a643be0700841b1c7bc410918765efaecebe02bb4c33be81f7877d01d43dc8cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / aissemble_inference_common_test-1.5.0-py3-none-any.whl

Download URL aissemble_inference_common_test-1.5.0-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd0870a9edf348c8045e7fe61b850e9cc227f0549ac003c834a1994ca48b61a4
BLAKE2b-256 checksum
How to use checksums
c8d5a91df9a26025f67edf4c504a894c55760fd8d9449a00b8aabd6c0009c92f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for aissemble-inference-common-test 1.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page