Coroflow: Easy and Fast Pipelines
Coroflow makes it easy to run pipelines with coroutines and also support mixing in blocking functions and generators.
Coroflow does a lot of heavy-lifting for you:
- Manage all tasks in the pipelinen concurently in one thread using coroutines
- Pass data between tasks with queues
- Easily specify concurrency limits
- Connect stages of the pipeline with fan-out/fan-in patterns or load-balancer patterns
- Define tasks as coroutines, normal (blocking) functions, async generators or normal generators; coroflow will run it appropriately in either the event-loop, a thread pool, or optionally in a processes pool
- Provides an apache-ariflow-like api for connecting tasks
Getting Started
Coroflow makes it easy to run pipelines with coroutines and also support mixing in blocking functions and generators
from coroflow import Node, Pipeline
import asyncio
import time
class GenNode(Node):
async def execute():
"""
The execute method of the first/root Node has to be a generator,
either async or synchronous.
"""
for url in ['img_url_1', 'img_url_2', 'img_url_3']:
print(f"Yielding {url}")
await asyncio.sleep(1)
yield url
print("Generator is exhausted")
return
class DoSomething(Node):
async def execute(inpt, param=None):
"""
The execute method of all non-root Nodes should be a async
or synchronous method.
"""
# do your async pipelined work
await asyncio.sleep(1) # simulated IO delay
outp = inpt
print(f"func1: T1 sending {inpt}")
return outp
p = Pipeline()
t0 = GenNode('gen', p)
t1 = DoSomething('func1', p, kwargs={'param': 'param_t1'})
t2 = DoSomething('func2', p, kwargs={'param': 'param_t2'})
t0.set_downstream(t1)
t1.set_downstream(t2)
start_time = time.time()
p.run()
print(f"Asynchronous duration: {time.time() - start_time}s.")
Tests
Run like so:
$ pytest
Metadata
Release files for coroflow 4.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| coroflow-4.0.1.tar.gz | 8.9 kB | Without provenance | Details for coroflow-4.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| coroflow-4.0.1-py3-none-any.whl | Python 3 | none | any | Details for coroflow-4.0.1-py3-none-any.whl |
Total release size: 17.1 kB
Release files / coroflow-4.0.1.tar.gz
| Download URL | coroflow-4.0.1.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e550cf9779799b0af6fe5f83e3ae23b11bf18bd5dbed4762f59b46a7ab11912
|
|
BLAKE2b-256 checksum How to use checksums |
262d7de067dd493cdbb6e1d93a6f124aa9da1ac95235ecc673d42fd3d52dc56c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.7.3 Linux/5.10.68+
|
Release files / coroflow-4.0.1-py3-none-any.whl
| Download URL | coroflow-4.0.1-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
577679d41efdc5d02716791da35f841dccc180086a9ec80db26b10021295f298
|
|
BLAKE2b-256 checksum How to use checksums |
4bc869bd268da2b97456c81ecc23b1928d56f80b6519448f263b9319f5b08134
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.7.3 Linux/5.10.68+
|
Security for coroflow 4.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.