Modular event-centric python library made for simplification typical stream applications development with python type system strong exploitation.
Project description
typed-blocks
Documentation: https://typed-blocks.readthedocs.io
Typed Blocks is a modular event-centric python library created to simplify development of typical stream applications. It hardly exploits standard Python type hints.
Distinctive features:
- Boilerplate-less: just ties together pre-defined computational blocks.
- Focuses on loose coupling and event-driven design.
- Encourages explicit separation of data and code. Static typing to the rescue!
- Minimalistic at it's core and easy-to-go.
- Modular and open for extension via self-defined connectors for different data sources.
Installation
In minimal installation typed-blocks requires python 3.7 or greater and has no dependencies, so you may just use:
$ pip install typed-blocks
For each data source or extended features you may need corresponding client library. More details in documentation.
Example
If it is hard to understand, what is going on in the following snippet of code, this article also may help.
TL;DR:
- we are defining
events: minimally significant pieces of data - we are defining
sourceof all events in our program - we define
processorsto handle them - we put all ingredients in the
App. Type hints are important! It's actually definition of whichprocessorshould handleeventand should it emit neweventsor not. - ???
- it works!
from dataclasses import dataclass
from blocks import App, source, processor
@dataclass
class E:
x: int
@dataclass
class E2:
y: int
@source
def generator() -> E:
return E(1)
@processor
def printer(e: E) -> E2:
print('1', e)
return E2(e.x)
@processor
def printer2(e: E2) -> None:
print('2', e)
blocks = (generator(), printer(), printer2())
App(blocks).run(once=True)
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 typed_blocks-0.18.2.tar.gz.
File metadata
- Download URL: typed_blocks-0.18.2.tar.gz
- Upload date:
- Size: 52.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6413d74ed88e5455e1da779e73e0b56f4c24a8318be3ce257453fbffb0f32e7d
|
|
| MD5 |
f3008230e85ae31b312df58e146478be
|
|
| BLAKE2b-256 |
a72f675ae5d749a50f936539b761d033dbc941f2ae70522efdbc81c5ecd6167b
|
File details
Details for the file typed_blocks-0.18.2-py3-none-any.whl.
File metadata
- Download URL: typed_blocks-0.18.2-py3-none-any.whl
- Upload date:
- Size: 62.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2c8651a4e3e26e1cbe1f74125755331e296cd25dfaf0831437fb6aab6225662
|
|
| MD5 |
721724b2a0612bfc12502cb39781c55a
|
|
| BLAKE2b-256 |
97622071190584e53fd14e2e84a1726cb14214a481d1388ff58d492d86017054
|