Skip to content

Commit 9e1925b

Browse files
KristijanFaust-OETpre-commit-ci[bot]FabianHofmann
authored
Oetc support (#50)
* Add oetc configuration support Co-authored-by: Fabian Hofmann <fab.hof@gmx.de> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Fabian Hofmann <fab.hof@gmx.de>
1 parent 8e454f5 commit 9e1925b

8 files changed

Lines changed: 119 additions & 4 deletions

File tree

doc/configtables/solving.csv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,12 @@ solver,,,
4141
-- name,--,"One of {'gurobi', 'cplex', 'highs', 'cbc', 'glpk'}; potentially more possible",Solver to use for optimisation problems in the workflow; e.g. clustering and linear optimal power flow.
4242
-- options,--,Key listed under ``solver_options``.,Link to specific parameter settings.
4343
solver_options,,dict,Dictionaries with solver-specific parameter settings.
44+
oetc,,,Configuration options for Open Energy Transition Computing (OETC) cluster support.
45+
-- name,--,str,Name identifier for the OETC job.
46+
-- authentication_server_url,--,str,URL of the OETC authentication server for job submission.
47+
-- orchestrator_server_url,--,str,URL of the OETC orchestrator server for job management.
48+
-- cpu_cores,--,int,Number of CPU cores to request for the OETC job. (includes RAM amount at the moment with a factor of 8)
49+
-- disk_space_gb,GB,int,Amount of disk space in gigabytes to request for the OETC job.
50+
-- delete_worker_on_error,bool,"{'true','false'}",Whether to delete the worker instance when an error occurs during job execution.
4451
mem,MB,int,Estimated maximum memory requirement for solving networks.
4552
mem_logging_frequency,s,int,Interval in seconds at which memory usage is logged.

doc/oetc.rst

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
..
2+
SPDX-FileCopyrightText: Contributors to PyPSA-Eur <https://github.com/pypsa/pypsa-eur>
3+
4+
SPDX-License-Identifier: CC-BY-4.0
5+
6+
##########################################
7+
OETC Integration
8+
##########################################
9+
10+
The OETC platform allows PyPSA-Eur to leverage cloud-based resources for
11+
solving energy system models. This integration enables solving of optimization problems
12+
using remote compute resources when local computational capacity is insufficient.
13+
14+
.. _oetc_overview:
15+
16+
Overview
17+
========
18+
19+
OETC provides a cloud-based optimization service that can handle PyPSA networks by:
20+
21+
- Offloading optimization tasks to remote compute resources
22+
- Supporting various solvers (Highs, Gurobi, etc.) on cloud infrastructure
23+
- Automatically managing authentication and resource allocation
24+
- Providing configurable compute resources (CPU cores, disk space)
25+
26+
The integration is implemented through the ``linopy.oetc`` module and is configured
27+
within the PyPSA-Eur solving configuration.
28+
29+
.. _oetc_setup:
30+
31+
Setup and Authentication
32+
========================
33+
34+
To use OETC with PyPSA-Eur, you need to:
35+
36+
1. **Set up environment variables** for authentication based on your OETC credentials:
37+
38+
.. code:: bash
39+
40+
export OETC_EMAIL="your-email@example.com"
41+
export OETC_PASSWORD="your-password"
42+
43+
2. **Configure OETC settings** in your configuration file (see :ref:`oetc_config`).
44+
45+
.. _oetc_config:
46+
47+
Configuration
48+
=============
49+
50+
OETC integration is configured within the ``solving`` section of your configuration file.
51+
Add an ``oetc`` subsection to enable cloud-based optimization:
52+
53+
.. code:: yaml
54+
55+
solving:
56+
# ... other solving options ...
57+
oetc:
58+
name: "job-name" # Arbitrary human readable job identifier
59+
authentication_server_url: "https://auth.oetc.example.com"
60+
orchestrator_server_url: "https://orchestrator.oetc.example.com"
61+
compute_provider: "GCP" # Currently only GCP is supported
62+
cpu_cores: 4 # This also sets the amount of RAM by a factor 8
63+
disk_space_gb: 20
64+
65+
.. note::
66+
67+
The ``solver`` and ``solver_options`` are automatically passed from the main
68+
solving configuration and do not need to be specified in the OETC section.
69+
70+
.. _oetc_usage:
71+
72+
Usage
73+
=====
74+
75+
Once configured, OETC integration works transparently with the standard PyPSA-Eur
76+
workflow. If a oetc configuration is present, PyPSA-Eur will automatically use
77+
the OETC platform for the model optimization during the solve network rule.
78+
79+
An example of a log entry when using OETC:
80+
.. code::
81+
INFO:linopy.oetc:OETC - Signing in...
82+
INFO:linopy.oetc:OETC - Signed in
83+
INFO:linopy.oetc:OETC - Fetching user GCP credentials...
84+
INFO:linopy.oetc:OETC - Fetched user GCP credentials
85+
INFO:linopy.oetc:OETC - Submitting compute job...
86+
INFO:linopy.oetc:OETC - Compute job 992616b6-0f24-4ab5-8675-ba8098d795fa started
87+
INFO:linopy.oetc:OETC - Waiting for job 992616b6-0f24-4ab5-8675-ba8098d795fa to complete...
88+
INFO:linopy.oetc:OETC - Job 992616b6-0f24-4ab5-8675-ba8098d795fa status: PENDING, checking again in 30 seconds...
89+
INFO:linopy.oetc:OETC - Job 992616b6-0f24-4ab5-8675-ba8098d795fa status: PENDING, checking again in 45 seconds...
90+
INFO:linopy.oetc:OETC - Job 992616b6-0f24-4ab5-8675-ba8098d795fa completed successfully!
91+
INFO:linopy.oetc:OETC - Model solved successfully. Status: ok
92+
INFO:linopy.oetc:OETC - Objective value: 3.11e+07

doc/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ Upcoming Release
4343

4444
* Updated `build_osm_network` and `clean_osm_data` to handle voltage levels below 220 kV (down to 63 kV). When `base_network` is set to `osm_raw`, an electricity grid from voltage levels AC 63 kV to 750 kV can be created (experimental feature). For an example, see the example configuration in `config/examples/config-distribution-grid-experimental.yaml`.
4545

46+
47+
* Added integration with the OETC platform
48+
4649
* Fix `retrieve_eurostat_data` and `retrieve_eurostat_household_data` on Windows by avoiding a double access to a temporary file.
4750
(https://github.com/PyPSA/pypsa-eur/pull/1825)
4851

52+
4953
PyPSA-Eur v2025.07.0 (11th July 2025)
5054
=====================================
5155

envs/linux-64.lock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ dependencies:
305305
- libxslt=1.1.43=h7a3aeb2_0
306306
- libzip=1.11.2=h6991a6a_0
307307
- libzlib=1.3.1=hb9d3cd8_2
308-
- linopy=0.5.5=pyhd8ed1ab_0
308+
- linopy=0.5.7=pyhd8ed1ab_0
309309
- locket=1.0.0=pyhd8ed1ab_0
310310
- lxml=6.0.1=py312h70dad80_0
311311
- lz4=4.4.4=py312hf0f0c11_0

envs/osx-64.lock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ dependencies:
270270
- libxslt=1.1.43=h59ddae0_0
271271
- libzip=1.11.2=h31df5bb_0
272272
- libzlib=1.3.1=hd23fc13_2
273-
- linopy=0.5.5=pyhd8ed1ab_0
273+
- linopy=0.5.7=pyhd8ed1ab_0
274274
- llvm-openmp=21.1.0=hf4e0ed4_0
275275
- locket=1.0.0=pyhd8ed1ab_0
276276
- lxml=6.0.1=py312ha108ba6_0

envs/osx-arm64.lock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ dependencies:
270270
- libxslt=1.1.43=h429d6fd_0
271271
- libzip=1.11.2=h1336266_0
272272
- libzlib=1.3.1=h8359307_2
273-
- linopy=0.5.5=pyhd8ed1ab_0
273+
- linopy=0.5.7=pyhd8ed1ab_0
274274
- llvm-openmp=21.1.0=hbb9b287_0
275275
- locket=1.0.0=pyhd8ed1ab_0
276276
- lxml=6.0.1=py312h4144cae_0

envs/win-64.lock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ dependencies:
250250
- libxslt=1.1.43=h25c3957_0
251251
- libzip=1.11.2=h3135430_0
252252
- libzlib=1.3.1=h2466b09_2
253-
- linopy=0.5.5=pyhd8ed1ab_0
253+
- linopy=0.5.7=pyhd8ed1ab_0
254254
- llvm-openmp=21.1.0=hfa2b4ca_0
255255
- locket=1.0.0=pyhd8ed1ab_0
256256
- lxml=6.0.1=py312hc85b015_0

scripts/solve_network.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import pypsa
4141
import xarray as xr
4242
import yaml
43+
from linopy.remote.oetc import OetcCredentials, OetcHandler, OetcSettings
4344
from pypsa.descriptors import get_activity_mask
4445
from pypsa.descriptors import get_switchable_as_dense as get_as_dense
4546

@@ -1335,6 +1336,17 @@ def solve_network(
13351336
kwargs["assign_all_duals"] = cf_solving.get("assign_all_duals", False)
13361337
kwargs["io_api"] = cf_solving.get("io_api", None)
13371338

1339+
oetc = solving.get("oetc", None)
1340+
if oetc:
1341+
oetc["credentials"] = OetcCredentials(
1342+
email=os.environ["OETC_EMAIL"], password=os.environ["OETC_PASSWORD"]
1343+
)
1344+
oetc["solver"] = kwargs["solver_name"]
1345+
oetc["solver_options"] = kwargs["solver_options"]
1346+
oetc_settings = OetcSettings(**oetc)
1347+
oetc_handler = OetcHandler(oetc_settings)
1348+
kwargs["remote"] = oetc_handler
1349+
13381350
kwargs["model_kwargs"] = cf_solving.get("model_kwargs", {})
13391351
kwargs["keep_files"] = cf_solving.get("keep_files", False)
13401352

0 commit comments

Comments
 (0)