Using a defined data schema to pass data between nodes in the pipeli.
Project description
Pipe-by-Schema
Using defined data schema to passing between nodes of pipeline, much more easier to maintain your complex workflow.
Installation
- Python 3.9+
- poetry 1.7.1
pip install pipesche
or
poetry install
Quick Start
- Implement the
runmethod of node class and define input and output schema.
from dataclasses import dataclass
from pipesche import BaseNode
@dataclass
class AddPayload:
x: int
y: int
class Add(BaseNode[AddPayload, int]):
def run(self, payload: AddPayload) -> int:
result = payload.x + payload.y
print(f"{payload.x} + {payload.y} = {result}")
return result
class PrintSomeThing(BaseNode[None, None]):
def run(self, payload: None) -> None:
print("Some thing...")
- Add the nodes to pipeline and link the nodes.
from pipesche import Pipeline
node_1 = Add("node_1")
node_2 = PrintSomeThing("node_2")
node_3 = Add("node_3")
pipeline = Pipeline()
pipeline.add_node(node_1, input_key="input_1")
pipeline.add_node(node_2)
pipeline.add_node(node_3, input_key="input_2")
pipeline.connect(node_1.name, node_3.name)
pipeline.connect(node_3.name, node_2.name)
pipeline.run({"input_1": AddPayload(1, 2), "input_2": AddPayload(3, 4)})
# Output:
# 1 + 2 = 3
# 3 + 4 = 7
# Some thing...
- Get the result of the node.
pipeline.get_data(key=node_3.name)
# Output:
# 7
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pipesche-0.1.3.tar.gz
(5.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pipesche-0.1.3.tar.gz.
File metadata
- Download URL: pipesche-0.1.3.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4008ac69e4051cfd4c1db5bb2eb9e52acbd104d28729e9edb2dec2a4ef2d381
|
|
| MD5 |
9f5a247334112862f74d4e6965853356
|
|
| BLAKE2b-256 |
83bfca2e8e79834190c59ceaf00fd7bbb50ecd44ab3c902d0345e0284f82609f
|
File details
Details for the file pipesche-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pipesche-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b4e511e3dcc7f7b4de527df09505c2360d76e9988b6e99ccd4999fa2e8b02b8
|
|
| MD5 |
b6ea652b960d32bda513a6d689cc3658
|
|
| BLAKE2b-256 |
1fb14ce841c1e9df15be697f232308a9fd9812ad42eac0ac7e3be5844d62a6ff
|