A Flask-based API for offshore wind farm installation planning and simulation.
Key Features:
- Flask-RESTx API with auto-generated Swagger documentation
- Petri Net simulation for installation scheduling (via gspn4py)
- Process Mining utilities for event log analysis
- Docker containerization for deployment
- Tox/pytest for testing
- Setup & Installation
- Running Locally
- API Overview
- API Architecture (Important)
- Deployment with Docker
- Testing
# 1) Clone the repo
git clone https://github.com/Peng-LUH/l3s-offshore-2
cd l3s_offshore_2
# 2) Create & Activate Virtual Environment (optional, recommended)
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
# 3) Install dependencies in editable mode
pip install -e .If you also want the development/testing tools (black, flake8, etc.):
pip install -e .[dev]We rely on a small run.py that uses the create_app factory from src/l3s_offshore_2/__init__.py.
Make sure FLASK_APP=run.py and FLASK_DEBUG=true are set in your environment (or .env file). Then:
flask run --host=0.0.0.0 --port=9040Navigate to:
- Swagger UI: http://localhost:9040/l3s-offshore-2/
- OpenAPI Spec (JSON): http://localhost:9040/l3s-offshore-2/swagger.json
The API provides four namespaces:
| Namespace | Path | Description |
|---|---|---|
| Offshore Plan | /offshore-plan/* |
Simulation and scheduling (production) |
| Simulation | /simulation-petri-nets/* |
Generic Petri net simulation |
| Process Mining | /process-mining/* |
Event log analysis utilities |
| DTO | /dto/* |
Parameter defaults and examples |
Offshore Planning (Simulation):
POST /offshore-plan/calc-opt-install-cycle-single-vessel– Run single installation cycle simulationPOST /offshore-plan/calc-opt-schedule-single-vessel-to-horizon– Run simulation to planning horizonPOST /offshore-plan/display-single-vessel-schedule– Generate schedule PDFGET /offshore-plan/get-tpn-cyclic-model– Get Petri net model definition
Parameter Defaults:
GET /dto/planning/defaults– Get default parameters (for Frontend display)GET /dto/example/scenario– Get example scenario configuration
All endpoints are documented via Swagger UI at runtime.
⚠️ Important: This project contains two API services with incompatible parameter formats.
| Service | Path | Format | Purpose |
|---|---|---|---|
dto_srv |
/dto/* |
Nested, modern | Frontend defaults display |
offshore_plan_srv |
/offshore-plan/* |
Flat, MATLAB-style | Actual simulation |
| Use Case | Endpoint |
|---|---|
| Get parameter defaults (Frontend) | GET /dto/planning/defaults |
| Run actual simulation | POST /offshore-plan/calc-opt-* |
| Generate schedule PDF | POST /offshore-plan/display-single-vessel-schedule |
- Format Incompatibility:
dto_srvuses nested JSON,offshore_plan_srvuses flat JSON - No simulation in dto_srv: The
POST /dto/planningendpoint returns mock data only - No defaults in offshore_plan_srv: No
/defaultsendpoint available
For detailed documentation, see: src/l3s_offshore_2/api/API_ARCHITECTURE.md
We’ve included a Dockerfile that sets up a Python 3.9 environment, installs dependencies, and launches the Flask app:
docker build -t l3s_offshore_2 .
docker run -p 9040:9040 l3s_offshore_2After the container starts, you can hit [host machine IP]:9040/l3s-offshore-2 to see your API.
We use pytest for tests and tox for environment isolation. Make sure you have installed dev dependencies:
pip install -e .[dev]
toxThis runs lint checks (flake8) and any unit tests you create. See pytest.ini for configuration.