Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nextpipe-0.1.2.dev5.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nextpipe-0.1.2.dev5-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file nextpipe-0.1.2.dev5.tar.gz.

File metadata

  • Download URL: nextpipe-0.1.2.dev5.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nextpipe-0.1.2.dev5.tar.gz
Algorithm Hash digest
SHA256 251b632a385d9fbaffdeea308f46f5c7763b1947071d496715419c6af9a6f9e2
MD5 8c1b4a776fcec980ddb02a3026b0de4e
BLAKE2b-256 ac2715f00df163486c7418ae6ec21dc36290e1fe2abf0a55cabff6fe4a7b7982

See more details on using hashes here.

Provenance

The following attestation bundles were made for nextpipe-0.1.2.dev5.tar.gz:

Publisher: release.yml on nextmv-io/nextpipe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nextpipe-0.1.2.dev5-py3-none-any.whl.

File metadata

  • Download URL: nextpipe-0.1.2.dev5-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nextpipe-0.1.2.dev5-py3-none-any.whl
Algorithm Hash digest
SHA256 ed79fa9a53dbcf9d5ab1119cae4e0bcaba6a1617a5a65285182b0174ebc7eb51
MD5 ef6afc7e13ff9cc0b20de18f696971e1
BLAKE2b-256 2c5309278d06d194b4891996f3877eb61c87bc6cf5b0c2ae0a2d2d7cafad7977

See more details on using hashes here.

Provenance

The following attestation bundles were made for nextpipe-0.1.2.dev5-py3-none-any.whl:

Publisher: release.yml on nextmv-io/nextpipe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page