Skip to content

Commit ac4bceb

Browse files
authored
Merge pull request #716 from BDonnot/bd_dev
Bd dev
2 parents 768e309 + 93ecf9c commit ac4bceb

File tree

5 files changed

+123
-57
lines changed

5 files changed

+123
-57
lines changed

.github/workflows/main.yml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ jobs:
4343
abi: cp312,
4444
version: '3.12',
4545
}
46-
# - {
47-
# name: cp313, # issue with pandapower atm
48-
# abi: cp313,
49-
# version: '3.13',
50-
# }
46+
- {
47+
name: cp313, # issue with pandapower atm
48+
abi: cp313,
49+
version: '3.13',
50+
}
5151

5252
steps:
5353

@@ -141,10 +141,10 @@ jobs:
141141
name: cp312,
142142
version: '3.12',
143143
}
144-
# - { # issue with pandapower atm
145-
# name: cp313,
146-
# version: '3.13',
147-
# }
144+
- { # issue with pandapower atm
145+
name: cp313,
146+
version: '3.13',
147+
}
148148

149149
steps:
150150

@@ -197,7 +197,7 @@ jobs:
197197
path: dist/*.tar.gz
198198

199199
auto_class_in_file:
200-
name: Test ${{ matrix.config.name }} OS can handle automatic class generation
200+
name: Test ${{ matrix.config.name }} OS can handle automatic class generation for python ${{matrix.python.version}}
201201
runs-on: ${{ matrix.config.os }}
202202
strategy:
203203
matrix:
@@ -220,8 +220,8 @@ jobs:
220220
version: '3.9',
221221
}
222222
- {
223-
name: cp312,
224-
version: '3.12',
223+
name: cp313,
224+
version: '3.13',
225225
}
226226

227227
steps:
@@ -238,10 +238,7 @@ jobs:
238238

239239
- name: Install Python dependencies
240240
run: |
241-
python -m pip install --upgrade pip
242-
python -m pip install --upgrade wheel
243-
python -m pip install --upgrade setuptools
244-
python -m pip install --upgrade gymnasium "numpy<2"
241+
python -m pip install --upgrade pip wheel setuptools gymnasium
245242
246243
- name: Build wheel
247244
run: python setup.py bdist_wheel
@@ -254,7 +251,7 @@ jobs:
254251
255252
- name: Test the automatic generation of classes in the env folder
256253
run: |
257-
python -m unittest grid2op/tests/automatic_classes.py -f
254+
python -m unittest grid2op/tests/automatic_classes.py -v -f
258255
259256
package:
260257
name: Test install

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Its main features are:
115115
* can adopt any powergrid modeling, especially Alternating Current (AC) and Direct Current (DC) approximation to
116116
when performing the compitations
117117
* supports changes of powerflow solvers, actions, observations to better suit any need in performing power system operations modeling
118-
* has an RL-focused interface, compatible with [OpenAI-gym](https://gym.openai.com/): same interface for the
118+
* has an RL-focused interface, compatible with [gymnasium](https://gymnasium.farama.org/index.html): same interface for the
119119
Environment class.
120120
* parameters, game rules or type of actions are perfectly parametrizable
121121
* can adapt to any kind of input data, in various format (might require the rewriting of a class)
@@ -306,11 +306,12 @@ The unit tests includes testing, on linux machines the correct integration of gr
306306
* python 3.10
307307
* python 3.11
308308
* python 3.12
309+
* python 3.13
309310

310-
On all of these cases, we tested grid2op on all available numpy versions >= 1.20 (**nb** available numpy versions depend
311+
On all of these cases, we tested grid2op on all available numpy versions >= 2.0 (**nb** available numpy versions depend
311312
on python version).
312313

313-
The complete test suit is run on linux with the latest numpy version on python 3.10.
314+
The complete test suit is run on linux with the latest numpy version on python 3.12.
314315

315316
### Known issues
316317

grid2op/Environment/baseEnv.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
import warnings
2121
import numpy as np
2222
from scipy.optimize import (minimize, LinearConstraint)
23-
2423
from abc import ABC, abstractmethod
24+
25+
from grid2op._glop_platform_info import _IS_WINDOWS
2526
from grid2op.Environment._env_prev_state import _EnvPreviousState
2627
from grid2op.Observation import (BaseObservation,
2728
ObservationSpace,
@@ -4117,14 +4118,25 @@ def close(self):
41174118
self._aux_close_local_dir_cls()
41184119

41194120
def _aux_close_local_dir_cls(self):
4120-
if self._local_dir_cls is not None:
4121-
# I am the "keeper" of the temporary directory
4122-
# deleting this env should also delete the temporary directory
4123-
if not (hasattr(self._local_dir_cls, "_RUNNER_DO_NOT_ERASE") and not self._local_dir_cls._RUNNER_DO_NOT_ERASE):
4124-
# BUT if a runner uses it, then I should not delete it !
4125-
self._local_dir_cls.cleanup()
4126-
self._local_dir_cls = None
4127-
# In this case it's likely that the OS will clean it for grid2op with a warning...
4121+
if self._local_dir_cls is None:
4122+
return
4123+
# I am the "keeper" of the temporary directory
4124+
# deleting this env should also delete the temporary directory
4125+
if not (hasattr(self._local_dir_cls, "_RUNNER_DO_NOT_ERASE") and not self._local_dir_cls._RUNNER_DO_NOT_ERASE):
4126+
# BUT if a runner uses it, then I should not delete it !
4127+
self._local_dir_cls.cleanup()
4128+
self._local_dir_cls = None
4129+
# In this case it's likely that the OS will clean it for grid2op with a warning...
4130+
4131+
# clear all imported modules (required for windows)
4132+
# otherwise it tries to import the classes when processes are spawned
4133+
# even the classes that have been "cleaned"
4134+
if _IS_WINDOWS and type(self)._PATH_GRID_CLASSES is not None:
4135+
# TODO find a better way here
4136+
module_name = os.path.split(type(self)._PATH_GRID_CLASSES)[-1]
4137+
for el in sys.modules.copy():
4138+
if module_name in el:
4139+
del sys.modules[el]
41284140

41294141
def attach_layout(self, grid_layout):
41304142
"""

grid2op/VoltageControler/BaseVoltageController.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
# This file is part of Grid2Op, Grid2Op a testbed platform to model sequential decision making in power systems.
88
from abc import ABC, abstractmethod
99
import numpy as np
10-
import copy
1110

1211
from grid2op.dtypes import dt_int
13-
from grid2op.Action import VoltageOnlyAction, ActionSpace
12+
from grid2op.Action import VoltageOnlyAction
1413
from grid2op.Rules import AlwaysLegal
1514
from grid2op.Space import RandomObject
1615

0 commit comments

Comments
 (0)