Skip to main content

TinyPipe

TinyPipe is a lightweight library that facilitates the application of the Pipeline Pattern. A pipeline has a general form as follows:

       |---|    |----|    |- -|    |----|    |---|
... -> | Q | -> | OP | -> | Q | -> | OP | -> | Q | -> ...
       |---|    |----|    |---|    |----|    |---|

As data flows through the pipeline, it is first fed into the input queue (denoted as Q above). The following operation unit (OP) grabs it and produces a result, which is then fed into its output queue. This process continues until the data encounters a terminating OP which has no output queue.

Building blocks are provided for pipeline construction, where each operation unit (represented by Pipe), owns a threads and runs individually. A ParallelPipe is also included for an operation to run with multiple threads. See the documentation for detail.

Setup

Python version: 3.6+ (other versions not tested, feel free to try it out!)

To install TinyPipe:

$ pip install tinypipe

Usage

Suppose every data has to go through the functions f1, f2, and f3 in sequence. The pipeline can be constructed by:

import tinypipe as tp

# 1. Create pipeline
pipeline = tp.Pipeline()

# 2. Append pipes to pipeline
f1_pipe = tp.pipe.FunctionPipe(f1)
pipeline.append(f1_pipe)

f2_pipe = tp.pipe.FunctionPipe(f2)
pipeline.append(f2_pipe)

f3_pipe = tp.pipe.FunctionPipe(f3)
pipeline.append(f3_pipe)
# One can call `pipeline.extend([f1_pipe, f2_pipe, f3_pipe])` instead

# 3. Build & start the pipeline
# Once the pipeline is started, it will keep trying to get data to process
#
# The following `pipeline.build()` call is optional. `pipeline.start()` will
# make the call if it is not called.
#
# pipeline.build()
pipeline.start()

# 5. Feed data into the pipeline
data_iterator = ...
for data in data_iterator:
  pipeline.put(data)

# 6. If all the data has been passed into the pipeline,
#    wait for it to finish all the work.
pipeline.join()

Release files for tinypipe 0.1.2

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

Source distribution (sdist)

Source distribution for tinypipe 0.1.2
File Size Uploaded
tinypipe-0.1.2.tar.gz 7.0 kB Details

Built distribution (wheel)

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

Total release size: 20.6 kB

Release files / tinypipe-0.1.2.tar.gz

Download URL tinypipe-0.1.2.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
eecf2fa9e823d7641df010334e4a4ea6d879c2f870ac9f6242078798e88cf1d3
BLAKE2b-256 checksum
How to use checksums
fa73210f350ee18edb96de787de91b8cb294d64dde5872264ffa3628532c76e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.15.0 CPython/3.6.1

Release files / tinypipe-0.1.2-py3-none-any.whl

Download URL tinypipe-0.1.2-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e3d350e99ffda215866b46e6435593b212b5600049baffb99653bb2b82606ab
BLAKE2b-256 checksum
How to use checksums
9994a50f7407cc9b6618dd18f1aa06bf07730388a49c66e24c185a6034752464
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.15.0 CPython/3.6.1

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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