Skip to main content

gengine

PyPI - Version PyPI - Python Version


Table of Contents

About

gengine (short for generator engine) is a pipeline or workflow engine for iterating over generators within a pipe and passing the output to the following generators.

This makes it a perfect fit for pipeline oriented approaches where you don't want to write the iteration logic manually.

Installation

pip install gengine

Usage

From a technical perspective, a gengine pipeline is just an ordered list of callables. Each callable implements a generator pattern (yield) or simply returns an output (return). gengine iterates over all outputs of each callable in the list and makes sure that every output is forwarded through the whole pipeline. NoneType is ignored and not forwarded (this is the reason why it is mandatory to pass an input to GenGine.run, even if the first callable doesn't use it). Each callable must accept exactly one parameter.

from gengine import GenGine

def my_gen(_inp):
    for j in range(10):
        yield j

def my_add(inp):
    return inp+2

def my_mul(inp):
    for i in range(3):
        yield inp*i

def my_filter(inp):
    if inp%2 == 0:
        return None
    else:
        return inp

g = GenGine([my_gen, my_add, my_mul, my_filter])

for el in g.run(1):
    print(el)

License

gengine is distributed under the terms of the MIT license.

Metadata

Release files for gengine 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for gengine 0.1.0
File Interpreter ABI Platform
gengine-0.1.0-py3-none-any.whl Python 3 none any Details

Release files / gengine-0.1.0-py3-none-any.whl

Download URL gengine-0.1.0-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2eb1553daaf30d06238275b655cc172639d1c628dda6ba346db5273688316d6b
BLAKE2b-256 checksum
How to use checksums
2462b76ff6eac9a144e844e0b2d9bd193a0915b68c1fe303d57c673c9a0b37bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.25.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page