Skip to content

Commit 6c70efe

Browse files
authored
Merge pull request #619 from BDonnot/issue_617
Fix issue #617
2 parents 017128d + 58c09ad commit 6c70efe

File tree

7 files changed

+548
-78
lines changed

7 files changed

+548
-78
lines changed

.circleci/config.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ jobs:
163163
cd /tmp
164164
grid2op.testinstall
165165
166-
legacy_lightsim:
166+
legacy_lightsim_old_pp:
167167
executor: python38 # needs to be 38: whl of lightsim were not released for 3.10 at the time
168168
resource_class: small
169169
steps:
@@ -190,6 +190,33 @@ jobs:
190190
export _GRID2OP_FORCE_TEST=1
191191
python -m unittest grid2op/tests/test_basic_env_ls.py
192192
193+
legacy_lightsim:
194+
executor: python38 # needs to be 38: whl of lightsim were not released for 3.10 at the time
195+
resource_class: small
196+
steps:
197+
- checkout
198+
- run:
199+
command: |
200+
apt-get update
201+
apt-get install -y coinor-cbc
202+
- run: python -m pip install virtualenv
203+
- run: python -m virtualenv venv_test
204+
- run:
205+
command: |
206+
source venv_test/bin/activate
207+
python -m pip install -U pip setuptools wheel
208+
python -m pip install -U lightsim2grid==0.6.0 gymnasium "numpy<1.22"
209+
- run:
210+
command: |
211+
source venv_test/bin/activate
212+
python -m pip install -e .
213+
pip freeze
214+
- run:
215+
command: |
216+
source venv_test/bin/activate
217+
export _GRID2OP_FORCE_TEST=1
218+
python -m unittest grid2op/tests/test_basic_env_ls.py
219+
193220
install39:
194221
executor: python39
195222
resource_class: small
@@ -340,6 +367,7 @@ workflows:
340367
test:
341368
jobs:
342369
- test
370+
- legacy_lightsim_old_pp
343371
- legacy_lightsim
344372
install:
345373
jobs:

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ Next release
7373
- [FIXED] another issue with the seeding of `MultifolderWithCache`: the seed was not used
7474
correctly on the cache data when calling `chronics_handler.reset` multiple times without
7575
any changes
76+
- [FIXED] `Backend` now properly raise EnvError (grid2op exception) instead of previously
77+
`EnvironmentError` (python default exception)
78+
- [FIXED] a bug in `PandaPowerBackend` (missing attribute) causing directly
79+
https://github.com/rte-france/Grid2Op/issues/617
80+
- [FIXED] a bug in `Environment`: the thermal limit were used when loading the environment
81+
even before the "time series" are applied (and before the user defined thermal limits were set)
82+
which could lead to disconnected powerlines even before the initial step (t=0, when time
83+
series are loaded)
7684
- [ADDED] possibility to skip some step when calling `env.reset(..., options={"init ts": ...})`
7785
- [ADDED] possibility to limit the duration of an episode with `env.reset(..., options={"max step": ...})`
7886
- [ADDED] possibility to specify the "reset_options" used in `env.reset` when

grid2op/Backend/backend.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,12 +1019,7 @@ def _runpf_with_diverging_exception(self, is_dc : bool) -> Optional[Exception]:
10191019
conv, exc_me = self.runpf(is_dc=is_dc) # run powerflow
10201020
except Grid2OpException as exc_:
10211021
exc_me = exc_
1022-
# except Exception as exc_:
1023-
# exc_me = DivergingPowerflow(
1024-
# f" An unexpected error occurred during the computation of the powerflow."
1025-
# f"The error is: \n {exc_} \n. This is game over"
1026-
# )
1027-
1022+
10281023
if not conv and exc_me is None:
10291024
exc_me = DivergingPowerflow(
10301025
"GAME OVER: Powerflow has diverged during computation "
@@ -2160,22 +2155,22 @@ def assert_grid_correct_after_powerflow(self) -> None:
21602155
if tmp.shape[0] != self.n_line:
21612156
raise IncorrectNumberOfLines('returned by "backend.get_line_status()"')
21622157
if (~np.isfinite(tmp)).any():
2163-
raise EnvironmentError(type(self).ERR_INIT_POWERFLOW)
2158+
raise EnvError(type(self).ERR_INIT_POWERFLOW)
21642159
tmp = self.get_line_flow()
21652160
if tmp.shape[0] != self.n_line:
21662161
raise IncorrectNumberOfLines('returned by "backend.get_line_flow()"')
21672162
if (~np.isfinite(tmp)).any():
2168-
raise EnvironmentError(type(self).ERR_INIT_POWERFLOW)
2163+
raise EnvError(type(self).ERR_INIT_POWERFLOW)
21692164
tmp = self.get_thermal_limit()
21702165
if tmp.shape[0] != self.n_line:
21712166
raise IncorrectNumberOfLines('returned by "backend.get_thermal_limit()"')
21722167
if (~np.isfinite(tmp)).any():
2173-
raise EnvironmentError(type(self).ERR_INIT_POWERFLOW)
2168+
raise EnvError(type(self).ERR_INIT_POWERFLOW)
21742169
tmp = self.get_line_overflow()
21752170
if tmp.shape[0] != self.n_line:
21762171
raise IncorrectNumberOfLines('returned by "backend.get_line_overflow()"')
21772172
if (~np.isfinite(tmp)).any():
2178-
raise EnvironmentError(type(self).ERR_INIT_POWERFLOW)
2173+
raise EnvError(type(self).ERR_INIT_POWERFLOW)
21792174

21802175
tmp = self.generators_info()
21812176
if len(tmp) != 3:

0 commit comments

Comments
 (0)