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.1.tar.gz (30.7 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.1-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ezmsg_baseproc-1.0.1.tar.gz
  • Upload date:
  • Size: 30.7 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.1.tar.gz
Algorithm Hash digest
SHA256 fae2242b091d2afbfec7d9d0430759ac61cf09eca223c2a8717df10c81fdce2d
MD5 5a5d2556d4c1716cdda2f39fc6841cb8
BLAKE2b-256 46a873b12117db237b130063f80a42c3d228e0d93878214668841059516b9f89

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ezmsg_baseproc-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b896aae57988bc7fc81da109dba8537625cea9a88950d0a918382d121a9cb7cb
MD5 6ff56ffa4786454b127cea3dc7b7c7da
BLAKE2b-256 a0660f49b614255314d12064b474f80a6d4d57b44a85b4e72e34d4cbdeca3489

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