A module for defining pipeline processing graphs.
Project description
pypegraph
Pypegraph is a python library to create directed acyclic graphs (DAG) that represent data processing pipelines. In a pypegraph graph, each node contains a function wich output is sendend to the connected nodes and are used as input of those nodes's functions.
Installation
pip install pypegraph
Common usage
node1 = Node(lambda: print("Node1 is executing"), name="Node1")
node2 = Node(lambda: print("Node2 is executing"), name="Node2")
node1 |= node2 # connect both nodes node1 -> node2
outputs = node1() # dictionary with each node outputs
node1_output = outputs[node1] # None in this case because it does not return anything
node2_output = outputs[node2] # None also
You can connect one node's output to a named parameter of another node's function input
def foo(n):
return n
def square(number):
return number * number
node1 = Node(foo, name="Node1")
node2 = Node(square, name="Node2")
node1 |= (node2, "number") # connect both nodes with a connection name
outputs = node1(2)
node2_output = outputs[node2] # should be 4
Connections
You can connect nodes in several ways
node1 = Node(lambda: print("Node1 is executing"), name="Node1")
node2 = Node(lambda: print("Node2 is executing"), name="Node2")
# you can do
n1 = n1 | n2
# or
n1 |= n2
# or
n1.connect(n2)
# nodes can be disconnected with
n1.disconnect(n2)
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
pypegraph-0.1.5.tar.gz
(6.5 kB
view details)
Built Distribution
File details
Details for the file pypegraph-0.1.5.tar.gz
.
File metadata
- Download URL: pypegraph-0.1.5.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6248ea53e686cdf0653a688a31757f7115f5d0b7686035376e1bab953ed4d73 |
|
MD5 | 8cd7de4e1b9a528ebefff2ae8d36482d |
|
BLAKE2b-256 | 8d26fc5a4e35c0f20515257ce5869fe335361b533da0ac2aa52a43a11b539f4b |
File details
Details for the file pypegraph-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: pypegraph-0.1.5-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b0bbb4e003a05cab840b8e8538b0edd471138f0a997a99a45e5b983c740b906 |
|
MD5 | ea07ad554c56a8f4c8d05def50e005ff |
|
BLAKE2b-256 | 6e72bd5ee9a4228a63952e8cd811159211cc8a09140cb09340ee03eee912e3bb |