diff options
| author | Yuval Adam <_@yuv.al> | 2025-03-21 22:20:57 +0100 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2025-03-21 22:21:56 +0100 |
| commit | 7bfc742f68061ddfde308336a1d4d47c52da1913 (patch) | |
| tree | 08d1badb4e09d761422260f2b20847ca422df93b | |
| parent | 9b56aaa7a1aefc2fd07e3bf4baedf9206d9dd7ad (diff) | |
Update description
| -rw-r--r-- | README.md | 26 | ||||
| -rw-r--r-- | pyproject.toml | 2 | ||||
| -rw-r--r-- | rivulet/tests/test_batch.py | 4 |
3 files changed, 18 insertions, 14 deletions
@@ -1,18 +1,22 @@ # Rivulet -Elegant asynchronous data streams +Lightweight asynchronous data streams ```python -from rivulet import BatchProcessor - -async def item_stream(): - for i in range(10): - yield i - await asyncio.sleep(0.1) +from rivulet import Pipeline, Batch async def main(): - processor = BatchProcessor(batch_size=3, timeout_seconds=0.5) - - async for batch in processor.process(item_stream()): - print(f"Processing batch of {len(batch)} items: {batch}") + pipe = Pipeline(source()) + pipe.add_step(double) + + batch = Batch(N=5, timeout=0.1) + pipe.add_step(batch) + pipe.add_step(sum) + + # run the pipeline + async for out in pipe: + print(out) + + # or collect them all + res = await pipe.collect() ```
\ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 6565b62..948523c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "rivulet" version = "0.1.0" -description = "Elegant asynchronous data streams" +description = "Lightweight asynchronous data streams" readme = "README.md" requires-python = ">=3.8" authors = [ diff --git a/rivulet/tests/test_batch.py b/rivulet/tests/test_batch.py index 6b32462..5c17175 100644 --- a/rivulet/tests/test_batch.py +++ b/rivulet/tests/test_batch.py @@ -1,14 +1,14 @@ import asyncio import pytest -from ..batch import Batch # Update with your actual import +from ..batch import Batch class TestBatch: @pytest.mark.asyncio async def test_batch_by_size(self): # Test batching by size - batch_processor = Batch[int](N=3, timeout=10.0) # Long timeout + batch_processor = Batch[int](N=3, timeout=10) # Long timeout async def source(): for i in range(8): # 8 items should produce 2 full batches and 1 partial |
