App

Overview

A tutorial for deploying a custom decision model to Nextmv Cloud.

With custom apps, you can customize all parts of the model and therefore completely adapt the service to your unique business needs. You can begin working with custom apps in either of the following two ways:

  • Write your model using one of our language templates which are available for Python, Java and Go.
  • Start with one of our many community apps available (e.g. vehicle routing, scheduling).

App rules and conventions

To create and run your own model on the Nextmv plaform you have to adhere to some rules and conventions.

Custom apps are supported for these languages:

  • Go
  • Python
  • Java

The code of the app can come from a Nextmv template, or it can be your own custom code. If custom, you will need to ensure the following conditions are met:

  1. Must read from either Stdin or a file.
  2. Must write results either to Stdout or a file.
  3. Must conform to the Nextmv statistics convention in order to leverage experiments and tests.
  4. Must contain an app.yaml manifest in the root of your custom app project. Here are some example app.yaml files for different languages. Please read the corresponding section for more details.
type: go
# We use the default runtime as the app gets compiled into a binary
runtime: ghcr.io/nextmv-io/runtime/default:latest
# We build the app for linux and arm64 (the default runtime)
# and call it "main" (the default entrypoint)
build:
  command: go build -o main .
  environment:
    GOOS: linux
    GOARCH: arm64
# We only need to include the resulting binary "main"
files:
  - main
Copy

For a custom app you need to:

  1. Create the app
  2. Deploy (push code to the app)

Write your custom model

You can choose to write your app completely on your own or bring in your exsiting model, it only needs to comply with the rules and conventions mentioned before. If you want to start with a domain specific app, please read more about our community apps. Or create your model based on one of our language specific templates for Python, Java or Go.

nextmv community clone -a python-hello-world
Copy

Create the app

To create a custom app, define the desired app ID and name. After, you can use one of the following interfaces:

  • Console. Go to Console, Apps section. Add a new app from All or Custom tabs. Fill in the fields.

    New app

  • Nextmv CLI. Anywhere on your machine, run the following command:

nextmv app create \
    --app-id $APP_ID \
    --name $APP_ID \
    --description "An optional description"
Copy

Deploy

Deploying an app means pushing code to it. You can use one of the following interfaces:

  • Nextmv CLI. Stand at the root of your project run the following command:
nextmv app push --app-id $APP_ID
Copy
  • Python SDK. Run the following script. By default, it will push the app that is the current directory and attempt to use an app.yaml file therein contained. You can customize this behavior by modifying the arguments given to the push function.
import os

from nextmv import cloud

client = cloud.Client(api_key=os.getenv("NEXTMV_API_KEY"))
app = cloud.Application(client=client, id="<YOUR-APP-ID>")
app.push()  # Use verbose=True for step-by-step output.

Copy

You need to push the app whenever you need to deploy new code to it. The app.yaml manifest contains different configurations that allow you to execute scripts before pushing the app, like compile dependencies or run tests, for example.

๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰ The app is ready to be used.

Delete a custom app

Delete a custom app using the following interfaces:

  • Nextmv CLI. Anywhere on your machine, run the following command:
nextmv app delete \
    --app-id $APP_ID \
    --confirm
Copy
  • Cloud API. Make sure your NEXTMV_API_KEY is exported as an environment variable. The API uses Bearer Authentication.

    DELETEhttps://api.cloud.nextmv.io/v1/applications/{application_id}

    Delete application.

    Delete application, specified by application ID.

curl -sS -L -X DELETE \
    "https://api.cloud.nextmv.io/v1/applications/$APP_ID" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $NEXTMV_API_KEY"
Copy

Page last updated

Go to on-page nav menu