nextpipe 0.2.2.dev0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/.gitignore +3 -0
- nextpipe-0.3.0/.markdownlint.jsonc +51 -0
- nextpipe-0.3.0/.readthedocs.yaml +19 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/PKG-INFO +48 -57
- nextpipe-0.3.0/README.md +81 -0
- nextpipe-0.3.0/docs/examples/basic-chained-workflow.md +123 -0
- nextpipe-0.3.0/docs/examples/complex-workflow-csv.md +345 -0
- nextpipe-0.3.0/docs/examples/complex-workflow.md +264 -0
- nextpipe-0.3.0/docs/examples/ensemble-workflow.md +663 -0
- nextpipe-0.3.0/docs/examples/fanout-workflow.md +187 -0
- nextpipe-0.3.0/docs/images/logo-180.png +0 -0
- nextpipe-0.3.0/docs/images/nextmv-favicon.svg +4 -0
- nextpipe-0.3.0/docs/images/routing-ortools-pyvroom-selected.png +0 -0
- nextpipe-0.3.0/docs/images/routing-selected.png +0 -0
- nextpipe-0.3.0/docs/index.md +78 -0
- nextpipe-0.3.0/docs/reference/config.md +5 -0
- nextpipe-0.3.0/docs/reference/decorators.md +5 -0
- nextpipe-0.3.0/docs/reference/flow.md +6 -0
- nextpipe-0.3.0/docs/reference/graph.md +6 -0
- nextpipe-0.3.0/docs/reference/schema.md +5 -0
- nextpipe-0.3.0/docs/reference/threads.md +5 -0
- nextpipe-0.3.0/docs/reference/uplink.md +5 -0
- nextpipe-0.3.0/docs/reference/utils.md +5 -0
- nextpipe-0.3.0/docs/requirements.txt +4 -0
- nextpipe-0.3.0/docs/tutorials/echo.md +114 -0
- nextpipe-0.3.0/docs/tutorials/getting-started.md +259 -0
- nextpipe-0.3.0/mkdocs.yml +142 -0
- nextpipe-0.3.0/nextpipe/__about__.py +1 -0
- nextpipe-0.3.0/nextpipe/config.py +56 -0
- nextpipe-0.3.0/nextpipe/decorators.py +959 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/nextpipe/flow.py +602 -15
- nextpipe-0.3.0/nextpipe/graph.py +84 -0
- nextpipe-0.3.0/nextpipe/schema.py +114 -0
- nextpipe-0.3.0/nextpipe/threads.py +278 -0
- nextpipe-0.3.0/nextpipe/uplink.py +420 -0
- nextpipe-0.3.0/nextpipe/utils.py +305 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/pyproject.toml +1 -1
- nextpipe-0.3.0/tests/test_schema.py +21 -0
- nextpipe-0.2.2.dev0/README.md +0 -90
- nextpipe-0.2.2.dev0/examples/README.md +0 -19
- nextpipe-0.2.2.dev0/examples/apps/echo/README.md +0 -17
- nextpipe-0.2.2.dev0/examples/apps/echo/input.json +0 -1
- nextpipe-0.2.2.dev0/examples/apps/echo/requirements.txt +0 -1
- nextpipe-0.2.2.dev0/examples/pipeline-chain/README.md +0 -25
- nextpipe-0.2.2.dev0/examples/pipeline-chain/app.yaml +0 -6
- nextpipe-0.2.2.dev0/examples/pipeline-chain/main.py +0 -43
- nextpipe-0.2.2.dev0/examples/pipeline-chain/requirements.txt +0 -1
- nextpipe-0.2.2.dev0/examples/pipeline-complex/README.md +0 -43
- nextpipe-0.2.2.dev0/examples/pipeline-complex/app.yaml +0 -6
- nextpipe-0.2.2.dev0/examples/pipeline-complex/main.py +0 -83
- nextpipe-0.2.2.dev0/examples/pipeline-complex/requirements.txt +0 -1
- nextpipe-0.2.2.dev0/examples/pipeline-ensemble/README.md +0 -34
- nextpipe-0.2.2.dev0/examples/pipeline-ensemble/app.yaml +0 -6
- nextpipe-0.2.2.dev0/examples/pipeline-ensemble/main.py +0 -48
- nextpipe-0.2.2.dev0/examples/pipeline-ensemble/requirements.txt +0 -1
- nextpipe-0.2.2.dev0/examples/pipeline-foreach/README.md +0 -28
- nextpipe-0.2.2.dev0/examples/pipeline-foreach/app.yaml +0 -6
- nextpipe-0.2.2.dev0/examples/pipeline-foreach/main.py +0 -70
- nextpipe-0.2.2.dev0/examples/pipeline-foreach/requirements.txt +0 -1
- nextpipe-0.2.2.dev0/examples/pipeline-preprocess/README.md +0 -46
- nextpipe-0.2.2.dev0/examples/pipeline-preprocess/app.yaml +0 -6
- nextpipe-0.2.2.dev0/examples/pipeline-preprocess/main.py +0 -109
- nextpipe-0.2.2.dev0/examples/pipeline-preprocess/requirements.txt +0 -1
- nextpipe-0.2.2.dev0/nextpipe/__about__.py +0 -1
- nextpipe-0.2.2.dev0/nextpipe/config.py +0 -22
- nextpipe-0.2.2.dev0/nextpipe/decorators.py +0 -497
- nextpipe-0.2.2.dev0/nextpipe/graph.py +0 -44
- nextpipe-0.2.2.dev0/nextpipe/schema.py +0 -28
- nextpipe-0.2.2.dev0/nextpipe/threads.py +0 -101
- nextpipe-0.2.2.dev0/nextpipe/uplink.py +0 -212
- nextpipe-0.2.2.dev0/nextpipe/utils.py +0 -115
- nextpipe-0.2.2.dev0/tests/apps/echo/.gitignore +0 -1
- nextpipe-0.2.2.dev0/tests/apps/echo/app.yaml +0 -6
- nextpipe-0.2.2.dev0/tests/apps/echo/main.py +0 -17
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/.github/workflows/lint.yml +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/.github/workflows/release.yml +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/.github/workflows/test.yml +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/.nextmv/bump_requirements.sh +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/.prettierrc.yml +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/LICENSE.md +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/nextpipe/__init__.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/nextpipe.code-workspace +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/.gitignore +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/README.md +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/__init__.py +0 -0
- {nextpipe-0.2.2.dev0/examples → nextpipe-0.3.0/tests}/apps/echo/.gitignore +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/apps/echo/README.md +0 -0
- {nextpipe-0.2.2.dev0/examples → nextpipe-0.3.0/tests}/apps/echo/app.yaml +0 -0
- {nextpipe-0.2.2.dev0/examples → nextpipe-0.3.0/tests}/apps/echo/main.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/apps/echo/requirements.txt +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/deploy/app.yaml +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/deploy/main.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/deploy/requirements.txt +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/chain.json +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/chain.json.golden +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/chain.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/complex.json +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/complex.json.golden +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/complex.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/fail.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/foreach-2-pred.json +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/foreach-2-pred.json.golden +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/foreach-2-pred.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/foreach.json +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/foreach.json.golden +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/pipelines/foreach.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/test_graph.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/test_integration.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/test_threads.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/test_uplink.py +0 -0
- {nextpipe-0.2.2.dev0 → nextpipe-0.3.0}/tests/test_version.py +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Reference: https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
|
|
2
|
+
// Rules: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#rules
|
|
3
|
+
//
|
|
4
|
+
// Run markdown linting:
|
|
5
|
+
// - Install [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2):
|
|
6
|
+
// npm install markdownlint-cli2 --global
|
|
7
|
+
// - Lint. Stand at the root of the repo and run:
|
|
8
|
+
// markdownlint-cli2 "**/*.md"
|
|
9
|
+
// - Ignore a certain rule for some lines:
|
|
10
|
+
// <!-- markdownlint-disable MD013 -->
|
|
11
|
+
// Your line here
|
|
12
|
+
// <!-- markdownlint-enable MD013 -->
|
|
13
|
+
{
|
|
14
|
+
// Use the default configurations as a starting point
|
|
15
|
+
"default": true,
|
|
16
|
+
|
|
17
|
+
// Max line length configurations
|
|
18
|
+
"MD013": {
|
|
19
|
+
"code_blocks": false,
|
|
20
|
+
"headings": false,
|
|
21
|
+
"line_length": 100,
|
|
22
|
+
"stern": false,
|
|
23
|
+
"strict": false,
|
|
24
|
+
"tables": false
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
// GitBook compatibility configurations
|
|
28
|
+
// Unordered lists use asterisks
|
|
29
|
+
"MD004": { "style": "asterisk" },
|
|
30
|
+
|
|
31
|
+
// First line in a file should be a top-level heading specifying a
|
|
32
|
+
// description, as such:
|
|
33
|
+
// ---
|
|
34
|
+
// description: You will learn the basics of getting started on cloud.
|
|
35
|
+
// ---
|
|
36
|
+
"MD041": { "level": 1, "front_matter_title": "^\\s*description\\s*[:=]" },
|
|
37
|
+
|
|
38
|
+
// There can only be a single top-level heading, which should be the YAML
|
|
39
|
+
// front matter containing the "title" property.
|
|
40
|
+
"MD025": { "level": 1, "front_matter_title": "^\\s*title\\s*[:=]" },
|
|
41
|
+
|
|
42
|
+
// Don't enforce heading level continuity.
|
|
43
|
+
"MD001": false,
|
|
44
|
+
|
|
45
|
+
// Use spaces as opposed to hard-tabs for consistency.
|
|
46
|
+
"MD010": { "spaces_per_tab": 4 },
|
|
47
|
+
|
|
48
|
+
// Material for mkdocs has admonitions which are indented by 4 spaces and not
|
|
49
|
+
// fenced.
|
|
50
|
+
"MD046": false
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Read the Docs configuration file for MkDocs projects
|
|
2
|
+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
|
3
|
+
|
|
4
|
+
# Required
|
|
5
|
+
version: 2
|
|
6
|
+
|
|
7
|
+
# Set the version of Python and other tools you might need
|
|
8
|
+
build:
|
|
9
|
+
os: ubuntu-22.04
|
|
10
|
+
tools:
|
|
11
|
+
python: "3.11"
|
|
12
|
+
|
|
13
|
+
mkdocs:
|
|
14
|
+
configuration: mkdocs.yml
|
|
15
|
+
|
|
16
|
+
# Optionally declare the Python requirements required to build your docs
|
|
17
|
+
python:
|
|
18
|
+
install:
|
|
19
|
+
- requirements: docs/requirements.txt
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nextpipe
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Framework for Decision Pipeline modeling and execution
|
|
5
5
|
Project-URL: Homepage, https://www.nextmv.io
|
|
6
6
|
Project-URL: Documentation, https://www.nextmv.io/docs
|
|
@@ -105,26 +105,65 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
105
105
|
Classifier: Programming Language :: Python :: 3.13
|
|
106
106
|
Requires-Python: >=3.9
|
|
107
107
|
Requires-Dist: dataclasses-json>=0.6.7
|
|
108
|
-
Requires-Dist: nextmv>=0.
|
|
108
|
+
Requires-Dist: nextmv>=0.28.0
|
|
109
109
|
Requires-Dist: requests>=2.31.0
|
|
110
110
|
Provides-Extra: dev
|
|
111
111
|
Requires-Dist: goldie>=0.1.7; extra == 'dev'
|
|
112
112
|
Requires-Dist: ruff>=0.11.6; extra == 'dev'
|
|
113
113
|
Description-Content-Type: text/markdown
|
|
114
114
|
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
# Nextpipe
|
|
116
|
+
|
|
117
|
+
<!-- markdownlint-disable MD033 MD013 -->
|
|
118
|
+
|
|
119
|
+
<p align="center">
|
|
120
|
+
<a href="https://nextmv.io"><img src="https://cdn.prod.website-files.com/60dee0fad10d14c8ab66dd74/65c66addcd07eed09be35114_blog-banner-what-is-cicd-for-decision-science-p-2000.jpeg" alt="Nextmv" width="45%"></a>
|
|
121
|
+
</p>
|
|
122
|
+
<p align="center">
|
|
123
|
+
<em>Nextmv: The home for all your optimization work</em>
|
|
124
|
+
</p>
|
|
125
|
+
<p align="center">
|
|
126
|
+
<a href="https://github.com/nextmv-io/nextpipe/actions/workflows/test.yml" target="_blank">
|
|
127
|
+
<img src="https://github.com/nextmv-io/nextpipe/actions/workflows/test.yml/badge.svg?event=push&branch=develop" alt="Test">
|
|
128
|
+
</a>
|
|
129
|
+
<a href="https://github.com/nextmv-io/nextpipe/actions/workflows/lint.yml" target="_blank">
|
|
130
|
+
<img src="https://github.com/nextmv-io/nextpipe/actions/workflows/lint.yml/badge.svg?event=push&branch=develop" alt="Lint">
|
|
131
|
+
</a>
|
|
132
|
+
<a href="https://pypi.org/project/nextpipe" target="_blank">
|
|
133
|
+
<img src="https://img.shields.io/pypi/v/nextpipe?color=%2334D058&label=nextpipe" alt="Package version">
|
|
134
|
+
</a>
|
|
135
|
+
<a href="https://pypi.org/project/nextpipe" target="_blank">
|
|
136
|
+
<img src="https://img.shields.io/pypi/pyversions/nextpipe.svg?color=%2334D058" alt="Supported Python versions">
|
|
137
|
+
</a>
|
|
138
|
+
</p>
|
|
139
|
+
|
|
140
|
+
<!-- markdownlint-enable MD033 MD013 -->
|
|
141
|
+
|
|
142
|
+
Nextpipe is a Python package that provides a framework for Decision Workflows
|
|
143
|
+
modeling and execution. It provides first-class support for Workflows in the
|
|
144
|
+
[Nextmv Platform][nextmv].
|
|
145
|
+
|
|
146
|
+
> [!IMPORTANT]
|
|
147
|
+
> Please note that `nextpipe` is provided as _source-available_ software
|
|
148
|
+
> (not _open-source_). For further information, please refer to the
|
|
149
|
+
> [LICENSE](./LICENSE.md) file.
|
|
150
|
+
|
|
151
|
+
📖 To learn more about the `nextpipe`, visit the [docs][docs].
|
|
118
152
|
|
|
119
153
|
## Installation
|
|
120
154
|
|
|
155
|
+
The package is hosted on [PyPI][nextpipe-pypi]. Python `>=3.9` is required.
|
|
156
|
+
|
|
157
|
+
Install via `pip`:
|
|
158
|
+
|
|
121
159
|
```bash
|
|
122
160
|
pip install nextpipe
|
|
123
161
|
```
|
|
124
162
|
|
|
125
163
|
## Preview
|
|
126
164
|
|
|
127
|
-
Example of a pipeline utilizing multiple routing solvers, and picking the best
|
|
165
|
+
Example of a pipeline utilizing multiple routing solvers, and picking the best
|
|
166
|
+
result.
|
|
128
167
|
|
|
129
168
|
```mermaid
|
|
130
169
|
graph LR
|
|
@@ -151,54 +190,6 @@ graph LR
|
|
|
151
190
|
pick_best(pick_best)
|
|
152
191
|
```
|
|
153
192
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
The following example demonstrates a 3 step pipeline that makes use of dynamic fanout and joining of results.
|
|
158
|
-
|
|
159
|
-
```python
|
|
160
|
-
from nextpipe import AppOption, AppRunConfig, FlowSpec, app, foreach, join, needs, step
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
class Flow(FlowSpec):
|
|
164
|
-
@foreach() # Run the successor step for each item in the result list of this step
|
|
165
|
-
@step
|
|
166
|
-
def prepare(data: dict):
|
|
167
|
-
"""
|
|
168
|
-
Creates 3 copies of the input and configures them for 3 different app parameters.
|
|
169
|
-
"""
|
|
170
|
-
inputs = [copy.deepcopy(data) for _ in range(3)]
|
|
171
|
-
run_configs = [AppRunConfig(input, [AppOption("param", i)]) for i, input in enumerate(inputs)]
|
|
172
|
-
return run_configs
|
|
173
|
-
|
|
174
|
-
@app(app_id="echo")
|
|
175
|
-
@needs(predecessors=[prepare])
|
|
176
|
-
@step
|
|
177
|
-
def solve():
|
|
178
|
-
"""
|
|
179
|
-
Imitates a solver app.
|
|
180
|
-
"""
|
|
181
|
-
pass
|
|
182
|
-
|
|
183
|
-
@needs(predecessors=[solve])
|
|
184
|
-
@join() # Collect the results from the previous 'foreach' step and combine them into a list passed as the arg
|
|
185
|
-
@step
|
|
186
|
-
def merge(results: list[dict]):
|
|
187
|
-
"""Merges the results."""
|
|
188
|
-
return results
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
The pipeline can simply be executed from the main func of the app.
|
|
192
|
-
|
|
193
|
-
```python
|
|
194
|
-
# Run workflow
|
|
195
|
-
flow = Flow("DecisionFlow", input.data)
|
|
196
|
-
flow.run()
|
|
197
|
-
|
|
198
|
-
# Write out the result
|
|
199
|
-
print(json.dumps(flow.get_result(flow.merge)))
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
## Examples
|
|
203
|
-
|
|
204
|
-
You can find further examples of how to use `nextpipe` in the [examples](./examples) directory.
|
|
193
|
+
[nextpipe-pypi]: https://pypi.org/project/nextpipe/
|
|
194
|
+
[nextmv]: https://nextmv.io
|
|
195
|
+
[docs]: https://nextpipe.docs.nextmv.io/en/latest/
|
nextpipe-0.3.0/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Nextpipe
|
|
2
|
+
|
|
3
|
+
<!-- markdownlint-disable MD033 MD013 -->
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://nextmv.io"><img src="https://cdn.prod.website-files.com/60dee0fad10d14c8ab66dd74/65c66addcd07eed09be35114_blog-banner-what-is-cicd-for-decision-science-p-2000.jpeg" alt="Nextmv" width="45%"></a>
|
|
7
|
+
</p>
|
|
8
|
+
<p align="center">
|
|
9
|
+
<em>Nextmv: The home for all your optimization work</em>
|
|
10
|
+
</p>
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/nextmv-io/nextpipe/actions/workflows/test.yml" target="_blank">
|
|
13
|
+
<img src="https://github.com/nextmv-io/nextpipe/actions/workflows/test.yml/badge.svg?event=push&branch=develop" alt="Test">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://github.com/nextmv-io/nextpipe/actions/workflows/lint.yml" target="_blank">
|
|
16
|
+
<img src="https://github.com/nextmv-io/nextpipe/actions/workflows/lint.yml/badge.svg?event=push&branch=develop" alt="Lint">
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://pypi.org/project/nextpipe" target="_blank">
|
|
19
|
+
<img src="https://img.shields.io/pypi/v/nextpipe?color=%2334D058&label=nextpipe" alt="Package version">
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://pypi.org/project/nextpipe" target="_blank">
|
|
22
|
+
<img src="https://img.shields.io/pypi/pyversions/nextpipe.svg?color=%2334D058" alt="Supported Python versions">
|
|
23
|
+
</a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
<!-- markdownlint-enable MD033 MD013 -->
|
|
27
|
+
|
|
28
|
+
Nextpipe is a Python package that provides a framework for Decision Workflows
|
|
29
|
+
modeling and execution. It provides first-class support for Workflows in the
|
|
30
|
+
[Nextmv Platform][nextmv].
|
|
31
|
+
|
|
32
|
+
> [!IMPORTANT]
|
|
33
|
+
> Please note that `nextpipe` is provided as _source-available_ software
|
|
34
|
+
> (not _open-source_). For further information, please refer to the
|
|
35
|
+
> [LICENSE](./LICENSE.md) file.
|
|
36
|
+
|
|
37
|
+
📖 To learn more about the `nextpipe`, visit the [docs][docs].
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
The package is hosted on [PyPI][nextpipe-pypi]. Python `>=3.9` is required.
|
|
42
|
+
|
|
43
|
+
Install via `pip`:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install nextpipe
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Preview
|
|
50
|
+
|
|
51
|
+
Example of a pipeline utilizing multiple routing solvers, and picking the best
|
|
52
|
+
result.
|
|
53
|
+
|
|
54
|
+
```mermaid
|
|
55
|
+
graph LR
|
|
56
|
+
fetch_data(prepare_data)
|
|
57
|
+
fetch_data --> run_nextroute
|
|
58
|
+
fetch_data --> run_ortools
|
|
59
|
+
fetch_data --> run_pyvroom
|
|
60
|
+
run_nextroute{ }
|
|
61
|
+
run_nextroute_join{ }
|
|
62
|
+
run_nextroute_0(run_nextroute_0)
|
|
63
|
+
run_nextroute --> run_nextroute_0
|
|
64
|
+
run_nextroute_0 --> run_nextroute_join
|
|
65
|
+
run_nextroute_1(run_nextroute_1)
|
|
66
|
+
run_nextroute --> run_nextroute_1
|
|
67
|
+
run_nextroute_1 --> run_nextroute_join
|
|
68
|
+
run_nextroute_2(run_nextroute_2)
|
|
69
|
+
run_nextroute --> run_nextroute_2
|
|
70
|
+
run_nextroute_2 --> run_nextroute_join
|
|
71
|
+
run_nextroute_join --> pick_best
|
|
72
|
+
run_ortools(run_ortools)
|
|
73
|
+
run_ortools --> pick_best
|
|
74
|
+
run_pyvroom(run_pyvroom)
|
|
75
|
+
run_pyvroom --> pick_best
|
|
76
|
+
pick_best(pick_best)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
[nextpipe-pypi]: https://pypi.org/project/nextpipe/
|
|
80
|
+
[nextmv]: https://nextmv.io
|
|
81
|
+
[docs]: https://nextpipe.docs.nextmv.io/en/latest/
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Basic Chained Workflow Example
|
|
2
|
+
|
|
3
|
+
!!! tip
|
|
4
|
+
|
|
5
|
+
This example uses the [`echo` app](../tutorials/echo.md), make sure to complete
|
|
6
|
+
that tutorial first.
|
|
7
|
+
|
|
8
|
+
This is a basic example of a three-step, sequential workflow. It demonstrates
|
|
9
|
+
the basic structure of a workflow, which consists of steps being chained
|
|
10
|
+
together. Each step can depend on the output of the previous step.
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
import nextmv
|
|
16
|
+
|
|
17
|
+
from nextpipe import FlowSpec, app, needs, step
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Workflow(FlowSpec):
|
|
21
|
+
@step
|
|
22
|
+
def prepare(input: dict[str, Any]) -> dict[str, Any]:
|
|
23
|
+
"""Prepares the data."""
|
|
24
|
+
|
|
25
|
+
input["prepared"] = True
|
|
26
|
+
|
|
27
|
+
return input
|
|
28
|
+
|
|
29
|
+
@app(app_id="echo")
|
|
30
|
+
@needs(predecessors=[prepare])
|
|
31
|
+
@step
|
|
32
|
+
def solve() -> dict[str, Any]:
|
|
33
|
+
"""Runs the model."""
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
@needs(predecessors=[solve])
|
|
37
|
+
@step
|
|
38
|
+
def enhance(result: dict[str, Any]) -> dict[str, Any]:
|
|
39
|
+
"""Enhances the result."""
|
|
40
|
+
|
|
41
|
+
output = result["solution"]
|
|
42
|
+
output["enhanced"] = True
|
|
43
|
+
|
|
44
|
+
return output
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def main():
|
|
48
|
+
"""Runs the workflow."""
|
|
49
|
+
|
|
50
|
+
# Load input data
|
|
51
|
+
input = nextmv.load()
|
|
52
|
+
|
|
53
|
+
# Run workflow
|
|
54
|
+
workflow = Workflow("DecisionWorkflow", input.data)
|
|
55
|
+
workflow.run()
|
|
56
|
+
|
|
57
|
+
# Write the result
|
|
58
|
+
result = workflow.get_result(workflow.enhance)
|
|
59
|
+
nextmv.write(result)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if __name__ == "__main__":
|
|
63
|
+
main()
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Run the example:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
$ echo '{"hello": "world!"}' | python main.py
|
|
70
|
+
[nextpipe] No application ID or run ID found, uplink is inactive.
|
|
71
|
+
[nextpipe] Flow: Workflow
|
|
72
|
+
[nextpipe] nextpipe: v0.2.2.dev0
|
|
73
|
+
[nextpipe] nextmv: 0.28.0
|
|
74
|
+
[nextpipe] Flow graph steps:
|
|
75
|
+
[nextpipe] Step:
|
|
76
|
+
[nextpipe] Definition: Step(prepare)
|
|
77
|
+
[nextpipe] Docstring: Prepares the data.
|
|
78
|
+
[nextpipe] Step:
|
|
79
|
+
[nextpipe] Definition: Step(solve, StepNeeds(prepare), StepRun(echo, devint, {}, InputType.JSON, False))
|
|
80
|
+
[nextpipe] Docstring: Runs the model.
|
|
81
|
+
[nextpipe] Step:
|
|
82
|
+
[nextpipe] Definition: Step(enhance, StepNeeds(solve))
|
|
83
|
+
[nextpipe] Docstring: Enhances the result.
|
|
84
|
+
[nextpipe] Mermaid diagram:
|
|
85
|
+
[nextpipe] graph LR
|
|
86
|
+
prepare(prepare)
|
|
87
|
+
prepare --> solve
|
|
88
|
+
solve(solve)
|
|
89
|
+
solve --> enhance
|
|
90
|
+
enhance(enhance)
|
|
91
|
+
|
|
92
|
+
[nextpipe] Mermaid URL: https://mermaid.ink/svg/Z3JhcGggTFIKICBwcmVwYXJlKHByZXBhcmUpCiAgcHJlcGFyZSAtLT4gc29sdmUKICBzb2x2ZShzb2x2ZSkKICBzb2x2ZSAtLT4gZW5oYW5jZQogIGVuaGFuY2UoZW5oYW5jZSkK?theme=dark
|
|
93
|
+
[nextpipe] Running node prepare_0
|
|
94
|
+
[nextpipe] Running node solve_0
|
|
95
|
+
[nextpipe] Running node enhance_0
|
|
96
|
+
{
|
|
97
|
+
"echo": {
|
|
98
|
+
"data": {
|
|
99
|
+
"hello": "world!",
|
|
100
|
+
"prepared": true
|
|
101
|
+
},
|
|
102
|
+
"args": []
|
|
103
|
+
},
|
|
104
|
+
"enhanced": true
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
As you can observe from the output, `nextpipe` automatically generates a
|
|
109
|
+
Mermaid diagram to visualize the flow structure.
|
|
110
|
+
|
|
111
|
+
```mermaid
|
|
112
|
+
graph LR
|
|
113
|
+
prepare(prepare)
|
|
114
|
+
prepare --> solve
|
|
115
|
+
solve(solve)
|
|
116
|
+
solve --> enhance
|
|
117
|
+
enhance(enhance)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The diagram can be viewed in a browser by following the [link][mermaid-link]
|
|
121
|
+
provided in the output. The diagram shows the flow of data between the steps.
|
|
122
|
+
|
|
123
|
+
[mermaid-link]: https://mermaid.ink/svg/Z3JhcGggTFIKICBwcmVwYXJlKHByZXBhcmUpCiAgcHJlcGFyZSAtLT4gc29sdmUKICBzb2x2ZShzb2x2ZSkKICBzb2x2ZSAtLT4gZW5oYW5jZQogIGVuaGFuY2UoZW5oYW5jZSkK?theme=dark
|