Skip to main content

A minimal library for building one-off concurrent data pipelines

Project description

minpipe

minpipe is a minimal library for building one-off concurrent data pipelines in python. It was inspired by pypeln.

Example

import numpy as np
from minpipe import Pipeline, Signal, Stage

def make_random_data():
    x = np.random.randn(10, 10, 10000)

    def random_data():
        for xi in x:
            yield xi
        yield Signal.STOP

    return random_data

def mean(xi):
    yield np.mean(xi, axis=-1)

def flatten(means):
    for m in means:
        yield m

def filter_pos(m):
    if m > 0:
        yield m

def printout(m):
    print(f"mean={m:.2f}")

pipeline = Pipeline(
    Stage(make_random_data()),
    Stage(mean, num_workers=2),
    Stage(flatten, num_workers=1),
    Stage(filter_pos),
    Stage(printout),
)

# serial debug run
# pipeline.serial(max_items=10)

pipeline.start()
pipeline.join()

Installation

pip install minpipe

See also

Licence

MIT

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

minpipe-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file minpipe-0.1.0.tar.gz.

File metadata

  • Download URL: minpipe-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.59.0 importlib-metadata/3.10.0 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.7.10

File hashes

Hashes for minpipe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 07df6e7ca4dfef74e0f7d904f67a3e32ae4ecde5e3d8b327c252a74c74b3a4a2
MD5 098864f0770357789f8a1fe19dc5b4b8
BLAKE2b-256 44323ee148bca06dba5d6e809184e7e9d64afbc09b67ed979e0a16b817abd861

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