Skip to content

Commit

Permalink
Merge pull request #596 from rte-france/dev_1.10.1
Browse files Browse the repository at this point in the history
Ready for version 1.10.1
  • Loading branch information
BDonnot authored Mar 18, 2024
2 parents 5d93858 + fe41bfd commit 9a7568d
Show file tree
Hide file tree
Showing 20 changed files with 1,141 additions and 147 deletions.
28 changes: 28 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,33 @@ jobs:
cd /tmp
grid2op.testinstall
legacy_lightsim:
executor: python38
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.5.3 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 @@ -313,6 +340,7 @@ workflows:
test:
jobs:
- test
- legacy_lightsim
install:
jobs:
- install38
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ Change Log
- [???] "asynch" multienv
- [???] properly model interconnecting powerlines

[1.10.1] - 2024-03-18
----------------------
- [FIXED] issue https://github.com/rte-france/Grid2Op/issues/593
- [FIXED] backward compatibility issues with "oldest" lightsim2grid versions
(now tested in basic settings)
- [ADDED] a "compact" way to store the data in the Runner
- [IMPROVED] the "`train_val_split`" functions, now more names (for the folders)
can be used

[1.10.0] - 2024-03-06
----------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Benjamin Donnot'

# The full version, including alpha/beta/rc tags
release = '1.10.0'
release = '1.10.1.dev0'
version = '1.10'


Expand Down
38 changes: 23 additions & 15 deletions grid2op/Backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1844,8 +1844,9 @@ def get_action_to_set(self) -> "grid2op.Action.CompleteAction":
p_s, q_s, sh_v, bus_s = self.shunt_info()
dict_["shunt"] = {"shunt_bus": bus_s}
if (bus_s >= 1).sum():
p_s *= (self._sh_vnkv / sh_v) ** 2
q_s *= (self._sh_vnkv / sh_v) ** 2
sh_conn = bus_s > 0
p_s[sh_conn] *= (self._sh_vnkv[sh_conn] / sh_v[sh_conn]) ** 2
q_s[sh_conn] *= (self._sh_vnkv[sh_conn] / sh_v[sh_conn]) ** 2
p_s[bus_s == -1] = np.NaN
q_s[bus_s == -1] = np.NaN
dict_["shunt"]["shunt_p"] = p_s
Expand Down Expand Up @@ -1944,21 +1945,28 @@ def assert_grid_correct(self) -> None:
from grid2op.Action import CompleteAction
from grid2op.Action._backendAction import _BackendAction

if self._missing_two_busbars_support_info:
warnings.warn("The backend implementation you are using is probably too old to take advantage of the "
"new feature added in grid2op 1.10.0: the possibility "
"to have more than 2 busbars per substations (or not). "
"To silence this warning, you can modify the `load_grid` implementation "
"of your backend and either call:\n"
"- self.can_handle_more_than_2_busbar if the current implementation "
" can handle more than 2 busbsars OR\n"
"- self.cannot_handle_more_than_2_busbar if not."
"\nAnd of course, ideally, if the current implementation "
"of your backend cannot "
"handle more than 2 busbars per substation, then change it :-)\n"
"Your backend will behave as if it did not support it.")
if hasattr(self, "_missing_two_busbars_support_info"):
if self._missing_two_busbars_support_info:
warnings.warn("The backend implementation you are using is probably too old to take advantage of the "
"new feature added in grid2op 1.10.0: the possibility "
"to have more than 2 busbars per substations (or not). "
"To silence this warning, you can modify the `load_grid` implementation "
"of your backend and either call:\n"
"- self.can_handle_more_than_2_busbar if the current implementation "
" can handle more than 2 busbsars OR\n"
"- self.cannot_handle_more_than_2_busbar if not."
"\nAnd of course, ideally, if the current implementation "
"of your backend cannot "
"handle more than 2 busbars per substation, then change it :-)\n"
"Your backend will behave as if it did not support it.")
self._missing_two_busbars_support_info = False
self.n_busbar_per_sub = DEFAULT_N_BUSBAR_PER_SUB
else:
self._missing_two_busbars_support_info = False
self.n_busbar_per_sub = DEFAULT_N_BUSBAR_PER_SUB
warnings.warn("Your backend is missing the `_missing_two_busbars_support_info` "
"attribute. This is known issue in lightims2grid <= 0.7.5. Please "
"upgrade your backend. This will raise an error in the future.")

orig_type = type(self)
if orig_type.my_bk_act_class is None:
Expand Down
15 changes: 8 additions & 7 deletions grid2op/Environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Environment(BaseEnv):
"""

REGEX_SPLIT = r"^[a-zA-Z0-9]*$"
REGEX_SPLIT = r"^[a-zA-Z0-9_\\.]*$"

def __init__(
self,
Expand Down Expand Up @@ -1362,21 +1362,22 @@ def train_val_split(
"""
# define all the locations
if re.match(self.REGEX_SPLIT, add_for_train) is None:
cls = type(self)
if re.match(cls.REGEX_SPLIT, add_for_train) is None:
raise EnvError(
f"The suffixes you can use for training data (add_for_train) "
f'should match the regex "{self.REGEX_SPLIT}"'
f'should match the regex "{cls.REGEX_SPLIT}"'
)
if re.match(self.REGEX_SPLIT, add_for_val) is None:
if re.match(cls.REGEX_SPLIT, add_for_val) is None:
raise EnvError(
f"The suffixes you can use for validation data (add_for_val)"
f'should match the regex "{self.REGEX_SPLIT}"'
f'should match the regex "{cls.REGEX_SPLIT}"'
)
if add_for_test is not None:
if re.match(self.REGEX_SPLIT, add_for_test) is None:
if re.match(cls.REGEX_SPLIT, add_for_test) is None:
raise EnvError(
f"The suffixes you can use for test data (add_for_test)"
f'should match the regex "{self.REGEX_SPLIT}"'
f'should match the regex "{cls.REGEX_SPLIT}"'
)

if add_for_test is None and test_scen_id is not None:
Expand Down
Loading

0 comments on commit 9a7568d

Please sign in to comment.