Skip to content

Commit

Permalink
Merge pull request #619 from BDonnot/issue_617
Browse files Browse the repository at this point in the history
Fix issue #617
  • Loading branch information
BDonnot authored Jun 26, 2024
2 parents 017128d + 58c09ad commit 6c70efe
Show file tree
Hide file tree
Showing 7 changed files with 548 additions and 78 deletions.
30 changes: 29 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ jobs:
cd /tmp
grid2op.testinstall
legacy_lightsim:
legacy_lightsim_old_pp:
executor: python38 # needs to be 38: whl of lightsim were not released for 3.10 at the time
resource_class: small
steps:
Expand All @@ -190,6 +190,33 @@ jobs:
export _GRID2OP_FORCE_TEST=1
python -m unittest grid2op/tests/test_basic_env_ls.py
legacy_lightsim:
executor: python38 # needs to be 38: whl of lightsim were not released for 3.10 at the time
resource_class: small
steps:
- checkout
- run:
command: |
apt-get update
apt-get install -y coinor-cbc
- run: python -m pip install virtualenv
- run: python -m virtualenv venv_test
- run:
command: |
source venv_test/bin/activate
python -m pip install -U pip setuptools wheel
python -m pip install -U lightsim2grid==0.6.0 gymnasium "numpy<1.22"
- run:
command: |
source venv_test/bin/activate
python -m pip install -e .
pip freeze
- run:
command: |
source venv_test/bin/activate
export _GRID2OP_FORCE_TEST=1
python -m unittest grid2op/tests/test_basic_env_ls.py
install39:
executor: python39
resource_class: small
Expand Down Expand Up @@ -340,6 +367,7 @@ workflows:
test:
jobs:
- test
- legacy_lightsim_old_pp
- legacy_lightsim
install:
jobs:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ Next release
- [FIXED] another issue with the seeding of `MultifolderWithCache`: the seed was not used
correctly on the cache data when calling `chronics_handler.reset` multiple times without
any changes
- [FIXED] `Backend` now properly raise EnvError (grid2op exception) instead of previously
`EnvironmentError` (python default exception)
- [FIXED] a bug in `PandaPowerBackend` (missing attribute) causing directly
https://github.com/rte-france/Grid2Op/issues/617
- [FIXED] a bug in `Environment`: the thermal limit were used when loading the environment
even before the "time series" are applied (and before the user defined thermal limits were set)
which could lead to disconnected powerlines even before the initial step (t=0, when time
series are loaded)
- [ADDED] possibility to skip some step when calling `env.reset(..., options={"init ts": ...})`
- [ADDED] possibility to limit the duration of an episode with `env.reset(..., options={"max step": ...})`
- [ADDED] possibility to specify the "reset_options" used in `env.reset` when
Expand Down
15 changes: 5 additions & 10 deletions grid2op/Backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,12 +1019,7 @@ def _runpf_with_diverging_exception(self, is_dc : bool) -> Optional[Exception]:
conv, exc_me = self.runpf(is_dc=is_dc) # run powerflow
except Grid2OpException as exc_:
exc_me = exc_
# except Exception as exc_:
# exc_me = DivergingPowerflow(
# f" An unexpected error occurred during the computation of the powerflow."
# f"The error is: \n {exc_} \n. This is game over"
# )


if not conv and exc_me is None:
exc_me = DivergingPowerflow(
"GAME OVER: Powerflow has diverged during computation "
Expand Down Expand Up @@ -2160,22 +2155,22 @@ def assert_grid_correct_after_powerflow(self) -> None:
if tmp.shape[0] != self.n_line:
raise IncorrectNumberOfLines('returned by "backend.get_line_status()"')
if (~np.isfinite(tmp)).any():
raise EnvironmentError(type(self).ERR_INIT_POWERFLOW)
raise EnvError(type(self).ERR_INIT_POWERFLOW)
tmp = self.get_line_flow()
if tmp.shape[0] != self.n_line:
raise IncorrectNumberOfLines('returned by "backend.get_line_flow()"')
if (~np.isfinite(tmp)).any():
raise EnvironmentError(type(self).ERR_INIT_POWERFLOW)
raise EnvError(type(self).ERR_INIT_POWERFLOW)
tmp = self.get_thermal_limit()
if tmp.shape[0] != self.n_line:
raise IncorrectNumberOfLines('returned by "backend.get_thermal_limit()"')
if (~np.isfinite(tmp)).any():
raise EnvironmentError(type(self).ERR_INIT_POWERFLOW)
raise EnvError(type(self).ERR_INIT_POWERFLOW)
tmp = self.get_line_overflow()
if tmp.shape[0] != self.n_line:
raise IncorrectNumberOfLines('returned by "backend.get_line_overflow()"')
if (~np.isfinite(tmp)).any():
raise EnvironmentError(type(self).ERR_INIT_POWERFLOW)
raise EnvError(type(self).ERR_INIT_POWERFLOW)

tmp = self.generators_info()
if len(tmp) != 3:
Expand Down
Loading

0 comments on commit 6c70efe

Please sign in to comment.