Framework for Decision Pipeline modeling and execution
Project description
nextpipe
Framework for Decision Pipeline modeling and execution.
Installation
pip install nextpipe
Preview
Example of a pipeline utilizing multiple routing solvers, and picking the best result.
graph LR
fetch_data(prepare_data)
fetch_data --> run_nextroute
fetch_data --> run_ortools
fetch_data --> run_pyvroom
run_nextroute{ }
run_nextroute_join{ }
run_nextroute_0(run_nextroute_0)
run_nextroute --> run_nextroute_0
run_nextroute_0 --> run_nextroute_join
run_nextroute_1(run_nextroute_1)
run_nextroute --> run_nextroute_1
run_nextroute_1 --> run_nextroute_join
run_nextroute_2(run_nextroute_2)
run_nextroute --> run_nextroute_2
run_nextroute_2 --> run_nextroute_join
run_nextroute_join --> pick_best
run_ortools(run_ortools)
run_ortools --> pick_best
run_pyvroom(run_pyvroom)
run_pyvroom --> pick_best
pick_best(pick_best)
Modeling
Pipeline modeling is done by defining a flow as steps and decorating them. The following example demonstrates a 3 step pipeline that makes use of dynamic fanout and joining of results.
from nextpipe import AppOption, AppRunConfig, FlowSpec, app, foreach, join, needs, step
class Flow(FlowSpec):
@foreach() # Run the successor step for each item in the result list of this step
@step
def prepare(data: dict):
"""
Creates 3 copies of the input and configures them for 3 different app parameters.
"""
inputs = [copy.deepcopy(data) for _ in range(3)]
run_configs = [AppRunConfig(input, [AppOption("param", i)]) for i, input in enumerate(inputs)]
return run_configs
@app(app_id="echo")
@needs(predecessors=[prepare])
@step
def solve():
"""
Imitates a solver app.
"""
pass
@needs(predecessors=[solve])
@join() # Collect the results from the previous 'foreach' step and combine them into a list passed as the arg
@step
def merge(results: list[dict]):
"""Merges the results."""
return results
The pipeline can simply be executed from the main func of the app.
# Run workflow
flow = Flow("DecisionFlow", input.data)
flow.run()
# Write out the result
print(json.dumps(flow.get_result(flow.merge)))
Examples
You can find further examples of how to use nextpipe in the examples directory.
Project details
Release history Release notifications | RSS feed
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
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 nextpipe-0.1.0.dev6.tar.gz.
File metadata
- Download URL: nextpipe-0.1.0.dev6.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1873dda94ed9d41fd2430f31f0da8f545423cf6d442e88c0ae25c3ccbc58185
|
|
| MD5 |
3bb3b081753c7c25303a24f36f8da98a
|
|
| BLAKE2b-256 |
831c0c2f038c9956a222332da03ae8c55003d47837047d987ae0582029544003
|
Provenance
The following attestation bundles were made for nextpipe-0.1.0.dev6.tar.gz:
Publisher:
release.yml on nextmv-io/nextpipe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nextpipe-0.1.0.dev6.tar.gz -
Subject digest:
e1873dda94ed9d41fd2430f31f0da8f545423cf6d442e88c0ae25c3ccbc58185 - Sigstore transparency entry: 185848070
- Sigstore integration time:
-
Permalink:
nextmv-io/nextpipe@47342363c04341bc3a78ab2d4e2fb249e6fdff63 -
Branch / Tag:
refs/heads/merschformann/simplify-step-execution - Owner: https://github.com/nextmv-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@47342363c04341bc3a78ab2d4e2fb249e6fdff63 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file nextpipe-0.1.0.dev6-py3-none-any.whl.
File metadata
- Download URL: nextpipe-0.1.0.dev6-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49ad5442a8bfac59dc3ac249ff6c4fd20aa1be7bd2bf30afcac4721971fe5395
|
|
| MD5 |
456dec0e76906736b4a9ae976413b0d7
|
|
| BLAKE2b-256 |
d765bfebdb1ad4cee99876257e61d955f3d0d4fd3f044b748d2f8deb581f20f4
|
Provenance
The following attestation bundles were made for nextpipe-0.1.0.dev6-py3-none-any.whl:
Publisher:
release.yml on nextmv-io/nextpipe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nextpipe-0.1.0.dev6-py3-none-any.whl -
Subject digest:
49ad5442a8bfac59dc3ac249ff6c4fd20aa1be7bd2bf30afcac4721971fe5395 - Sigstore transparency entry: 185848072
- Sigstore integration time:
-
Permalink:
nextmv-io/nextpipe@47342363c04341bc3a78ab2d4e2fb249e6fdff63 -
Branch / Tag:
refs/heads/merschformann/simplify-step-execution - Owner: https://github.com/nextmv-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@47342363c04341bc3a78ab2d4e2fb249e6fdff63 -
Trigger Event:
workflow_dispatch
-
Statement type: