Skip to content

Commit

Permalink
Merge pull request #79 from BDonnot/bd-dev
Browse files Browse the repository at this point in the history
Upgrade to version 0.8.1
  • Loading branch information
BDonnot authored Mar 26, 2024
2 parents d05dede + f657ca2 commit bca579e
Show file tree
Hide file tree
Showing 62 changed files with 2,035 additions and 389 deletions.
25 changes: 25 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@ executors:
- image: silkeh/clang:9 # no c++ 11, does not work

jobs:
test_legacy_grid2op:
executor: gcc_13
resource_class: small
steps:
- checkout
- run: apt-get update && apt-get install python3-full python3-dev python3-pip python3-virtualenv git -y
- run: python3 -m virtualenv venv_test
- run:
name: "Set up virtual environment"
command: |
source venv_test/bin/activate
pip install --upgrade pip setuptools wheel gym "numpy<1.22" grid2op==1.6.4
pip install -U pybind11
git submodule init
git submodule update
make
CC=gcc python setup.py build
python -m pip install -U .
pip freeze
- run:
name: legacy test
command: |
source venv_test/bin/activate
python -m unittest lightsim2grid/tests/test_compat_legacy_grid2op.py
compile_gcc12:
executor: gcc_12
resource_class: small
Expand Down
46 changes: 28 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
steps:

- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v3 # v4 not working...
with:
submodules: true

Expand All @@ -76,16 +76,22 @@ jobs:
run: python setup.py sdist

- name: Install wheel
run: pip3 install wheelhouse/*.whl --user
run: |
pip3 install wheelhouse/*.whl --user
pip freeze
# - name: Install GDB
# run: yum install -y gdb

- name: Check package can be imported
- name: Check package can be imported (bare install)
run: |
python3 -c "import lightsim2grid"
python3 -c "from lightsim2grid import *"
python3 -c "from lightsim2grid.newtonpf import newtonpf"
python3 -c "from lightsim2grid.timeSerie import TimeSeriesCPP"
python3 -c "from lightsim2grid.contingencyAnalysis import ContingencyAnalysisCPP"
python3 -c "from lightsim2grid.securityAnalysis import SecurityAnalysisCPP"
python3 -c "from lightsim2grid.gridmodel import init, GridModel"
- name: Fix urllib3 (python 3.7)
if: matrix.python.name == 'cp37'
Expand All @@ -98,22 +104,26 @@ jobs:
python3 -m pip install grid2op
python3 -m pip freeze
- name: Check LightSimBackend can be imported 1
- name: Check extra can be imported can be imported (with grid2op)
run:
python3 -v -c "from lightsim2grid import LightSimBackend"

- name: Check LightSimBackend can be imported 2
python3 -c "from lightsim2grid.timeSerie import TimeSerie"
python3 -c "from lightsim2grid.contingencyAnalysis import ContingencyAnalysis"
python3 -c "from lightsim2grid.physical_law_checker import PhysicalLawChecker"
python3 -c "from lightsim2grid.securityAnalysis import SecurityAnalysis"

- name: Check LightSimBackend can be used to create env
run:
python3 -v -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"

- name: Upload wheel
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v3 # v4 broken
with:
name: lightsim2grid-wheel-linux-${{ matrix.python.name }}
path: wheelhouse/*.whl

- name: Upload source archive
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v3 # v4 broken
if: matrix.python.name == 'cp311'
with:
name: lightsim2grid-sources
Expand Down Expand Up @@ -157,12 +167,12 @@ jobs:
steps:

- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python.version }}

Expand Down Expand Up @@ -210,7 +220,7 @@ jobs:
python -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"
- name: Upload wheel
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: lightsim2grid-wheel-${{ matrix.config.name }}-${{ matrix.python.name }}
path: dist/*.whl
Expand All @@ -228,12 +238,12 @@ jobs:
}
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python.version }}

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

- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python.version }}

Expand Down Expand Up @@ -346,7 +356,7 @@ jobs:
python -c "from lightsim2grid import LightSimBackend; import grid2op; env = grid2op.make('l2rpn_case14_sandbox', test=True, backend=LightSimBackend())"
- name: Upload wheel
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels-darwin-${{ matrix.python.name }}
path: ./wheelhouse/*.whl
Expand All @@ -363,7 +373,7 @@ jobs:
path: download

- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: lightsim2grid-wheels
path: |
Expand Down
34 changes: 33 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,39 @@ Change Log
- maybe have a look at suitesparse "sliplu" tools ?
- easier building (get rid of the "make" part)

[0.8.0] 2023-03-18
[0.8.1] 2024-03-26
--------------------
- [FIXED] a bug with shunts when `nb_busbar_per_sub` >= 2
- [FIXED] some bugs preventing backward compatibility
- [FIXED] an issue in the computation of gen_q when intialized with pypowsybl
(some overflow cpp side leading to infinite number in gen_q)
- [FIXED] a bug in the "containers" cpp side (wrong bus was assigned)
when elements was disconnected, which lead to wrong computations for
time series or contingency analysis.
- [FIXED] another bug in ContingencyAnalysis (cpp side) leading to wrong computation
when a powerline was disconnected
- [FIXED] some broken imports when grid2op was not installed
- [FIXED] missing "typing_extension" as required when installation
- [ADDED] some information of compilation directly in the cpp module
- [ADDED] some information of compilation available in the python `compilation_options`
module python side
- [ADDED] some convenient methods for `ContingencyAnalysis` python side (most
notably the possibility to initialize it from a `LightSimBackend` and to
change the topology of the grid)
- [ADDED] a "reward" module in lightsim2grid with custom reward
based on lightsim2grid.
- [ADDED] a class `N1ContingencyReward` that can leverage lightsim2grid to
assess the number of safe / unsafe N-1.
- [IMPROVED] time measurments in python and c++
- [IMPROVED] now test lightsim2grid with oldest grid2op version
- [IMPROVED] speed, by accelerating the reading back of the data (now read only once and then
pointers are re used)
- [IMPROVED] c++ side avoid allocating memory (which allow to gain speed python side too)
- [IMPROVED] type hinting in `LightSimBackend` for all 'public' methods (most
notably the one used by grid2op)
- [IMPROVED] now the benchmarks are more verbose (detailing some compilation options)

[0.8.0] 2024-03-18
--------------------
- [BREAKING] now able to retrieve `dcSbus` with a dedicated method (and not with the old `get_Sbus`).
If you previously used `gridmodel.get_Sbus()` to retrieve the Sbus used for DC powerflow, please use
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ For example: `export PATH_NICSLU=/home/user/Documents/cktso`
#### Enable 03 optimization
By default, at least on ubuntu, only the "-O2" compiler flags is used. To use the O3 optimization flag, you need
to specify the `__COMPLILE_O3` environment variable: `set __COMPLILE_O3=1` before the compilation (so before
to specify the `__O3_OPTIM` environment variable: `set __O3_OPTIM=1` before the compilation (so before
`python3 setup.py build` or `python -m pip install -e .`)
This compilation argument will increase the compilation time, but will make the package faster.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmark_grid_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"case300.json",
"case1354pegase.json",
"case1888rte.json",
"GBnetwork.json", # 2224 buses
# "GBnetwork.json", # 2224 buses
"case2848rte.json",
"case2869pegase.json",
"case3120sp.json",
Expand Down
13 changes: 12 additions & 1 deletion benchmarks/utils_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import numpy as np
from tqdm import tqdm
import argparse
import datetime
from grid2op.Environment import MultiMixEnvironment
import pdb

Expand Down Expand Up @@ -127,6 +128,8 @@ def str2bool(v):


def print_configuration():
print()
print(f"- date: {datetime.datetime.now():%Y-%m-%d %H:%M %z} {time.localtime().tm_zone}")
try:
import platform
print(f"- system: {platform.system()} {platform.release()}")
Expand Down Expand Up @@ -156,6 +159,14 @@ def print_configuration():
print(f"- numpy version: {np.__version__}")
print(f"- pandas version: {pd.__version__}")
print(f"- pandapower version: {pp.__version__}")
print(f"- lightsim2grid version: {lightsim2grid.__version__}")
print(f"- grid2op version: {grid2op.__version__}")
print(f"- lightsim2grid version: {lightsim2grid.__version__}")
if hasattr(lightsim2grid, "compilation_options"):
print(f"- lightsim2grid extra information: ")
print()
print(f"\t- klu_solver_available: {lightsim2grid.compilation_options.klu_solver_available} ")
print(f"\t- nicslu_solver_available: {lightsim2grid.compilation_options.nicslu_solver_available} ")
print(f"\t- cktso_solver_available: {lightsim2grid.compilation_options.cktso_solver_available} ")
print(f"\t- compiled_march_native: {lightsim2grid.compilation_options.compiled_march_native} ")
print(f"\t- compiled_o3_optim: {lightsim2grid.compilation_options.compiled_o3_optim} ")
print()
Loading

0 comments on commit bca579e

Please sign in to comment.