Skip to main content

Experimental in-memory data flow pipelines.

Project description

Experiments in data flow programming.

https://travis-ci.org/geowurster/tinyflow.svg?branch=master https://coveralls.io/repos/geowurster/tinyflow/badge.svg?branch=master

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))

Developing

$ git clone https://github.com/geowurster/tinyflow.git
$ cd tinyflow
$ pip install -e .\[all\]
$ pytest --cov tinyflow --cov-report term-missing

License

See LICENSE.txt

Changelog

See CHANGES.md

Project details


Release history Release notifications | RSS feed

This version

0.1

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 Python 2 Python 3

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