ezmsg-baseproc 1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ezmsg_baseproc-1.0/.github/workflows/docs.yml +66 -0
- ezmsg_baseproc-1.0/.github/workflows/python-publish.yml +28 -0
- ezmsg_baseproc-1.0/.github/workflows/python-tests.yml +36 -0
- ezmsg_baseproc-1.0/.gitignore +129 -0
- ezmsg_baseproc-1.0/.pre-commit-config.yaml +9 -0
- ezmsg_baseproc-1.0/LICENSE +21 -0
- ezmsg_baseproc-1.0/PKG-INFO +106 -0
- ezmsg_baseproc-1.0/README.md +94 -0
- ezmsg_baseproc-1.0/docs/Makefile +20 -0
- ezmsg_baseproc-1.0/docs/make.bat +35 -0
- ezmsg_baseproc-1.0/docs/source/_templates/autosummary/module.rst +64 -0
- ezmsg_baseproc-1.0/docs/source/api/index.rst +8 -0
- ezmsg_baseproc-1.0/docs/source/conf.py +122 -0
- ezmsg_baseproc-1.0/docs/source/guides/ProcessorsBase.md +165 -0
- ezmsg_baseproc-1.0/docs/source/guides/how-tos/processors/adaptive.rst +4 -0
- ezmsg_baseproc-1.0/docs/source/guides/how-tos/processors/checkpoint.rst +4 -0
- ezmsg_baseproc-1.0/docs/source/guides/how-tos/processors/composite.rst +4 -0
- ezmsg_baseproc-1.0/docs/source/guides/how-tos/processors/content-processors.rst +13 -0
- ezmsg_baseproc-1.0/docs/source/guides/how-tos/processors/processor.rst +4 -0
- ezmsg_baseproc-1.0/docs/source/guides/how-tos/processors/standalone.rst +4 -0
- ezmsg_baseproc-1.0/docs/source/guides/how-tos/processors/stateful.rst +4 -0
- ezmsg_baseproc-1.0/docs/source/guides/how-tos/processors/unit.rst +11 -0
- ezmsg_baseproc-1.0/docs/source/index.rst +87 -0
- ezmsg_baseproc-1.0/examples/example.py +44 -0
- ezmsg_baseproc-1.0/pyproject.toml +76 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/__init__.py +155 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/__version__.py +34 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/composite.py +323 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/processor.py +209 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/protocols.py +147 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/stateful.py +323 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/units.py +282 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/util/__init__.py +1 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/util/asio.py +138 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/util/message.py +31 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/util/profile.py +171 -0
- ezmsg_baseproc-1.0/src/ezmsg/baseproc/util/typeresolution.py +81 -0
- ezmsg_baseproc-1.0/tests/test_baseproc.py +1118 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
name: Documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
tags:
|
|
8
|
+
- 'v*'
|
|
9
|
+
pull_request:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
- dev
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
pages: write
|
|
18
|
+
id-token: write
|
|
19
|
+
|
|
20
|
+
# Allow only one concurrent deployment
|
|
21
|
+
concurrency:
|
|
22
|
+
group: "pages"
|
|
23
|
+
cancel-in-progress: false
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
build:
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 0 # Needed for hatch-vcs to determine version
|
|
32
|
+
|
|
33
|
+
- name: Install uv
|
|
34
|
+
uses: astral-sh/setup-uv@v6
|
|
35
|
+
with:
|
|
36
|
+
enable-cache: true
|
|
37
|
+
python-version: "3.12"
|
|
38
|
+
|
|
39
|
+
- name: Install the project
|
|
40
|
+
run: uv sync --only-group docs
|
|
41
|
+
|
|
42
|
+
- name: Build documentation
|
|
43
|
+
run: |
|
|
44
|
+
cd docs
|
|
45
|
+
uv run make html
|
|
46
|
+
|
|
47
|
+
- name: Add .nojekyll file
|
|
48
|
+
run: touch docs/build/html/.nojekyll
|
|
49
|
+
|
|
50
|
+
- name: Upload artifact
|
|
51
|
+
uses: actions/upload-pages-artifact@v3
|
|
52
|
+
with:
|
|
53
|
+
path: 'docs/build/html'
|
|
54
|
+
|
|
55
|
+
deploy:
|
|
56
|
+
# Only deploy on push to main or release tags
|
|
57
|
+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
|
58
|
+
environment:
|
|
59
|
+
name: github-pages
|
|
60
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
needs: build
|
|
63
|
+
steps:
|
|
64
|
+
- name: Deploy to GitHub Pages
|
|
65
|
+
id: deployment
|
|
66
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# This workflow will upload a Python Package using Twine when a release is created
|
|
2
|
+
|
|
3
|
+
name: Upload Python Package
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
name: build and upload release to PyPI
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
environment: "release"
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v6
|
|
23
|
+
|
|
24
|
+
- name: Build Package
|
|
25
|
+
run: uv build
|
|
26
|
+
|
|
27
|
+
- name: Publish package distributions to PyPI
|
|
28
|
+
run: uv publish
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Test package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches:
|
|
8
|
+
- main
|
|
9
|
+
- dev
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ["3.10.15", "3.11", "3.12", "3.13"]
|
|
17
|
+
os:
|
|
18
|
+
- "ubuntu-latest"
|
|
19
|
+
- "windows-latest"
|
|
20
|
+
- "macos-latest"
|
|
21
|
+
runs-on: ${{matrix.os}}
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: Install the latest version of uv
|
|
27
|
+
uses: astral-sh/setup-uv@v6
|
|
28
|
+
|
|
29
|
+
- name: Install the project
|
|
30
|
+
run: uv sync --python ${{ matrix.python-version }}
|
|
31
|
+
|
|
32
|
+
- name: Lint
|
|
33
|
+
run: uv tool run ruff check --output-format=github src
|
|
34
|
+
|
|
35
|
+
- name: Run tests
|
|
36
|
+
run: uv run pytest tests
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
*.manifest
|
|
31
|
+
*.spec
|
|
32
|
+
|
|
33
|
+
# Installer logs
|
|
34
|
+
pip-log.txt
|
|
35
|
+
pip-delete-this-directory.txt
|
|
36
|
+
|
|
37
|
+
# Unit test / coverage reports
|
|
38
|
+
htmlcov/
|
|
39
|
+
.tox/
|
|
40
|
+
.nox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
*.py,cover
|
|
48
|
+
.hypothesis/
|
|
49
|
+
.pytest_cache/
|
|
50
|
+
cover/
|
|
51
|
+
|
|
52
|
+
# Translations
|
|
53
|
+
*.mo
|
|
54
|
+
*.pot
|
|
55
|
+
|
|
56
|
+
# Sphinx documentation
|
|
57
|
+
docs/_build/
|
|
58
|
+
docs/build/
|
|
59
|
+
docs/source/_build
|
|
60
|
+
docs/source/generated
|
|
61
|
+
docs/source/api/generated
|
|
62
|
+
|
|
63
|
+
# PyBuilder
|
|
64
|
+
.pybuilder/
|
|
65
|
+
target/
|
|
66
|
+
|
|
67
|
+
# Jupyter Notebook
|
|
68
|
+
.ipynb_checkpoints
|
|
69
|
+
|
|
70
|
+
# IPython
|
|
71
|
+
profile_default/
|
|
72
|
+
ipython_config.py
|
|
73
|
+
|
|
74
|
+
# pyenv
|
|
75
|
+
# .python-version
|
|
76
|
+
|
|
77
|
+
# PEP 582
|
|
78
|
+
__pypackages__/
|
|
79
|
+
|
|
80
|
+
# Environments
|
|
81
|
+
.env
|
|
82
|
+
.venv
|
|
83
|
+
env/
|
|
84
|
+
venv/
|
|
85
|
+
ENV/
|
|
86
|
+
env.bak/
|
|
87
|
+
venv.bak/
|
|
88
|
+
|
|
89
|
+
# Spyder project settings
|
|
90
|
+
.spyderproject
|
|
91
|
+
.spyproject
|
|
92
|
+
|
|
93
|
+
# Rope project settings
|
|
94
|
+
.ropeproject
|
|
95
|
+
|
|
96
|
+
# mkdocs documentation
|
|
97
|
+
/site
|
|
98
|
+
|
|
99
|
+
# mypy
|
|
100
|
+
.mypy_cache/
|
|
101
|
+
.dmypy.json
|
|
102
|
+
dmypy.json
|
|
103
|
+
|
|
104
|
+
# Pyre type checker
|
|
105
|
+
.pyre/
|
|
106
|
+
|
|
107
|
+
# pytype static type analyzer
|
|
108
|
+
.pytype/
|
|
109
|
+
|
|
110
|
+
# Cython debug symbols
|
|
111
|
+
cython_debug/
|
|
112
|
+
|
|
113
|
+
# JetBrains IDE
|
|
114
|
+
.idea/
|
|
115
|
+
|
|
116
|
+
# VS Code
|
|
117
|
+
.vscode/
|
|
118
|
+
|
|
119
|
+
# Ruff cache
|
|
120
|
+
.ruff_cache/
|
|
121
|
+
|
|
122
|
+
# hatch-vcs generated version file
|
|
123
|
+
src/ezmsg/baseproc/__version__.py
|
|
124
|
+
|
|
125
|
+
# uv lockfile (optional - comment if you want to track it)
|
|
126
|
+
uv.lock
|
|
127
|
+
|
|
128
|
+
# Claude
|
|
129
|
+
settings.local.json
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ezmsg-org
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ezmsg-baseproc
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: Base processor classes and protocols for ezmsg signal processing pipelines
|
|
5
|
+
Author-email: Griffin Milsap <griffin.milsap@gmail.com>, Preston Peranich <pperanich@gmail.com>, Chadwick Boulay <chadwick.boulay@gmail.com>, Kyle McGraw <kmcgraw@blackrockneuro.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: ezmsg[axisarray]>=3.6.0
|
|
10
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# ezmsg-baseproc
|
|
14
|
+
|
|
15
|
+
Base processor classes and protocols for building signal processing pipelines in [ezmsg](https://github.com/ezmsg-org/ezmsg).
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install ezmsg-baseproc
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Overview
|
|
24
|
+
|
|
25
|
+
This package provides the foundational processor architecture for ezmsg signal processing:
|
|
26
|
+
|
|
27
|
+
- **Protocols** - Type definitions for processors, transformers, consumers, and producers
|
|
28
|
+
- **Base Classes** - Abstract base classes for building stateless and stateful processors
|
|
29
|
+
- **Composite Processors** - Classes for chaining processors into pipelines
|
|
30
|
+
- **Unit Wrappers** - ezmsg Unit base classes that wrap processors for graph integration
|
|
31
|
+
|
|
32
|
+
## Module Structure
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
ezmsg.baseproc/
|
|
36
|
+
├── protocols.py # Protocol definitions and type variables
|
|
37
|
+
├── processor.py # Base non-stateful processors
|
|
38
|
+
├── stateful.py # Stateful processor base classes
|
|
39
|
+
├── composite.py # CompositeProcessor and CompositeProducer
|
|
40
|
+
├── units.py # ezmsg Unit wrappers
|
|
41
|
+
└── util/
|
|
42
|
+
├── asio.py # Async/sync utilities
|
|
43
|
+
├── message.py # SampleMessage definitions
|
|
44
|
+
├── profile.py # Profiling decorators
|
|
45
|
+
└── typeresolution.py # Type resolution helpers
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
### Creating a Simple Transformer
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from dataclasses import dataclass
|
|
54
|
+
from ezmsg.baseproc import BaseTransformer
|
|
55
|
+
from ezmsg.util.messages.axisarray import AxisArray
|
|
56
|
+
|
|
57
|
+
@dataclass
|
|
58
|
+
class MySettings:
|
|
59
|
+
scale: float = 1.0
|
|
60
|
+
|
|
61
|
+
class MyTransformer(BaseTransformer[MySettings, AxisArray, AxisArray]):
|
|
62
|
+
def _process(self, message: AxisArray) -> AxisArray:
|
|
63
|
+
return message.replace(data=message.data * self.settings.scale)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Creating a Stateful Transformer
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from ezmsg.baseproc import BaseStatefulTransformer, processor_state
|
|
70
|
+
|
|
71
|
+
@processor_state
|
|
72
|
+
class MyState:
|
|
73
|
+
count: int = 0
|
|
74
|
+
hash: int = -1
|
|
75
|
+
|
|
76
|
+
class MyStatefulTransformer(BaseStatefulTransformer[MySettings, AxisArray, AxisArray, MyState]):
|
|
77
|
+
def _reset_state(self, message: AxisArray) -> None:
|
|
78
|
+
self._state.count = 0
|
|
79
|
+
|
|
80
|
+
def _process(self, message: AxisArray) -> AxisArray:
|
|
81
|
+
self._state.count += 1
|
|
82
|
+
return message
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Creating an ezmsg Unit
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from ezmsg.baseproc import BaseTransformerUnit
|
|
89
|
+
|
|
90
|
+
class MyUnit(BaseTransformerUnit[MySettings, AxisArray, AxisArray, MyTransformer]):
|
|
91
|
+
SETTINGS = MySettings
|
|
92
|
+
# That's all - the base class handles everything else!
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
We use [`uv`](https://docs.astral.sh/uv/getting-started/installation/) for development.
|
|
98
|
+
|
|
99
|
+
1. Install `uv` if not already installed
|
|
100
|
+
2. Clone and cd into the repository
|
|
101
|
+
3. Run `uv sync` to create a `.venv` and install dependencies
|
|
102
|
+
4. Run `uv run pytest tests` to run tests
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# ezmsg-baseproc
|
|
2
|
+
|
|
3
|
+
Base processor classes and protocols for building signal processing pipelines in [ezmsg](https://github.com/ezmsg-org/ezmsg).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install ezmsg-baseproc
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This package provides the foundational processor architecture for ezmsg signal processing:
|
|
14
|
+
|
|
15
|
+
- **Protocols** - Type definitions for processors, transformers, consumers, and producers
|
|
16
|
+
- **Base Classes** - Abstract base classes for building stateless and stateful processors
|
|
17
|
+
- **Composite Processors** - Classes for chaining processors into pipelines
|
|
18
|
+
- **Unit Wrappers** - ezmsg Unit base classes that wrap processors for graph integration
|
|
19
|
+
|
|
20
|
+
## Module Structure
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
ezmsg.baseproc/
|
|
24
|
+
├── protocols.py # Protocol definitions and type variables
|
|
25
|
+
├── processor.py # Base non-stateful processors
|
|
26
|
+
├── stateful.py # Stateful processor base classes
|
|
27
|
+
├── composite.py # CompositeProcessor and CompositeProducer
|
|
28
|
+
├── units.py # ezmsg Unit wrappers
|
|
29
|
+
└── util/
|
|
30
|
+
├── asio.py # Async/sync utilities
|
|
31
|
+
├── message.py # SampleMessage definitions
|
|
32
|
+
├── profile.py # Profiling decorators
|
|
33
|
+
└── typeresolution.py # Type resolution helpers
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### Creating a Simple Transformer
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from dataclasses import dataclass
|
|
42
|
+
from ezmsg.baseproc import BaseTransformer
|
|
43
|
+
from ezmsg.util.messages.axisarray import AxisArray
|
|
44
|
+
|
|
45
|
+
@dataclass
|
|
46
|
+
class MySettings:
|
|
47
|
+
scale: float = 1.0
|
|
48
|
+
|
|
49
|
+
class MyTransformer(BaseTransformer[MySettings, AxisArray, AxisArray]):
|
|
50
|
+
def _process(self, message: AxisArray) -> AxisArray:
|
|
51
|
+
return message.replace(data=message.data * self.settings.scale)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Creating a Stateful Transformer
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from ezmsg.baseproc import BaseStatefulTransformer, processor_state
|
|
58
|
+
|
|
59
|
+
@processor_state
|
|
60
|
+
class MyState:
|
|
61
|
+
count: int = 0
|
|
62
|
+
hash: int = -1
|
|
63
|
+
|
|
64
|
+
class MyStatefulTransformer(BaseStatefulTransformer[MySettings, AxisArray, AxisArray, MyState]):
|
|
65
|
+
def _reset_state(self, message: AxisArray) -> None:
|
|
66
|
+
self._state.count = 0
|
|
67
|
+
|
|
68
|
+
def _process(self, message: AxisArray) -> AxisArray:
|
|
69
|
+
self._state.count += 1
|
|
70
|
+
return message
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Creating an ezmsg Unit
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from ezmsg.baseproc import BaseTransformerUnit
|
|
77
|
+
|
|
78
|
+
class MyUnit(BaseTransformerUnit[MySettings, AxisArray, AxisArray, MyTransformer]):
|
|
79
|
+
SETTINGS = MySettings
|
|
80
|
+
# That's all - the base class handles everything else!
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Development
|
|
84
|
+
|
|
85
|
+
We use [`uv`](https://docs.astral.sh/uv/getting-started/installation/) for development.
|
|
86
|
+
|
|
87
|
+
1. Install `uv` if not already installed
|
|
88
|
+
2. Clone and cd into the repository
|
|
89
|
+
3. Run `uv sync` to create a `.venv` and install dependencies
|
|
90
|
+
4. Run `uv run pytest tests` to run tests
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
|
8
|
+
SOURCEDIR = source
|
|
9
|
+
BUILDDIR = build
|
|
10
|
+
|
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
|
12
|
+
help:
|
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
+
|
|
15
|
+
.PHONY: help Makefile
|
|
16
|
+
|
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
+
%: Makefile
|
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
REM Command file for Sphinx documentation
|
|
6
|
+
|
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
|
8
|
+
set SPHINXBUILD=sphinx-build
|
|
9
|
+
)
|
|
10
|
+
set SOURCEDIR=source
|
|
11
|
+
set BUILDDIR=build
|
|
12
|
+
|
|
13
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
14
|
+
if errorlevel 9009 (
|
|
15
|
+
echo.
|
|
16
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
17
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
18
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
19
|
+
echo.may add the Sphinx directory to PATH.
|
|
20
|
+
echo.
|
|
21
|
+
echo.If you don't have Sphinx installed, grab it from
|
|
22
|
+
echo.https://www.sphinx-doc.org/
|
|
23
|
+
exit /b 1
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if "%1" == "" goto help
|
|
27
|
+
|
|
28
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
29
|
+
goto end
|
|
30
|
+
|
|
31
|
+
:help
|
|
32
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
33
|
+
|
|
34
|
+
:end
|
|
35
|
+
popd
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{{ fullname | escape | underline}}
|
|
2
|
+
|
|
3
|
+
.. automodule:: {{ fullname }}
|
|
4
|
+
|
|
5
|
+
{% block attributes %}
|
|
6
|
+
{% if attributes %}
|
|
7
|
+
.. rubric:: Module Attributes
|
|
8
|
+
|
|
9
|
+
.. autosummary::
|
|
10
|
+
:toctree:
|
|
11
|
+
{% for item in attributes %}
|
|
12
|
+
{{ item }}
|
|
13
|
+
{%- endfor %}
|
|
14
|
+
{% endif %}
|
|
15
|
+
{% endblock %}
|
|
16
|
+
|
|
17
|
+
{% block functions %}
|
|
18
|
+
{% if functions %}
|
|
19
|
+
.. rubric:: Functions
|
|
20
|
+
|
|
21
|
+
{% for item in functions %}
|
|
22
|
+
.. autofunction:: {{ item }}
|
|
23
|
+
{%- endfor %}
|
|
24
|
+
{% endif %}
|
|
25
|
+
{% endblock %}
|
|
26
|
+
|
|
27
|
+
{% block classes %}
|
|
28
|
+
{% if classes %}
|
|
29
|
+
.. rubric:: Classes
|
|
30
|
+
|
|
31
|
+
{% for item in classes %}
|
|
32
|
+
.. autoclass:: {{ item }}
|
|
33
|
+
:members:
|
|
34
|
+
:undoc-members:
|
|
35
|
+
:show-inheritance:
|
|
36
|
+
:special-members: __init__
|
|
37
|
+
{%- endfor %}
|
|
38
|
+
{% endif %}
|
|
39
|
+
{% endblock %}
|
|
40
|
+
|
|
41
|
+
{% block exceptions %}
|
|
42
|
+
{% if exceptions %}
|
|
43
|
+
.. rubric:: Exceptions
|
|
44
|
+
|
|
45
|
+
{% for item in exceptions %}
|
|
46
|
+
.. autoexception:: {{ item }}
|
|
47
|
+
:members:
|
|
48
|
+
:show-inheritance:
|
|
49
|
+
{%- endfor %}
|
|
50
|
+
{% endif %}
|
|
51
|
+
{% endblock %}
|
|
52
|
+
|
|
53
|
+
{% block modules %}
|
|
54
|
+
{% if modules %}
|
|
55
|
+
.. rubric:: Modules
|
|
56
|
+
|
|
57
|
+
.. autosummary::
|
|
58
|
+
:toctree:
|
|
59
|
+
:recursive:
|
|
60
|
+
{% for item in modules %}
|
|
61
|
+
{{ item }}
|
|
62
|
+
{%- endfor %}
|
|
63
|
+
{% endif %}
|
|
64
|
+
{% endblock %}
|