Prefect flow repo for the NWN optimizer.
This defines the prefect flow function which is the entry function for prefect runs.
There is a prefect_deploy_flow.py script to create/update a
prefect deployment which can be used for runs.
This project uses:
- uv: Fast Python package manager and resolver. Install via https://docs.astral.sh/uv/
- just: Command runner for common tasks (similar to Make). Install via https://github.com/casey/just
-
Install dependencies:
uv sync
-
Copy .env.template to .env
Note to use local code for sdk run .venv/bin/pip install -e ../omotes-sdk-python/.
In vscode go to the debug view and run run_optimizer_flow_function. This runs the function without prefect.
Run via just (also used in in github actions):
just ci # run all CI checks (lint, security, format-check, typecheck, test)
just lint # ruff checks
just security # ruff security
just format # ruff format
just format-check # verify formatting
just typecheck # ty type checking
just test # pytestTo debug test go to the debug view in vscode and run "pytest".
When using an editable install of the sdk, don't use the just command as uv run ... will remove this editable install.
There are different ways to deploy prefect flow.
- to a local prefect instance using local code
- automatic on github CI
- manual via omotes-system repo: https://github.com/Project-OMOTES/omotes-system
In vscode go to the debug view and run prefect_deploy_flow.
This will create a deployment on prefect (to the prefect instance on PREFECT_API_URL).\
During development you may want to deploy local code of this repo instead of an already published image, then set
PREFECT_USE_LOCAL_CODE_AND_IMAGE=true in .env. To also use local code for the omotes-sdk-python and mesido set
PREFECT_USE_LOCAL_SDK_AND_MESIDO=true as well.
On git tag the prefect flow is deployed to the NWN TEST MapEditor. The deployment to the NWN PROD MapEditor needs confirmation which can be set on clicking the deploy action: https://github.com/Project-OMOTES/optimizer-worker/actions.
Make sure to have the required Tools installed.
Start with creating an issue: https://github.com/Project-OMOTES/optimizer-worker/issues, create a branch of that issue
and pull locally. Then update the mesido version in pyproject.toml and run (on windows run in
Git Bash terminal):
uv lock
uv sync --locked --group dev
just ciThis updates the package versions and installs them locally. And runs all the ci checks locally.
Commit changes (pyproject.toml and uv.lock) and push to github. Optionally create a PR and merge into main.
Next create a new release on https://github.com/Project-OMOTES/optimizer-worker/releases:
- Tag: Select tag: Create new tag
- Select target branch:
mainor dev branch. - Previous tag: Select previous tag, don't leave auto
- Generate release notes
- Optionally select
Pre-release - Publish release
This will publish a new docker image and deploy to NWN MapEditor TEST, approval is needed to deploy to PROD: https://github.com/Project-OMOTES/optimizer-worker/actions.
optimizer-worker/
├── src/
│ └── omotes_optimizer_worker/
│ ├── __init__.py # Package initialization
│ ├── env.py # Environment configuration helpers
│ ├── prefect_deploy_flow.py # Registers/updates Prefect deployment
│ ├── prefect_flow.py # Main Prefect flow implementation
│ └── worker_types.py # Workflow/solver mapping utilities
├── tests/
│ ├── test_prefect_deploy_flow.py # Tests for deploy flow module behavior
│ ├── test_prefect_flow.py # Tests for optimizer flow behavior
│ ├── data/
│ │ └── esdl/
│ │ ├── Delft_T.esdl # Successful optimizer flow input
│ │ └── Delft_T_feedback.esdl # Feedback/error flow input
│ └── test_worker_types.py # Tests for worker type mapping logic
├── local_run/
│ └── run_optimizer_flow_function.py # Run flow function locally without Prefect
├── doc/ # Project documentation assets
├── gurobi/
│ └── gurobi.lic # Local Gurobi license file
├── Dockerfile # Runtime image for optimizer worker
├── dev.Dockerfile # Local development image (monorepo/local SDK mode)
├── justfile # Task runner commands (ci, lint, typecheck, test)
├── pyproject.toml # Dependencies and project metadata
└── README.md