Skip to main content

Experimental in-memory data flow pipelines.

Project description

Experiments in data flow programming.

After some experimentation, Apache Beam’s Python SDK got the API right. Use that instead.

Standard Word Count Example

Grab the 5 most common words in LICENSE.txt

from collections import Counter

from tinyflow.serial import ops, Pipeline

pipe = Pipeline() \
    | "Split line into words" >> ops.flatmap(lambda x: x.lower().split()) \
    | "Remove empty lines" >> ops.filter(bool) \
    | "Produce the 5 most common words" >> ops.counter(5) \
    | "Sort by frequency desc" >> ops.sort(key=lambda x: x[1], reverse=True)

with open('LICENSE.txt') as f:
    results = dict(pipe(f))

Using only Python’s builtins:

from collections import Counter
import itertools as it

with open('LICENSE.txt') as f:
    lines = (line.lower().split() for line in f)
    words = it.chain.from_iterable(lines)
    count = Counter(words)
    results = dict(count.most_common(10))


$ git clone
$ cd tinyflow
$ pip install -e .\[all\]
$ pytest --cov tinyflow --cov-report term-missing





Project details

Release history Release notifications | RSS feed

This version


Download files

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

Source Distribution

tinyflow-0.1.macosx-10.12-x86_64.tar.gz (13.1 kB view hashes)

Uploaded source

Built Distribution

tinyflow-0.1-py2.py3-none-any.whl (10.9 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page