Skip to content

Commit bca579e

Browse files
authored
Merge pull request #79 from BDonnot/bd-dev
Upgrade to version 0.8.1
2 parents d05dede + f657ca2 commit bca579e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2035
-389
lines changed

.circleci/config.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,31 @@ executors:
5555
- image: silkeh/clang:9 # no c++ 11, does not work
5656

5757
jobs:
58+
test_legacy_grid2op:
59+
executor: gcc_13
60+
resource_class: small
61+
steps:
62+
- checkout
63+
- run: apt-get update && apt-get install python3-full python3-dev python3-pip python3-virtualenv git -y
64+
- run: python3 -m virtualenv venv_test
65+
- run:
66+
name: "Set up virtual environment"
67+
command: |
68+
source venv_test/bin/activate
69+
pip install --upgrade pip setuptools wheel gym "numpy<1.22" grid2op==1.6.4
70+
pip install -U pybind11
71+
git submodule init
72+
git submodule update
73+
make
74+
CC=gcc python setup.py build
75+
python -m pip install -U .
76+
pip freeze
77+
- run:
78+
name: legacy test
79+
command: |
80+
source venv_test/bin/activate
81+
python -m unittest lightsim2grid/tests/test_compat_legacy_grid2op.py
82+
5883
compile_gcc12:
5984
executor: gcc_12
6085
resource_class: small

.github/workflows/main.yml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
steps:
5151

5252
- name: Checkout sources
53-
uses: actions/checkout@v3
53+
uses: actions/checkout@v3 # v4 not working...
5454
with:
5555
submodules: true
5656

@@ -76,16 +76,22 @@ jobs:
7676
run: python setup.py sdist
7777

7878
- name: Install wheel
79-
run: pip3 install wheelhouse/*.whl --user
79+
run: |
80+
pip3 install wheelhouse/*.whl --user
81+
pip freeze
8082
8183
# - name: Install GDB
8284
# run: yum install -y gdb
8385

84-
- name: Check package can be imported
86+
- name: Check package can be imported (bare install)
8587
run: |
8688
python3 -c "import lightsim2grid"
8789
python3 -c "from lightsim2grid import *"
8890
python3 -c "from lightsim2grid.newtonpf import newtonpf"
91+
python3 -c "from lightsim2grid.timeSerie import TimeSeriesCPP"
92+
python3 -c "from lightsim2grid.contingencyAnalysis import ContingencyAnalysisCPP"
93+
python3 -c "from lightsim2grid.securityAnalysis import SecurityAnalysisCPP"
94+
python3 -c "from lightsim2grid.gridmodel import init, GridModel"
8995
9096
- name: Fix urllib3 (python 3.7)
9197
if: matrix.python.name == 'cp37'
@@ -98,22 +104,26 @@ jobs:
98104
python3 -m pip install grid2op
99105
python3 -m pip freeze
100106
101-
- name: Check LightSimBackend can be imported 1
107+
- name: Check extra can be imported can be imported (with grid2op)
102108
run:
103109
python3 -v -c "from lightsim2grid import LightSimBackend"
104-
105-
- name: Check LightSimBackend can be imported 2
110+
python3 -c "from lightsim2grid.timeSerie import TimeSerie"
111+
python3 -c "from lightsim2grid.contingencyAnalysis import ContingencyAnalysis"
112+
python3 -c "from lightsim2grid.physical_law_checker import PhysicalLawChecker"
113+
python3 -c "from lightsim2grid.securityAnalysis import SecurityAnalysis"
114+
115+
- name: Check LightSimBackend can be used to create env
106116
run:
107117
python3 -v -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"
108118

109119
- name: Upload wheel
110-
uses: actions/upload-artifact@v3
120+
uses: actions/upload-artifact@v3 # v4 broken
111121
with:
112122
name: lightsim2grid-wheel-linux-${{ matrix.python.name }}
113123
path: wheelhouse/*.whl
114124

115125
- name: Upload source archive
116-
uses: actions/upload-artifact@v3
126+
uses: actions/upload-artifact@v3 # v4 broken
117127
if: matrix.python.name == 'cp311'
118128
with:
119129
name: lightsim2grid-sources
@@ -157,12 +167,12 @@ jobs:
157167
steps:
158168

159169
- name: Checkout sources
160-
uses: actions/checkout@v3
170+
uses: actions/checkout@v4
161171
with:
162172
submodules: true
163173

164174
- name: Setup Python
165-
uses: actions/setup-python@v4
175+
uses: actions/setup-python@v5
166176
with:
167177
python-version: ${{ matrix.python.version }}
168178

@@ -210,7 +220,7 @@ jobs:
210220
python -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"
211221
212222
- name: Upload wheel
213-
uses: actions/upload-artifact@v3
223+
uses: actions/upload-artifact@v4
214224
with:
215225
name: lightsim2grid-wheel-${{ matrix.config.name }}-${{ matrix.python.name }}
216226
path: dist/*.whl
@@ -228,12 +238,12 @@ jobs:
228238
}
229239
steps:
230240
- name: Checkout sources
231-
uses: actions/checkout@v3
241+
uses: actions/checkout@v4
232242
with:
233243
submodules: true
234244

235245
- name: Setup Python
236-
uses: actions/setup-python@v4
246+
uses: actions/setup-python@v5
237247
with:
238248
python-version: ${{ matrix.python.version }}
239249

@@ -272,7 +282,7 @@ jobs:
272282
python -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"
273283
274284
- name: Upload wheel
275-
uses: actions/upload-artifact@v3
285+
uses: actions/upload-artifact@v4
276286
with:
277287
name: lightsim2grid-wheel-darwin-${{ matrix.python.name }}
278288
path: dist/*.whl
@@ -311,12 +321,12 @@ jobs:
311321
steps:
312322

313323
- name: Checkout sources
314-
uses: actions/checkout@v3
324+
uses: actions/checkout@v4
315325
with:
316326
submodules: true
317327

318328
- name: Setup Python
319-
uses: actions/setup-python@v4
329+
uses: actions/setup-python@v5
320330
with:
321331
python-version: ${{ matrix.python.version }}
322332

@@ -346,7 +356,7 @@ jobs:
346356
python -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"
347357
348358
- name: Upload wheel
349-
uses: actions/upload-artifact@v3
359+
uses: actions/upload-artifact@v4
350360
with:
351361
name: wheels-darwin-${{ matrix.python.name }}
352362
path: ./wheelhouse/*.whl
@@ -363,7 +373,7 @@ jobs:
363373
path: download
364374

365375
- name: Upload wheels
366-
uses: actions/upload-artifact@v3
376+
uses: actions/upload-artifact@v4
367377
with:
368378
name: lightsim2grid-wheels
369379
path: |

CHANGELOG.rst

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,39 @@ Change Log
1818
- maybe have a look at suitesparse "sliplu" tools ?
1919
- easier building (get rid of the "make" part)
2020

21-
[0.8.0] 2023-03-18
21+
[0.8.1] 2024-03-26
22+
--------------------
23+
- [FIXED] a bug with shunts when `nb_busbar_per_sub` >= 2
24+
- [FIXED] some bugs preventing backward compatibility
25+
- [FIXED] an issue in the computation of gen_q when intialized with pypowsybl
26+
(some overflow cpp side leading to infinite number in gen_q)
27+
- [FIXED] a bug in the "containers" cpp side (wrong bus was assigned)
28+
when elements was disconnected, which lead to wrong computations for
29+
time series or contingency analysis.
30+
- [FIXED] another bug in ContingencyAnalysis (cpp side) leading to wrong computation
31+
when a powerline was disconnected
32+
- [FIXED] some broken imports when grid2op was not installed
33+
- [FIXED] missing "typing_extension" as required when installation
34+
- [ADDED] some information of compilation directly in the cpp module
35+
- [ADDED] some information of compilation available in the python `compilation_options`
36+
module python side
37+
- [ADDED] some convenient methods for `ContingencyAnalysis` python side (most
38+
notably the possibility to initialize it from a `LightSimBackend` and to
39+
change the topology of the grid)
40+
- [ADDED] a "reward" module in lightsim2grid with custom reward
41+
based on lightsim2grid.
42+
- [ADDED] a class `N1ContingencyReward` that can leverage lightsim2grid to
43+
assess the number of safe / unsafe N-1.
44+
- [IMPROVED] time measurments in python and c++
45+
- [IMPROVED] now test lightsim2grid with oldest grid2op version
46+
- [IMPROVED] speed, by accelerating the reading back of the data (now read only once and then
47+
pointers are re used)
48+
- [IMPROVED] c++ side avoid allocating memory (which allow to gain speed python side too)
49+
- [IMPROVED] type hinting in `LightSimBackend` for all 'public' methods (most
50+
notably the one used by grid2op)
51+
- [IMPROVED] now the benchmarks are more verbose (detailing some compilation options)
52+
53+
[0.8.0] 2024-03-18
2254
--------------------
2355
- [BREAKING] now able to retrieve `dcSbus` with a dedicated method (and not with the old `get_Sbus`).
2456
If you previously used `gridmodel.get_Sbus()` to retrieve the Sbus used for DC powerflow, please use

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ For example: `export PATH_NICSLU=/home/user/Documents/cktso`
222222
223223
#### Enable 03 optimization
224224
By default, at least on ubuntu, only the "-O2" compiler flags is used. To use the O3 optimization flag, you need
225-
to specify the `__COMPLILE_O3` environment variable: `set __COMPLILE_O3=1` before the compilation (so before
225+
to specify the `__O3_OPTIM` environment variable: `set __O3_OPTIM=1` before the compilation (so before
226226
`python3 setup.py build` or `python -m pip install -e .`)
227227
228228
This compilation argument will increase the compilation time, but will make the package faster.

benchmarks/benchmark_grid_size.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"case300.json",
4747
"case1354pegase.json",
4848
"case1888rte.json",
49-
"GBnetwork.json", # 2224 buses
49+
# "GBnetwork.json", # 2224 buses
5050
"case2848rte.json",
5151
"case2869pegase.json",
5252
"case3120sp.json",

benchmarks/utils_benchmark.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import numpy as np
1212
from tqdm import tqdm
1313
import argparse
14+
import datetime
1415
from grid2op.Environment import MultiMixEnvironment
1516
import pdb
1617

@@ -127,6 +128,8 @@ def str2bool(v):
127128

128129

129130
def print_configuration():
131+
print()
132+
print(f"- date: {datetime.datetime.now():%Y-%m-%d %H:%M %z} {time.localtime().tm_zone}")
130133
try:
131134
import platform
132135
print(f"- system: {platform.system()} {platform.release()}")
@@ -156,6 +159,14 @@ def print_configuration():
156159
print(f"- numpy version: {np.__version__}")
157160
print(f"- pandas version: {pd.__version__}")
158161
print(f"- pandapower version: {pp.__version__}")
159-
print(f"- lightsim2grid version: {lightsim2grid.__version__}")
160162
print(f"- grid2op version: {grid2op.__version__}")
163+
print(f"- lightsim2grid version: {lightsim2grid.__version__}")
164+
if hasattr(lightsim2grid, "compilation_options"):
165+
print(f"- lightsim2grid extra information: ")
166+
print()
167+
print(f"\t- klu_solver_available: {lightsim2grid.compilation_options.klu_solver_available} ")
168+
print(f"\t- nicslu_solver_available: {lightsim2grid.compilation_options.nicslu_solver_available} ")
169+
print(f"\t- cktso_solver_available: {lightsim2grid.compilation_options.cktso_solver_available} ")
170+
print(f"\t- compiled_march_native: {lightsim2grid.compilation_options.compiled_march_native} ")
171+
print(f"\t- compiled_o3_optim: {lightsim2grid.compilation_options.compiled_o3_optim} ")
161172
print()

0 commit comments

Comments
 (0)