Custom App

Get started with bringing your own model to Nextmv

A brief introduction to using Nextmv with your own model.

This section details how to bring your decision model onto the Nextmv Platform using any of our solver integrations or custom logic.

  1. Install a Nextmv client.
  2. Nextmvify your model.
  3. Push your model to Nextmv cloud.
  4. Make a remote run.

Note: An active subscription with Nextmv is required to complete these steps. Sign up for an account or contact support@nextmv.io to request access.

Install Nextmv development tooling

Python developers can pip install nextmv to gain access to the Nextmv Python SDK containing helpful constructs for common patterns in decision models. Additionally, the Python SDK can be used to push your custom model up to the Nextmv cloud.

For non-Python developers, you can install the Nextmv CLI.

Nextmvify your model

Now, you're ready to Nextmvify your model to run on Nextmv as an app.

Input

Read model inputs from a file or stdin as JSON, TEXT, or CSV.

If reading from a file or files (required for CSV), your input data must be nested in and read from a folder called input in your model code.

For Python users, you may use the load_local function from the Nextmv Python SDK. If you are loading multiple CSVs from the input folder, your code might look like this:

input = nextmv.load_local(
    input_format=nextmv.InputFormat.CSV_ARCHIVE,
    options=options,
    path=options.input,
)
Copy

Note, you may choose to expose configuration of your model via CLI flags. For Python users, you may optionally use the Options and Parameter functions from the Nextmv Python SDK, and your code might look like this:

options = nextmv.Options(
    nextmv.Parameter("input", str, "", "Path to input folder.", False),
    nextmv.Parameter("output", str, "", "Path to output folder.", False),
    nextmv.Parameter("duration", int, 30, "Max runtime duration (in seconds).", False),
    nextmv.Parameter("provider", str, "SCIP", "Solver provider.", False),
)
Copy

load_local then receives these custom options.

If you are reading your input from stdin instead, you may also use load_local without specifying any arguments.

input = nextmv.load_local()
Copy

Statistics

Add statistics to your model and write them to stdout to conduct experiments and view run results in the UI.

Statistics must conform to the Nextmv statistics convention.

For Python users, you may optionally use the Output function from the Nextmv Python SDK and your code might look like this:

output = nextmv.Output(
    solution=None,
    statistics=nextmv.Statistics(
        result=nextmv.ResultStatistics(
            value=1.23,
            custom={"message": message},
        ),
    ),
)
Copy

Logs

Write logs to stderr to surface logs in the logs tab for each run.

For Python users, you may optionally use the log function from the Nextmv Python SDK and your code might look like this:

message = f"Hello, {name}"
nextmv.log(message)
Copy

Output

Write your model solution to a file or stdout as JSON, TEXT, or CSV. If reading from a file or files (required for CSV), your output data must be written to a folder called output in your model code. This ensures we can find your output and render it appropriately on the Nextmv Console.

For Python users, you may optionally use the write_local function to write an Output from the Nextmv Python SDK, and your code might look like this:

nextmv.write_local(output, path=options.output)
Copy

Where options.output is optional (required only for models with CSV input regardless of output type).

Manifest

Add an app manifest at the root of your project which will tell the Nextmv platform what runtime and requirements are needed to execute your custom model. For Python users, your app manifest might look like this:

# This manifest holds the information the app needs to run on the Nextmv Cloud.
type: python
runtime: ghcr.io/nextmv-io/runtime/python:3.11
python:
  # All listed packages will get bundled with the app.
  pip-requirements: requirements.txt

# List all files/directories that should be included in the app. Globbing
# (e.g.: configs/*.json) is supported.
files:
  - main.py
Copy

Make your model an app

Now that your model is Nextmvified, you can push your model to your Nextmv account as an app.

Run your app

Now, you can visit the Nextmv Console. Click into your apps icon on the left, and select your app. From your appโ€™s main details view, click the Run app button. This will load an empty user interface for adding the input and configuration for your run.

Screenshot showing UI for model input and other configuration options with a
space on the right for visualizing the model input

Paste in your input if JSON or upload a file for non-JSON inputs. Modify configuration if you exposed any configuration in your model.

Next, click the Start run button to run your app. This will load a new screen where you can view the details of your app run. Your run status will start with either queued or running and will move to successful once it has completed.

Screen showing the details of the newly created run listed in rows of text
with a queued or running status

Once the status reaches succeeded click on the Result tab to view the result of your run. You should either see your solution output or a button to download the output.

Next steps

๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰ You completed this brief introduction to using custom apps on the Nextmv Decision Platform. Here are some next steps:

  1. See the solvers that are supported.
  2. Begin exploring scenario tests and other experiments

Page last updated

Go to on-page nav menu