Python library for NXP Edge AI Industrial Platform
Project description
AI Box Library
Python library for the NXP Edge AI Industrial Platform.
Overview
ai-box-lib provides thin clients for component-to-component communication:
DataCollectorClientfor publishing data collector payloadsPreProcessorClientfor subscribing data collector payloads and publishing featuresContextEngineClientfor publishing context messagesChannelClientfor generic pub/sub communication between any components
Installation
Install from PyPI:
pip install ai-box-lib
Quick Start
1) Publish data from a data collector
from ai_box_lib.data_collector_client import DataCollectorClient
client = DataCollectorClient[dict]()
client.connect()
client.publish_timestream({"random_number": "42"})
2) Subscribe and publish from a pre-processor
from ai_box_lib.pre_processor_client import PreProcessorClient
client = PreProcessorClient[dict, dict]()
client.connect()
def handle_raw(message: dict) -> None:
processed = {"feature_a": [1.0, 2.0, 3.0]}
client.publish_data(processed)
unsubscribe = client.subscribe_timestream(handle_raw)
3) Publish context output
from ai_box_lib.context_engine_client import ContextEngineClient
client = ContextEngineClient[dict]()
client.connect()
client.publish_data({"state": "ok"})
4) Communicate over a generic channel
A channel lets any two components exchange messages without being tied to a specific pipeline stage. You define the channel by providing a channel_id string. Both publisher and subscriber must use the same channel_id.
Messages are delivered on the topic {asset_id}/channel/{channel_id}.
Publisher:
from ai_box_lib.channel_client import ChannelClient
client: ChannelClient[None, dict] = ChannelClient("my-alerts")
client.connect()
client.publish({"severity": "high", "value": 42.0})
Subscriber:
from ai_box_lib.channel_client import ChannelClient
client: ChannelClient[dict, None] = ChannelClient("my-alerts")
client.connect()
def handle_alert(message: dict) -> None:
print(f"Alert received: {message}")
unsubscribe = client.subscribe(handle_alert)
# call unsubscribe() when done
A single client instance can both publish and subscribe on the same channel.
API Summary
DataCollectorClient.publish_timestream(data)DataCollectorClient.publish_audio(data)PreProcessorClient.subscribe_timestream(handler)PreProcessorClient.subscribe_audio(handler)PreProcessorClient.publish_data(data)ContextEngineClient.publish_data(data)ChannelClient(channel_id).publish(data)ChannelClient(channel_id).subscribe(handler)
Validation and Limits
- Clients must call
connect()before publish/subscribe operations. DataCollectorClientvalidates message keys againstCHANNELS.PreProcessorClientvalidates feature keys and feature shapes againstFEATURES.- Maximum publish payload size is 2 MB.
License
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_box_lib-0.1.10.tar.gz.
File metadata
- Download URL: ai_box_lib-0.1.10.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c050b12e0ea1c2a94dc04eb732ec671841ea44d8698bccc1929333a8c1c7e7c0
|
|
| MD5 |
251cab5e1fcd2823dbdd6aad903b09ee
|
|
| BLAKE2b-256 |
3b1f297a8298b17485cd1b5ef0f208768e7e7e194ea3157d28483eb35bc9c00d
|
File details
Details for the file ai_box_lib-0.1.10-py3-none-any.whl.
File metadata
- Download URL: ai_box_lib-0.1.10-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
446db14fac1dad9f00d96fcc088cc68ca16e03fc6f6239fcfc5b84ae511acdac
|
|
| MD5 |
6ec98ed0c9a8e0ac788ff36d7531ec6f
|
|
| BLAKE2b-256 |
862255bb340ae1fe6549924aca5fd9ffc3030aab6bead7aed43a0c5194f8e4ef
|