Run App Locally

Run an app locally

A tutorial for running an app locally with Nextmv Platform.

A run is a single execution of an app. It is the basic functionality encompassed of receiving an input, running the app, and returning an output. This tutorial will walk you through running an app locally on your machine.

  • Custom apps: given you control the code, you can test it locally before deploying it to Nextmv Cloud.
  • Subscription apps: test a subscription app locally by using the community app it is based on. This is a good way to get started in the path to customization.

The following languages are supported:

  • Go: using the Nextmv Go SDK.
  • Java: using native Java.
  • Python: using native Python.

Go

Use a Go installation.

Here is an example of running the nextroute community app. Learn more about vehicle routing here.

go run . -runner.input.path input.json -runner.output.path output.json -solve.duration 10s
Copy

Java

Use a Java installation.

Run the following command to generate a main.jar in the root directory of the project.

mvn package
Copy

For example, to run the knapsack community app, execute the main.jar file with the following command:

java -jar main.jar --input input.json --output output.json --duration 30
Copy

Python

Use a Python installation. We suggest you use a virtual environment (venv) as well.

Make sure that the requirements.txt are installed in that local venv.

pip3 install -r requirements.txt
Copy

Here are some examples of how to run an app locally, from the app's root.

  • ortools. Learn more about mixed integer programming here.
python3 main.py -input input.json -output output.json -duration 30
Copy
  • pyomo. Learn more about mixed integer programming here.
python3 main.py -input input.json -output output.json -duration 30 -provider cbc
Copy

Running in a docker container

You can also run the app in a docker container. This is useful for testing because we can ensure that the app runs in the same environment as it would on our platform.

If you clone the knapsack community app, you will find that it has a .devcontainer folder with a .devcontainer file in it. If you use Visual Studio Code, and you have the Dev Containers extension and Docker installed, you can open the project in a docker container. We have prepared the Dev Container so that it mirrors the environment that the app will run in on the platform.

Alternatively, you can run the app in a docker container without using Visual Studio Code. Here is an example of how to run the knapsack community app in a docker container:

cat input.json | docker run -i --rm \
-v $(pwd):/app ghcr.io/nextmv-io/runtime/ortools:latest \
python3 /app/main.py
Copy

Page last updated

Go to on-page nav menu