Skip to main content

Base processor classes and protocols for ezmsg signal processing pipelines

Project description

ezmsg-baseproc

Base processor classes and protocols for building signal processing pipelines in ezmsg.

Installation

pip install ezmsg-baseproc

Overview

This package provides the foundational processor architecture for ezmsg signal processing:

  • Protocols - Type definitions for processors, transformers, consumers, and producers
  • Base Classes - Abstract base classes for building stateless and stateful processors
  • Composite Processors - Classes for chaining processors into pipelines
  • Unit Wrappers - ezmsg Unit base classes that wrap processors for graph integration

Module Structure

ezmsg.baseproc/
├── protocols.py      # Protocol definitions and type variables
├── processor.py      # Base non-stateful processors
├── stateful.py       # Stateful processor base classes
├── composite.py      # CompositeProcessor and CompositeProducer
├── units.py          # ezmsg Unit wrappers
└── util/
    ├── asio.py           # Async/sync utilities
    ├── message.py        # SampleMessage definitions
    ├── profile.py        # Profiling decorators
    └── typeresolution.py # Type resolution helpers

Usage

Creating a Simple Transformer

from dataclasses import dataclass
from ezmsg.baseproc import BaseTransformer
from ezmsg.util.messages.axisarray import AxisArray

@dataclass
class MySettings:
    scale: float = 1.0

class MyTransformer(BaseTransformer[MySettings, AxisArray, AxisArray]):
    def _process(self, message: AxisArray) -> AxisArray:
        return message.replace(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.

  1. Install uv if not already installed
  2. Clone and cd into the repository
  3. Run uv sync to create a .venv and install dependencies
  4. Run uv run pytest tests to run tests

License

MIT License - see LICENSE for details.

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

ezmsg_baseproc-1.0.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ezmsg_baseproc-1.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file ezmsg_baseproc-1.0.tar.gz.

File metadata

  • Download URL: ezmsg_baseproc-1.0.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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}

File hashes

Hashes for ezmsg_baseproc-1.0.tar.gz
Algorithm Hash digest
SHA256 33f8a26432a051bcd64313d87e5594193d2abfcb341b534889a04f8393cfacd5
MD5 d2c458e8ffa14832db3ab2581f323f53
BLAKE2b-256 b551488d1ec00b5e9eedbbc063e5e7c267346a9d698a7a5935120fb42fc6c91f

See more details on using hashes here.

File details

Details for the file ezmsg_baseproc-1.0-py3-none-any.whl.

File metadata

  • Download URL: ezmsg_baseproc-1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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}

File hashes

Hashes for ezmsg_baseproc-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7241f59ad42f22af5a64a6b3a214ec9466d68d29a7cd3a4a49794523078dead
MD5 2ad4ebb2ce6597145da2b87938b53ff0
BLAKE2b-256 4ae7446e4825ff06bcad69f0a528ed82dd4132a294030ec1ece752593c790fe9

See more details on using hashes here.

Supported by

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