ezmsg-baseproc
Base processor classes and protocols for building message-processing components in ezmsg.
Installation
pip install ezmsg-baseproc
Or install the latest development version:
pip install git+https://github.com/ezmsg-org/ezmsg-baseproc@dev
Overview
ezmsg-baseproc provides abstract base classes for creating message processors that can be used both standalone and within ezmsg pipelines. The package offers a consistent pattern for building:
- Protocols - Type definitions for processors, transformers, consumers, and producers
- Processors - Transform input messages to output messages
- Producers - Generate output messages without requiring input
- Consumers - Accept input messages without producing output
- Transformers - A specific type of processor with typed input/output
- Stateful variants - Processors that maintain state across invocations
- Adaptive transformers - Transformers that can be trained via
partial_fit - Composite processors - Chain multiple processors together efficiently
All base classes support both synchronous and asynchronous operation, making them suitable for offline analysis and real-time streaming applications.
Usage
Creating a Simple Transformer
from dataclasses import dataclass
from ezmsg.baseproc import BaseTransformer
from ezmsg.util.messages.axisarray import AxisArray, replace
@dataclass
class MySettings:
scale: float = 1.0
class MyTransformer(BaseTransformer[MySettings, AxisArray, AxisArray]):
def _process(self, message: AxisArray) -> AxisArray:
return replace(message, data=message.data * self.settings.scale)
Creating a Stateful Transformer
from ezmsg.baseproc import BaseStatefulTransformer, processor_state
@processor_state
class MyState:
count: int = 0
hash: int = -1
class MyStatefulTransformer(BaseStatefulTransformer[MySettings, AxisArray, AxisArray, MyState]):
def _reset_state(self, message: AxisArray) -> None:
self._state.count = 0
def _process(self, message: AxisArray) -> AxisArray:
self._state.count += 1
return message
Creating an ezmsg Unit
from ezmsg.baseproc import BaseTransformerUnit
class MyUnit(BaseTransformerUnit[MySettings, AxisArray, AxisArray, MyTransformer]):
SETTINGS = MySettings
# That's all - the base class handles everything else!
Development
We use uv for development.
- Install
uvif not already installed - Clone and cd into the repository
- Run
uv syncto create a.venvand install dependencies - Run
uv run pytest teststo run tests - (Optional) Install pre-commit hooks:
uv run pre-commit install
License
MIT License - see LICENSE for details.
Metadata
Release files for ezmsg-baseproc 1.15.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ezmsg_baseproc-1.15.0.tar.gz | 80.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ezmsg_baseproc-1.15.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 130.9 kB
Release files / ezmsg_baseproc-1.15.0.tar.gz
| Download URL | ezmsg_baseproc-1.15.0.tar.gz |
|---|---|
| Size | 80.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7cc8520df86ee8c05d19dd289d2ecdfe170560c244541c72803e2bdeaa0e4221
|
|
BLAKE2b-256 checksum How to use checksums |
199490a37ec9e60639059278665d9f9233053c31df18238683629be3cc83df12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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 / ezmsg_baseproc-1.15.0-py3-none-any.whl
| Download URL | ezmsg_baseproc-1.15.0-py3-none-any.whl |
|---|---|
| Size | 50.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eefce2638d557d563070b67a73582e8412dfdcad5f90eb9540286b4f0628da3f
|
|
BLAKE2b-256 checksum How to use checksums |
f8466fcc115a46460f7d61e5cc5f54c9c3ca09311f7e2d63fd064e95ca2ca89c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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}
|