Function dependencies resolution and execution
Project description
pyungo is a lightweight library to link a set of dependent functions together, and execute them in an ordered manner.
pyungo is built around Graphs and Nodes used in a DAG (Directed Acyclic Graph). A Node represent a function being run with a defined set of inputs and returning one or several outputs. A Graph is a collection of Nodes where data can flow in an logical manner, the output of one node serving as input of another.
installation
>> pip install pyungo
simple example
graph = Graph()
@graph.register()
def f_my_function_2(d, a):
e = d - a
return e
@graph.register()
def f_my_function_1(c):
d = c / 10
return d
@graph.register()
def f_my_function_3(a, b):
c = a + b
return c
res = graph.calculate(data={'a': 2, 'b': 3})
print(res)
pyungo is registering the functions at import time. It then resolve the DAG and figure out the sequence at which the functions have to be run per their inputs / outputs. In this case, it will be function 3 then 1 and finally 2.
The ordered Graph is run with calculate, with the given data. It returns the output of the last function being run (e), but all intermediate results are also available in the graph instance.
The result will be (a + b) / 10 - a = -1.5
links
Documentation: https://cedricleroy.github.io/pyungo/
Releases: https://pypi.org/project/pyungo/
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
Built Distribution
File details
Details for the file pyungo-0.9.0.tar.gz
.
File metadata
- Download URL: pyungo-0.9.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a713df94dd8704bbe1c2587676568d6968fc55be06fb88e26fad7844ec58303 |
|
MD5 | 625d87bb8307c547f523c7a11605706d |
|
BLAKE2b-256 | 874a71cb4fab712dbffe6c1335a28377d2021778a51f78c4ce8dfe4f9c705573 |
File details
Details for the file pyungo-0.9.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pyungo-0.9.0-py2.py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 773eddf38f7d703a510f0ca1b4d2a59ef3d8cfcdfa06e3d472d7ed48e8170645 |
|
MD5 | d862a63995f88114581898fcd7e0089d |
|
BLAKE2b-256 | ff0eb6d69990a521e174ca95495db582df5a763c625f922743545b05fb8a2d6a |