Skip to content

Commit

Permalink
Adapt Hexaly app to use Python SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-quintero committed Sep 25, 2024
1 parent 2485878 commit e482ca0
Show file tree
Hide file tree
Showing 26 changed files with 175 additions and 276 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ ampl_license_uuid*
!ampl_license_uuid.template

# Gurobi Secrets
# Secrets
gurobi.lic*
!gurobi.lic.template

# Hexaly Secrets
license.dat*
!license.dat.template
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .nextmv/readme/python-pyvroom-routing/2.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cat input.json | docker run -i --rm \
-v $(pwd):/app ghcr.io/nextmv-io/runtime/pyomo:latest \
-v $(pwd):/app ghcr.io/nextmv-io/runtime/python:latest \
sh -c 'python3 /app/main.py'
6 changes: 6 additions & 0 deletions .nextmv/workflow-configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ apps:
marketplace_app_id:
marketplace_major_version:
description: Get started with Python and Nextmv.
- name: python-hexaly-knapsack
type: python
app_id:
marketplace_app_id:
marketplace_major_version:
description: Use Python and Hexaly - knapsack.
- name: python-highs-knapsack
type: python
app_id: knapsack-highs
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ run on Nextmv Cloud.
problem. Demonstrates how to use devcontainers.
* [java-ortools-routing]: Use Java and Google OR-Tools to solve a vehicle
routing problem. Demonstrates how to use devcontainers.
* [python-hexaly-knapsack]: Use Python and Hexaly to solve a knapsack problem.
Demonstrates how to use devcontainers.
* [python-ampl-facilitylocation]: Use Python and AMPL to solve a facility
location problem. Demonstrates how to use devcontainers.
* [python-ampl-priceoptimization]: Use Python and AMPL to solve a price
Expand Down Expand Up @@ -95,6 +97,7 @@ run on Nextmv Cloud.
[python-ampl-knapsack]: ./python-ampl-knapsack/README.md
[python-ampl-priceoptimization]: ./python-ampl-priceoptimization/README.md
[python-gurobi-knapsack]: ./python-gurobi-knapsack/README.md
[python-hexaly-knapsack]: ./python-hexaly-knapsack/README.md
[python-highs-knapsack]: ./python-highs-knapsack/README.md
[python-ortools-costflow]: ./python-ortools-costflow/README.md
[python-ortools-demandforecasting]: ./python-ortools-demandforecasting/README.md
Expand Down
3 changes: 0 additions & 3 deletions knapsack-hexaly/.gitignore

This file was deleted.

71 changes: 0 additions & 71 deletions knapsack-hexaly/README.md

This file was deleted.

1 change: 0 additions & 1 deletion knapsack-hexaly/VERSION

This file was deleted.

29 changes: 0 additions & 29 deletions knapsack-hexaly/knapsack-hexaly.code-workspace

This file was deleted.

152 changes: 0 additions & 152 deletions knapsack-hexaly/main.py

This file was deleted.

1 change: 0 additions & 1 deletion python-ampl-knapsack/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ ampl-module-scip==20240121
ampl-module-xpress==20240115

nextmv==0.12.0

1 change: 0 additions & 1 deletion python-ampl-priceoptimization/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ ampl-module-scip==20240121
ampl-module-xpress==20240115

nextmv==0.12.0

1 change: 0 additions & 1 deletion python-gurobi-knapsack/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
gurobipy==11.0.0
nextmv==0.12.0

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"python.defaultInterpreterPath": "python"
}
}
}
},
"postCreateCommand": "pip install -r requirements.txt"
}
File renamed without changes.
48 changes: 48 additions & 0 deletions python-hexaly-knapsack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Nextmv Python Hexaly Knapsack

Example for running a Python application on the Nextmv Platform using the
Hexaly solver. We solve a knapsack Mixed Integer Programming problem.

If you have a Hexaly license, remove the `.template` extension from the
`license.dat.template` file and replace the contents with your actual license
key. Modify the `app.yaml` file to include the `license.dat` in the files list.

1. Install packages.

```bash
pip3 install -r requirements.txt
```

1. Run the app.

```bash
python3 main.py -input input.json -output output.json -duration 30
```

## Mirror running on Nextmv Cloud locally

Docker needs to be installed.

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

```bash
cat input.json | docker run -i --rm \
-v $(pwd):/app ghcr.io/nextmv-io/runtime/hexaly:latest \
sh -c 'python3 /app/main.py'
```

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 modify the model.
* Visit our [docs][docs] and [blog][blog]. Need more assistance?
[Contact][contact] us!

[docs]: https://docs.nextmv.io
[blog]: https://www.nextmv.io/blog
[contact]: https://www.nextmv.io/contact
12 changes: 7 additions & 5 deletions knapsack-hexaly/app.yaml → python-hexaly-knapsack/app.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# This manifest holds the information the app needs to run on the Nextmv Cloud.
type: python
runtime: ghcr.io/nextmv-io/runtime/hexaly:latest
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
- license.dat # Store your license information in this file.
python:
# Packages the app depends on need to be listed in a requirements.txt file
# that is referenced here. All listed packages will get bundled with the app.
pip-requirements: requirements.txt
# If you have a Hexaly license, uncomment the following line and make sure to
# store your license information in that file.
- license.dat
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit e482ca0

Please sign in to comment.