Skip to main content

A small wrapper library to help test systems using STAR

Project description

MOdel Test Harness (Moth)

Simple way to interrogate your AI model from a separate testing application

Quickstart

moth server <folder path>

moth client

Client

Simplest possible classification model client.

from moth import Moth
from moth.message import ImagePromptMsg, ClassificationResultMsg, HandshakeTaskTypes

moth = Moth("my-ai", task_type=HandshakeTaskTypes.CLASSIFICATION)

@moth.prompt
def on_prompt(prompt: ImagePromptMsg):
    # TODO: Do smart AI here
    return ClassificationResultMsg(prompt_id=prompt.id, class_name="cat") # Most pictures are cat pictures 

moth.run()

Simplest possible object detection model client.

from moth import Moth
from moth.message import ImagePromptMsg, ObjectDetectionResultMsg, ObjectDetectionResult, HandshakeTaskTypes

moth = Moth("my-ai", task_type=HandshakeTaskTypes.OBJECT_DETECTION)

@moth.prompt
def on_prompt(prompt: ImagePromptMsg):
    # TODO: Do smart AI here
    # Make a list of ObjectDetectionResults
    l = []
    l.append(ObjectDetectionResult(0, 0, 50, 50, class_name="cat", class_index=0, confidence=0.9))
    l.append(ObjectDetectionResult(10, 10, 50, 35, class_name="dog", class_index=1, confidence=0.1))
    return ObjectDetectionResultMsg(prompt_id=prompt.id, object_detection_results=l)
 

moth.run()

You can also define a set of client output classes that get handed over to the server.

moth = Moth("my-ai", task_type=HandshakeTaskTypes.CLASSIFICATION, output_classes=["cat", "dog"])

Server

Simplest possible server.

from moth.server import Server
from moth.message import HandshakeMsg

class ModelDriverImpl(ModelDriver):
    # TODO: Implement your model driver here
    pass

server = Server(7171)

@server.driver_factory
def handle_handshake(handshake: HandshakeMsg) -> ModelDriver
    return ModelDriverImpl()

You can also register to keep an up to datae list of connected models.

from moth.server import Model

@server.on_model_change
def handle_model_change(model_list: List[Model]):
    print(f"Connected models: {model_list}")

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

starmoth-0.5.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

starmoth-0.5.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file starmoth-0.5.0.tar.gz.

File metadata

  • Download URL: starmoth-0.5.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for starmoth-0.5.0.tar.gz
Algorithm Hash digest
SHA256 982eab37a475348dccaf1975a2e7b46538e6a504ffaaf219cd22e5760e7aac9a
MD5 73cf8cdbf37f1454d02ec83079c7b58b
BLAKE2b-256 17ad518b98c4dc4612e0a2f4b7c049f4b0c17b7936b093378b841657f829ff7f

See more details on using hashes here.

Provenance

File details

Details for the file starmoth-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: starmoth-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for starmoth-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c59ee3927dabf63a52edc284a47fec9494a43ade2d6326fbc166d0806886d4a1
MD5 502099b4a959e31da7eadc76a7bda8f9
BLAKE2b-256 af2abe6b5cefc244b601b11b9a0dca9dbd26a655dfb36cd91178e9889731a1e7

See more details on using hashes here.

Provenance

Supported by

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