Skip to content

Commit 6d3187b

Browse files
HevagogdJaniga
andauthored
Threading orchestration (#66)
Co-authored-by: Damian Janiga <[email protected]>
1 parent f7c7fb5 commit 6d3187b

37 files changed

+2454
-762
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ If your PR includes UI changes or modifications to the command-line interface (C
4646

4747
Ensure that all the following tasks are completed before submitting your PR:
4848

49-
- [ ] Code is formatted and has been linted using 'makefile' run-check option
49+
- [ ] Code is formatted and has been linted using `just run-check`
5050
- [ ] New and existing tests pass locally.
5151
- [ ] All relevant documentation has been updated (e.g., docstrings, README, etc.).
5252
- [ ] Dependencies have been updated in `pyproject.toml`, and `uv.lock` has been regenerated accordingly.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,6 @@ TSWLatexianTemp*
452452

453453
# csv log
454454
log/*.csv
455+
456+
# orchestration files
457+
orchestration_files/

Makefile

Lines changed: 0 additions & 116 deletions
This file was deleted.

README.md

Lines changed: 78 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<p align="center">
32
<img src="https://github.com/user-attachments/assets/d25f9fd7-7610-4725-9a8e-bead501ce568" width="250">
43
</p>
@@ -37,8 +36,8 @@ This Python-based toolbox is designed to optimize geothermal reservoir developme
3736
## Development Requirements
3837

3938
- **Operating System**: Ubuntu 22.04 (recommended)
40-
- **Python Version**: 3.12 (configured in the Makefile)
41-
- **Make and common Unix tools**: git, curl
39+
- **Python Version**: 3.12 (managed via uv; configured in `pyproject.toml` and `justfile`)
40+
- **Just and common Unix tools**: git, curl
4241

4342
---
4443

@@ -50,34 +49,46 @@ You can install either a **development environment** (recommended for developers
5049

5150
> **Note:** Currently, Windows OS is not supported for this setup.
5251
53-
#### Development Environment:
52+
#### Development Environment
53+
54+
Installs the tools needed for development (Python via uv, dev dependencies, pre-commit, LaTeX, optional Docker):
5455

55-
This installs all the necessary tools, including development dependencies, pre-commit hooks, Docker, LaTeX, and Python/uv environments:
56+
- Full dev (includes Docker):
5657

5758
```shell
58-
make install-dev
59+
just install-dev
5960
```
6061

61-
This command will specifically:
62+
- Dev without Docker (threaded runner only):
63+
64+
```shell
65+
just install-dev-thread
66+
```
67+
68+
The full dev setup will:
69+
70+
- Install Python 3.12 and create a virtual environment with `uv`.
71+
- Install LaTeX and TeXstudio for docs.
72+
- Install Docker and verify it.
73+
- Install all Python dev dependencies and pre-commit hooks.
6274

63-
- Install Python 3.12 and set up a virtual environment using `uv`.
64-
- Install LaTeX and TeXstudio for documentation purposes.
65-
- Install Docker, verifying its functionality.
66-
- Install all Python development dependencies and pre-commit hooks.
75+
#### Release Environment
6776

68-
#### Release Environment:
77+
Choose based on your runner mode:
6978

70-
Installs only the dependencies necessary to run the application in a production setting. Run:
79+
- Docker runner:
7180

7281
```shell
73-
make install-release
82+
just install-docker-release
7483
```
7584

76-
This command will specifically:
85+
- Threaded runner (without Docker):
7786

78-
- Install Python 3.12 and set up a virtual environment using `uv`.
79-
- Install Docker, verifying its functionality.
80-
- Install all Python development dependencies and pre-commit hooks.
87+
```shell
88+
just install-thread-release
89+
```
90+
91+
Both variants install Python 3.12 runtime deps via `uv`; the Docker option also installs and verifies Docker. Pre-commit hooks are set up by the recipes.
8192

8293
---
8394

@@ -86,13 +97,13 @@ This command will specifically:
8697
To edit the project documentation using TeXstudio, execute:
8798

8899
```shell
89-
make edit-docs
100+
just edit-docs
90101
```
91102

92103
- This will open the documentation in TeXstudio if installed.
93104
- If TeXstudio is not detected, please install it along with LaTeX by running:
94105
```shell
95-
make install-latex
106+
just install-latex
96107
```
97108

98109
---
@@ -102,7 +113,7 @@ make install-latex
102113
Maintain codebase quality by executing pre-commit hooks, which will run set of the tools including pytest and coverage:
103114

104115
```shell
105-
make run-check
116+
just run-check
106117
```
107118
---
108119

@@ -111,7 +122,29 @@ make run-check
111122
### 1. Supported Reservoir Simulators:
112123
- OpenDarts (1.1.3) [open_darts-1.1.3-cp310-cp310-linux_x86_64] (default)
113124

114-
### 2. Reservoir simulation interoperability
125+
### 2. Execution modes
126+
127+
The toolbox supports two execution modes for running simulations:
128+
129+
- Threaded runner (default): local execution without containers.
130+
- Docker runner: containerized workers.
131+
132+
Pick a runner using either the CLI flag `--use-docker` or the convenience `just` recipes:
133+
134+
- Threaded:
135+
136+
```shell
137+
just run-thread <config_filepath> <model_filepath>
138+
```
139+
140+
- Docker:
141+
142+
```shell
143+
just run-docker <config_filepath> <model_filepath>
144+
```
145+
146+
147+
### 3. Reservoir simulation interoperability
115148
Interoperability between reservoir simulator and toolbox is established by the proper `Connector` [src/services/simulation_service/core/connectors].
116149
Connector allows exchange information (simulation configuration and simulation results) between toolbox and simulator.
117150

@@ -195,7 +228,7 @@ Connector allows exchange information (simulation configuration and simulation r
195228
6. Simulation model implementation is read to run an optimization process using RiskManagementToolbox.
196229
7. All simulation model files must be archived in `.zip` format. User should ensure that after unpacking all simulation model files are accessible in folder without any additional subfolders.
197230

198-
### 3. Toolbox configuration file
231+
### 4. Toolbox configuration file
199232
RiskManagementToolbox is designed to use JSON configuration file, where the user defines the optimization problem(s),
200233
initial state, and variable constraints.
201234

@@ -305,7 +338,7 @@ Recently the following optimization problem(s) are supported:
305338

306339
If the user does not define the optimization strategy, the default value is `maximize`.
307340

308-
#### 3.1. Optimization parameters: linear inequalities
341+
#### 4.1. Optimization parameters: linear inequalities
309342

310343
You can optionally express additional relationships between variables using sparse linear (in)equalities.
311344

@@ -398,7 +431,7 @@ During validation the upper bound is automatically reduced if it exceeds a physi
398431
}
399432
```
400433

401-
#### 3.2. Example of the configuration file
434+
#### 4.2. Example of the configuration file
402435

403436
Well placement problem for two wells with maximization optimization strategy:
404437
```json
@@ -468,25 +501,32 @@ Well placement problem for two wells with maximization optimization strategy:
468501

469502
---
470503

471-
### 4. Toolbox running
504+
### 5. Running the toolbox
472505

473-
To run the RiskManagementToolbox the virtual environment corresponded with the repository must be
474-
activated
506+
Required arguments:
507+
1. `--config-file` path to JSON config
508+
2. `--model-file` path to zipped model archive
475509

476-
```URGENT_RiskManagementToolbox$ source .venv/bin/activate```
510+
Optional:
511+
- `--population-size` (default 10)
512+
- `--patience` (default 10)
513+
- `--max-generations` (default 10)
514+
- `--use-docker` to run via the Docker-based cluster
477515

478-
User must set:
479-
1. path to config file (--config-file)
480-
2. path to model archive(--model-file)
516+
CLI usage:
517+
518+
```
519+
uv run src/main.py \
520+
--config-file <config_filepath> \
521+
--model-file <model_filepath> \
522+
[--population-size 10] [--patience 10] [--max-generations 10] [--use-docker]
523+
```
481524

482-
optionally:
483-
1. population size (--population-size)
484-
2. iteration count without progress (--patience)
485-
3. max generations count (-max-generations)
525+
Equivalent with `just`:
486526

487527
```
488-
uv run src/main.py
489-
usage: main.py [-h] --config-file CONFIG_FILE --model-file MODEL_FILE [--population-size POPULATION_SIZE] [--patience PATIENCE] [--max-generations MAX_GENERATIONS]
528+
just run-thread <config_filepath> <model_filepath>
529+
just run-docker <config_filepath> <model_filepath>
490530
```
491531

492532
## Contact

0 commit comments

Comments
 (0)