Skip to main content

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 source of all events in our program
  • we define processors to handle them
  • we put all ingredients in the App. Type hints are important! It's actually definition of which processor should handle event and should it emit new events or 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typed-blocks-0.9.8.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

typed_blocks-0.9.8-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

Details for the file typed-blocks-0.9.8.tar.gz.

File metadata

  • Download URL: typed-blocks-0.9.8.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for typed-blocks-0.9.8.tar.gz
Algorithm Hash digest
SHA256 8c5bec810b919daac9999a1a5f5a3c05f5f0ddaec4803dbbac65a74ea4ad9a1a
MD5 8567ce630791f55f5942f0b4639ad629
BLAKE2b-256 ae54f0f92843fa14270ed94a77e503fedd257e248ec484464c5f96702eb2e2d9

See more details on using hashes here.

File details

Details for the file typed_blocks-0.9.8-py3-none-any.whl.

File metadata

  • Download URL: typed_blocks-0.9.8-py3-none-any.whl
  • Upload date:
  • Size: 44.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for typed_blocks-0.9.8-py3-none-any.whl
Algorithm Hash digest
SHA256 30a2848656cf79966cda432cced7be58122899481805d89d526533db534524f7
MD5 ecd41b6e5c4cd04899f5712472c98c2f
BLAKE2b-256 3355531f6144b4f92f23a42bd8fff95e5a628150548578f0dc56240c84497711

See more details on using hashes here.

Supported by

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