Skip to content

Commit 4b36a04

Browse files
authored
Merge pull request #624 from BDonnot/master
Ready for version 1.10.3
2 parents 6c70efe + 917b528 commit 4b36a04

File tree

132 files changed

+2975
-2073
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+2975
-2073
lines changed

.circleci/config.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ jobs:
140140
- run:
141141
command: |
142142
source venv_test/bin/activate
143-
python -m pip install -U "numpy>=1.20,<1.21" "pandas<2.2" "scipy<1.12" numba .[test]
143+
python -m pip install -U "numpy>=1.20,<1.21" "pandas<2.2" "scipy<1.12" numba "pillow<10.4.0" .[test]
144144
pip freeze
145145
- run:
146146
command: |
@@ -151,7 +151,7 @@ jobs:
151151
- run:
152152
command: |
153153
source venv_test/bin/activate
154-
python -m pip install -U "numpy>=1.24,<1.25" "pandas<2.2" "scipy<1.12" numba .[test]
154+
python -m pip install -U "numpy>=1.24,<1.25" "pandas<2.2" "scipy<1.12" numba "pillow<10.4.0" .[test]
155155
- run:
156156
command: |
157157
source venv_test/bin/activate
@@ -209,14 +209,40 @@ jobs:
209209
- run:
210210
command: |
211211
source venv_test/bin/activate
212-
python -m pip install -e .
212+
python -m pip install -e .
213213
pip freeze
214214
- run:
215215
command: |
216216
source venv_test/bin/activate
217217
export _GRID2OP_FORCE_TEST=1
218218
python -m unittest grid2op/tests/test_basic_env_ls.py
219219
220+
test_chronix2grid:
221+
executor: python310 # needs to be 38: whl of lightsim were not released for 3.10 at the time
222+
resource_class: small
223+
steps:
224+
- checkout
225+
- run:
226+
command: |
227+
apt-get update
228+
apt-get install -y coinor-cbc
229+
- run: python -m pip install virtualenv
230+
- run: python -m virtualenv venv_test
231+
- run:
232+
command: |
233+
source venv_test/bin/activate
234+
python -m pip install -U pip setuptools wheel "numpy==1.26.4"
235+
- run:
236+
command: |
237+
source venv_test/bin/activate
238+
python -m pip install -e .[chronix2grid] "linopy==0.3.8" "scs==3.2.4.post1" "ecos==2.0.13" "pillow==10.3.0" "numpy==1.26.4" "xarray==2024.3.0"
239+
pip freeze
240+
- run:
241+
command: |
242+
source venv_test/bin/activate
243+
export _GRID2OP_FORCE_TEST=1
244+
python -m unittest grid2op/tests/fromChronix2grid.py
245+
220246
install39:
221247
executor: python39
222248
resource_class: small
@@ -232,8 +258,7 @@ jobs:
232258
command: |
233259
export _GRID2OP_FORCE_TEST=1
234260
source venv_test/bin/activate
235-
python -m pip install -U pip setuptools wheel "numpy>=1.20,<1.21" "pandas<2.2" "scipy==1.10.1" numba
236-
python -m pip install "chronix2grid>=1.1.0.post1" "gymnasium==0.26.3" "matplotlib==3.7.5" "xarray==2023.10.0" "scs==3.0.0" "ecos==2.0.0"
261+
python -m pip install -U pip setuptools wheel "numpy>=1.20,<1.21" "pandas<2.2" "scipy==1.10.1" "pillow<10.4.0" numba
237262
python -m pip uninstall -y grid2op
238263
- run:
239264
command: | # issue with previous more simple install, so I fix some versions
@@ -249,7 +274,7 @@ jobs:
249274
- run:
250275
command: |
251276
source venv_test/bin/activate
252-
python -m pip install "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba
277+
python -m pip install "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba "pillow<10.4.0"
253278
pip freeze
254279
- run:
255280
command: |
@@ -369,6 +394,8 @@ workflows:
369394
- test
370395
- legacy_lightsim_old_pp
371396
- legacy_lightsim
397+
- test_chronix2grid
398+
372399
install:
373400
jobs:
374401
- install38

.github/workflows/main.yml

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
name: Build linux ${{ matrix.python.name }} wheel
1313
runs-on: ubuntu-latest
1414
container: quay.io/pypa/manylinux2014_x86_64
15+
env:
16+
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
1517
strategy:
1618
matrix:
1719
python:
@@ -59,7 +61,7 @@ jobs:
5961
6062
- name: Build wheel
6163
run: |
62-
python3 setup.py bdist_wheel
64+
python setup.py bdist_wheel
6365
# auditwheel repair dist/*.whl # only for compiled code !
6466
6567
- name: Install wheel
@@ -69,12 +71,16 @@ jobs:
6971
7072
- name: Check package can be imported
7173
run: |
72-
python3 -c "import grid2op"
73-
python3 -c "from grid2op import *"
74-
python3 -c "from grid2op.Action._backendAction import _BackendAction"
75-
74+
python -c "import grid2op"
75+
python -c "from grid2op import *"
76+
python -c "from grid2op.Action._backendAction import _BackendAction"
77+
78+
- name: List wheel
79+
run:
80+
ls ./dist/*.whl
81+
7682
- name: Upload wheel
77-
uses: actions/upload-artifact@v2
83+
uses: actions/upload-artifact@v3
7884
with:
7985
name: grid2op-wheel-${{ matrix.config.name }}-${{ matrix.python.name }}
8086
path: dist/*.whl
@@ -165,10 +171,70 @@ jobs:
165171
name: grid2op-sources
166172
path: dist/*.tar.gz
167173

174+
auto_class_in_file:
175+
name: Test ${{ matrix.config.name }} OS can handle automatic class generation
176+
runs-on: ${{ matrix.config.os }}
177+
strategy:
178+
matrix:
179+
config:
180+
- {
181+
name: darwin,
182+
os: macos-latest,
183+
}
184+
# - {
185+
# name: windows,
186+
# os: windows-2019,
187+
# }
188+
- {
189+
name: ubuntu,
190+
os: ubuntu-latest,
191+
}
192+
python:
193+
- {
194+
name: cp39,
195+
version: '3.9',
196+
}
197+
- {
198+
name: cp312,
199+
version: '3.12',
200+
}
201+
202+
steps:
203+
204+
- name: Checkout sources
205+
uses: actions/checkout@v1
206+
with:
207+
submodules: true
208+
209+
- name: Setup Python
210+
uses: actions/setup-python@v2
211+
with:
212+
python-version: ${{ matrix.python.version }}
213+
214+
- name: Install Python dependencies
215+
run: |
216+
python -m pip install --upgrade pip
217+
python -m pip install --upgrade wheel
218+
python -m pip install --upgrade setuptools
219+
python -m pip install --upgrade gymnasium "numpy<2"
220+
221+
- name: Build wheel
222+
run: python setup.py bdist_wheel
223+
224+
- name: Install wheel
225+
shell: bash
226+
run: |
227+
python -m pip install dist/*.whl --user
228+
pip freeze
229+
230+
- name: Test the automatic generation of classes in the env folder
231+
run: |
232+
python -m unittest grid2op/tests/automatic_classes.py -f
233+
168234
package:
169235
name: Test install
170236
runs-on: ubuntu-latest
171-
needs: [manylinux_build, macos_windows_build]
237+
needs: [manylinux_build, macos_windows_build, auto_class_in_file]
172238

173239
steps:
174240
- name: Download wheels

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ getting_started/env_py38_grid2op110_ray210.ipynb
413413
grid2op/tests/req_chronix2grid
414414
grid2op/tests/venv_test_chronix2grid/
415415
getting_started/venv_310_ray/
416+
grid2op/tests/venv_test_autoclass/
417+
test_eduardo.py
418+
grid2op/tests/failed_test*
416419

417420
# profiling files
418421
**.prof

CHANGELOG.rst

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,31 @@ Work kind of in progress
4040

4141
Next release
4242
---------------------------------
43+
- numpy 2 compat (need pandapower for that)
44+
- automatic read from local dir also on windows !
45+
- TODO doc for the "new" feature of automatic "experimental_read_from_local_dir"
4346
- TODO bug on maintenance starting at midnight (they are not correctly handled in the observation)
4447
=> cf script test_issue_616
48+
- TODO put the Grid2opEnvWrapper directly in grid2op as GymEnv
49+
- TODO faster gym_compat (especially for DiscreteActSpace and BoxGymObsSpace)
4550
- TODO Notebook for tf_agents
4651
- TODO Notebook for acme
4752
- TODO Notebook using "keras rl" (see https://keras.io/examples/rl/ppo_cartpole/)
48-
- TODO put the Grid2opEnvWrapper directly in grid2op as GymEnv
4953
- TODO example for MCTS https://github.com/bwfbowen/muax et https://github.com/google-deepmind/mctx
5054
- TODO jax everything that can be: create a simple env based on jax for topology manipulation, without
5155
redispatching or rules
5256
- TODO backend in jax, maybe ?
5357
- TODO done and truncated properly handled in gym_compat module (when game over
5458
before the end it's probably truncated and not done)
55-
56-
[1.10.3] - 2024-xx-yy
59+
- TODO when reset, have an attribute "reset_infos" with some infos about the
60+
way reset was called.
61+
- TODO ForecastEnv in MaskedEnv ! (and obs.simulate there too !)
62+
- TODO finish the test in automatic_classes
63+
- TODO in multi-mix increase the reset options with the mix the user wants
64+
- TODO L2RPN scores as reward (sum loads after the game over and have it in the final reward)
65+
- TODO on CI: test only gym, only gymnasium and keep current test for both gym and gymnasium
66+
67+
[1.10.3] - 2024-07-yy
5768
-------------------------
5869
- TODO Automatic "experimental_read_from_local_dir"
5970

@@ -66,8 +77,20 @@ Next release
6677
use it (will likely have no effect). Prefer using `env.set_max_iter` instead.
6778
- [BREAKING] now the `runner.run()` method only accept kwargs argument
6879
(because it should always have been like this)
80+
- [BREAKING] to improve pickle support and multi processing capabilities, the attribute
81+
`gym_env.observation_space._init_env` and `gym_env.observation_space.initial_obs_space`
82+
have been deleted (for the `Dict` space only, for the other spaces like the `Box` they
83+
were not present in the first place)
84+
- [BREAKING] in the `GymEnv` class now by default the underlying grid2op environment has no
85+
forecast anymore in an attempt to make this wrapper faster AND more easily pickle-able. You can
86+
retrieve the old behaviour by passing `gym_env = GymEnv(grid2op_env, with_forecast=True)`
6987
- [FIXED] a bug in the `MultiFolder` and `MultifolderWithCache` leading to the wrong
7088
computation of `max_iter` on some corner cases
89+
- [FIXED] the function `cleanup_action_space()` did not work correctly when the "chronics_hander"
90+
was not initialized for some classes
91+
- [FIXED] the `_observationClass` attribute of the "observation env" (used for simulate and forecasted env)
92+
is now an Observation and not an Action.
93+
- [FIXED] a bug when deep copying an "observation environment" (it changes its class)
7194
- [FIXED] issue on `seed` and `MultifolderWithCache` which caused
7295
https://github.com/rte-france/Grid2Op/issues/616
7396
- [FIXED] another issue with the seeding of `MultifolderWithCache`: the seed was not used
@@ -81,18 +104,36 @@ Next release
81104
even before the "time series" are applied (and before the user defined thermal limits were set)
82105
which could lead to disconnected powerlines even before the initial step (t=0, when time
83106
series are loaded)
107+
- [FIXED] an issue with the "max_iter" for `FromNPY` time series generator
108+
- [FIXED] a bug in `MultiMixEnvironment` : a multi-mix could be created even if the underlying
109+
powergrids (for each mix) where not the same.
110+
- [FIXED] a bug in `generate_classes` (experimental_read_from_local_dir) with alert data.
111+
- [FIXED] a bug in the `Runner` when using multi processing on macos and windows OS: some non default
112+
parameters where not propagated in the "child" process (bug in `runner._ger_params`)
84113
- [ADDED] possibility to skip some step when calling `env.reset(..., options={"init ts": ...})`
85114
- [ADDED] possibility to limit the duration of an episode with `env.reset(..., options={"max step": ...})`
86115
- [ADDED] possibility to specify the "reset_options" used in `env.reset` when
87116
using the runner with `runner.run(..., reset_options=xxx)`
88-
- [ADDED] the time series now are able to regenerate their "random" part
117+
- [ADDED] the argument `mp_context` when building the runner to help pass a multiprocessing context in the
118+
grid2op `Runner`
119+
- [ADDED] the time series are now able to regenerate their "random" part
89120
even when "cached" thanks to the addition of the `regenerate_with_new_seed` of the
90121
`GridValue` class (in public API)
91122
- [ADDED] `MultifolderWithCache` now supports `FromHandlers` time series generator
123+
- [IMPROVED] more consistency in the way the classes are initialized at the creation of an environment
124+
- [IMPROVED] more consistency when an environment is copied (some attributes of the copied env were
125+
deep copied incorrectly)
126+
- [IMPROVED] Doc about the runner
92127
- [IMPROVED] the documentation on the `time series` folder.
93128
- [IMPROVED] now the "maintenance from json" (*eg* the `JSONMaintenanceHandler` or the
94129
`GridStateFromFileWithForecastsWithMaintenance`) can be customized with the day
95130
of the week where the maintenance happens (key `maintenance_day_of_week`)
131+
- [IMPROVED] in case of "`MultiMixEnvironment`" there is now only class generated for
132+
all the underlying mixes (instead of having one class per mixes)
133+
- [IMPROVED] the `EpisodeData` have now explicitely a mode where they can be shared accross
134+
processes (using `fork` at least), see `ep_data.make_serializable`
135+
- [IMPROVED] chronix2grid tests are now done independantly on the CI
136+
96137

97138
[1.10.2] - 2024-05-27
98139
-------------------------
@@ -885,7 +926,7 @@ Next release
885926
`Issue#185 <https://github.com/rte-france/Grid2Op/issues/185>`_ )
886927
- [IMPROVED] the seed of openAI gym for composed action space (see issue `https://github.com/openai/gym/issues/2166`):
887928
in waiting for an official fix, grid2op will use the solution proposed there
888-
https://github.com/openai/gym/issues/2166#issuecomment-803984619 )
929+
https://github.com/openai/gym/issues/2166#issuecomment-803984619
889930

890931
[1.5.1] - 2021-04-15
891932
-----------------------

docs/grid2op.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ alert (when the attack is happening)
447447

448448
Disclaimer
449449
-----------
450+
450451
Grid2op is a research testbed platform, it has not been tested in "production" context
451452

452453
Going further
@@ -458,3 +459,5 @@ more information and a detailed tour about the issue that grid2op tries to addre
458459

459460
.. note:: As of writing (december 2020) most of these notebooks focus on the "agent" part of grid2op. We would welcome
460461
any contribution to better explain the other aspect of this platform.
462+
463+
.. include:: final.rst

docs/gym.rst

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -504,37 +504,7 @@ This is because grid2op will (to save computation time) generate some classes (t
504504
fly, once the environment is loaded. And unfortunately, pickle module is not always able to process these
505505
(meta) data.
506506

507-
Try to first create (automatically!) the files containing the description of the classes
508-
used by your environment (for example):
509-
510-
.. code-block:: python
511-
512-
from grid2op import make
513-
from grid2op.Reward import RedispReward
514-
from lightsim2grid import LightSimBackend
515-
516-
env_name = 'l2rpn_wcci_2022'
517-
backend_class = LightSimBackend
518-
env = make(env_name, reward_class=RedispReward, backend=backend_class())
519-
env.generate_classes()
520-
521-
.. note::
522-
This piece of code is to do once (each time you change the backend or the env name)
523-
524-
And then proceed as usual by loading the grid2op environment
525-
with the key-word `experimental_read_from_local_dir`
526-
527-
.. code-block:: python
528-
529-
from grid2op import make
530-
from grid2op.Reward import RedispReward
531-
from lightsim2grid import LightSimBackend
532-
533-
env_name = 'l2rpn_wcci_2022'
534-
backend_class = LightSimBackend
535-
env = make(env_name, reward_class=RedispReward, backend=backend_class(),
536-
experimental_read_from_local_dir=True)
537-
# do whatever
507+
You can solve this issue by look at :ref:`troubleshoot_pickle` section of the documentation.
538508

539509
Observation XXX outside given space YYY
540510
****************************************
@@ -560,4 +530,4 @@ Detailed Documentation by class
560530
:members:
561531
:autosummary:
562532

563-
.. include:: final.rst
533+
.. include:: final.rst

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Environments
7575
create_an_environment
7676
dive_into_time_series
7777
data_pipeline
78+
troubleshoot
7879

7980
Usage examples
8081
---------------------

docs/model_based.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,5 @@ And for the `ExampleAgent2`:
378378
res = strat[0] # action is the first one of the best strategy
379379
highest_score = ts_survived
380380
return res
381+
382+
.. include:: final.rst

docs/model_free.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ Some examples are given in "l2rpn-baselines":
1717

1818
- `PPO with RLLIB <https://l2rpn-baselines.readthedocs.io/en/bd-dev/ppo_rllib.html>`_
1919
- `PPO with stable-baselines3 <hhttps://l2rpn-baselines.readthedocs.io/en/bd-dev/ppo_stable_baselines.html>`_
20+
21+
.. include:: final.rst

docs/observation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,4 @@ Detailed Documentation by class
133133
:special-members:
134134
:autosummary:
135135

136-
.. include:: final.rst
136+
.. include:: final.rst

0 commit comments

Comments
 (0)