lazydep
Evaluates some set of functions, according to tome dependency graph structure
There's pretty much 1 function that is worth noting:
lazydep.resolve(graph, state, functions, request=None)
Arguments
- graph: dictionary, mapping function names to the names of parameters required for their execution
- state: dictionary, initial input to functions. the remainder of intermediary parameters will be bootstrapped
- functions: list of functions in any order, or dictionary mapping function names to functions
- request: name of desired function evaluation. If request is specified, only the desired function call will be returned. If left empty, all functions specified will be returned, in the same form as state object.
Returns
dictionary, or result of 'request' function
Example
# Each key here corresponds to a function name
# Once evaluated, a function's return value is stored as a key as its name
depGraph = {
# Once we specify seed, all else will be inferred
'f1': 'seed',
'f2': 'f1',
'f3': ['f1','f2'],
# Function unused. If we only request 'f3', these will never be evaluated
'f4': 'f3',
'f5': 'f6',
'f6': 'seed'
}
# Functions will receive parameters according to the dependency graph
# Keyword args only, positional args not supported
def f1(seed):
return seed % 10
def f2(f1):
return [f1]*f1
def f3(f1, f2):
return (f1,sum(f2))
# The initial information, some set of named parameters.
istate = {'seed': 42}
res = lazydep.resolve(
# How are inputs and outputs reordered?
graph = depGraph,
# What information are we working with?
state = istate,
# What functions are allowed?
functions = [f1,f2,f3],
# Which function output are we requesting?
# If request == None, we will return the aggregate state, after running all functions
request = 'f3',
)
assert( res == (2,4) )
Metadata
Release files for lazydep 1.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 | |
|---|---|---|---|
| lazydep-1.1.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lazydep-1.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 7.4 kB
Release files / lazydep-1.1.tar.gz
| Download URL | lazydep-1.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0bc3a74adc221011a3a7670c59813eb309ff50c34a97255cafdb802c9142e367
|
|
BLAKE2b-256 checksum How to use checksums |
4d860db3adf08136cfd222007aa70006649987bdad89211d0ad03aa5e6a06777
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|
Release files / lazydep-1.1-py2.py3-none-any.whl
| Download URL | lazydep-1.1-py2.py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
45de234a3dbce193a6fa1f3cae19947271736af379c00c28b2a26a8273bcadb6
|
|
BLAKE2b-256 checksum How to use checksums |
ba6ef5bfbde470bc3cf54a480d3ae7475466765ef9ddfb7fbb707003a45dea56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|