Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #617 #619

Merged
merged 5 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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