Skip to content
This repository was archived by the owner on Sep 6, 2024. It is now read-only.

Latest commit

 

History

History
58 lines (41 loc) · 2.03 KB

File metadata and controls

58 lines (41 loc) · 2.03 KB

Nextmv Python template

This template helps you writing your own optimization model in Python. It contains several files to easily deploy the model to the Nextmv platform.

The most important files created are main.py and input.json.

  • main.py is the starting point for the model.
  • input.json is a sample input file.

Follow these steps to run locally.

  1. The packages listed in the requirements.txt will get bundled with the app as defined in the app.yaml manifest. When working locally, make sure that these are installed as well:

    pip3 install -r requirements.txt
  2. Run the command below to check that everything works as expected:

    python3 main.py -input input.json -output output.json -recipient nextmv
  3. A file output.json should have been created a greeting message.

Mirror running on Nextmv Cloud locally

Pre-requisites: Docker needs to be installed.

To run the application locally in the same docker image as the one used on the Nextmv Cloud, you can use the following command:

cat input.json | docker run -i --rm \
-v $(pwd):/app ghcr.io/nextmv-io/runtime/python:3.11 \
sh -c 'pip install -r requirements.txt &> /dev/null && python3 /app/main.py'

Note that this command installs the dependencies from the requirements.txt file on the fly. If you want to avoid this, you can build a custom image with the dependencies already installed.

You can also debug the application by running it in a Dev Container. This workspace recommends to install the Dev Container extension for VSCode. If you have the extension installed, you can open the workspace in a container by using the command Dev Containers: Reopen in Container.

Next steps

  • Open main.py and start writing the model in python.
  • Further documentation, guides, and API references about custom modeling and deployment can also be found on our blog and on our documentation site.
  • Need more assistance? Send us an email!