Skip to content

Commit 0feefd9

Browse files
authored
Merge pull request #191 from BDonnot/bd_dev
Bd dev
2 parents e18957b + 7d3a926 commit 0feefd9

File tree

231 files changed

+11095
-1038
lines changed

Some content is hidden

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

231 files changed

+11095
-1038
lines changed

.circleci/config.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ jobs:
164164
grid2op.testinstall
165165
166166
legacy_lightsim:
167-
executor: python38
167+
executor: python38 # needs to be 38: whl of lightsim were not released for 3.10 at the time
168168
resource_class: small
169169
steps:
170170
- checkout
@@ -205,13 +205,13 @@ jobs:
205205
command: |
206206
export _GRID2OP_FORCE_TEST=1
207207
source venv_test/bin/activate
208-
python -m pip install -U pip setuptools wheel
209-
python -m pip install chronix2grid>="1.1.0.post1"
208+
python -m pip install -U pip setuptools wheel "numpy>=1.20,<1.21" "pandas<2.2" "scipy==1.10.1" numba
209+
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"
210210
python -m pip uninstall -y grid2op
211211
- run:
212-
command: |
212+
command: | # issue with previous more simple install, so I fix some versions
213213
source venv_test/bin/activate
214-
python -m pip install -U "numpy>=1.20,<1.21" "pandas<2.2" "scipy<1.12" numba .[test]
214+
python -m pip install "numpy>=1.20,<1.21" "pandas<2.2" "scipy==1.10.1" numba .
215215
pip freeze
216216
- run:
217217
command: |
@@ -222,7 +222,7 @@ jobs:
222222
- run:
223223
command: |
224224
source venv_test/bin/activate
225-
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba .[test]
225+
python -m pip install "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba
226226
pip freeze
227227
- run:
228228
command: |
@@ -250,7 +250,7 @@ jobs:
250250
- run:
251251
command: |
252252
source venv_test/bin/activate
253-
python -m pip install -U "numpy>=1.21,<1.22" "pandas<2.2" "scipy<1.12" numba .[test]
253+
python -m pip install -U "numpy>=1.21,<1.22" "pandas<2.2" "scipy<1.12" numba .
254254
pip freeze
255255
- run:
256256
command: |
@@ -261,7 +261,7 @@ jobs:
261261
- run:
262262
command: |
263263
source venv_test/bin/activate
264-
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba .[test]
264+
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba
265265
pip freeze
266266
- run:
267267
command: |
@@ -288,7 +288,7 @@ jobs:
288288
- run:
289289
command: |
290290
source venv_test/bin/activate
291-
python -m pip install -U "numpy>=1.23,<1.24" "pandas<2.2" "scipy<1.12" numba .[test]
291+
python -m pip install -U "numpy>=1.23,<1.24" "pandas<2.2" "scipy<1.12" numba .
292292
pip freeze
293293
- run:
294294
command: |
@@ -299,7 +299,7 @@ jobs:
299299
- run:
300300
command: |
301301
source venv_test/bin/activate
302-
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba .[test]
302+
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba
303303
pip freeze
304304
- run:
305305
command: |
@@ -326,7 +326,7 @@ jobs:
326326
- run:
327327
command: |
328328
source venv_test/bin/activate
329-
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" .[test]
329+
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" .
330330
pip freeze
331331
- run:
332332
command: |

.github/workflows/main.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,16 @@ jobs:
6363
# auditwheel repair dist/*.whl # only for compiled code !
6464
6565
- name: Install wheel
66-
run: pip3 install dist/*.whl --user
66+
run: |
67+
pip3 install dist/*.whl
68+
pip freeze
6769
6870
- name: Check package can be imported
6971
run: |
7072
python3 -c "import grid2op"
7173
python3 -c "from grid2op import *"
7274
python3 -c "from grid2op.Action._backendAction import _BackendAction"
73-
75+
7476
- name: Upload wheel
7577
uses: actions/upload-artifact@v2
7678
with:
@@ -136,13 +138,15 @@ jobs:
136138

137139
- name: Install wheel
138140
shell: bash
139-
run: python -m pip install dist/*.whl --user
141+
run: |
142+
python -m pip install dist/*.whl --user
143+
pip freeze
140144
141145
- name: Check package can be imported
142146
run: |
143-
python3 -c "import grid2op"
144-
python3 -c "from grid2op import *"
145-
python3 -c "from grid2op.Action._backendAction import _BackendAction"
147+
python -c "import grid2op"
148+
python -c "from grid2op import *"
149+
python -c "from grid2op.Action._backendAction import _BackendAction"
146150
147151
- name: Build source archive
148152
if: matrix.config.name == 'darwin' && matrix.python.name == 'cp310'

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ grid2op/tests/requirements.txt
403403
grid2op/tests/venv_test_311/
404404
issue_577/
405405
junk.py
406+
grid2op/tests/20240429_failed_tests.txt
407+
grid2op/tests/20240429_failed_tests_small.txt
408+
grid2op/tests/20240429_teq_test.txt
409+
grid2op/tests/req_38_np121
410+
test_make_2_envs.py
411+
getting_started/env_py38_grid2op110_ray110.ipynb
412+
getting_started/env_py38_grid2op110_ray210.ipynb
406413

407414
# profiling files
408415
**.prof

CHANGELOG.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,62 @@ Change Log
3131
- [???] "asynch" multienv
3232
- [???] properly model interconnecting powerlines
3333

34+
[1.10.2] - 2024-xx-yy
35+
-------------------------
36+
- [BREAKING] the `runner.run_one_episode` now returns an extra first argument:
37+
`chron_id, chron_name, cum_reward, timestep, max_ts = runner.run_one_episode()` which
38+
is consistant with `runner.run(...)` (previously it returned only
39+
`chron_name, cum_reward, timestep, max_ts = runner.run_one_episode()`)
40+
- [BREAKING] the runner now has no `chronics_handler` attribute (`runner.chronics_handler`
41+
is not defined)
42+
- [ADDED] it is now possible to call `change_reward` directly from
43+
an observation (no need to do it from the Observation Space)
44+
- [ADDED] method to change the reward from the observation (observation_space
45+
is not needed anymore): you can use `obs.change_reward`
46+
- [ADDED] a way to automatically set the `experimental_read_from_local_dir` flags
47+
(with automatic class creation). For now it is disable by default, but you can
48+
activate it transparently (see doc)
49+
- [ADDED] possibility to set the grid to an initial state (using an action) when using the
50+
"time series" classes. The supported classes are `GridStateFromFile` - and all its derivative,
51+
`FromOneEpisodeData`, `FromMultiEpisodeData`, `FromNPY` and `FromHandlers`. The classes `ChangeNothing`
52+
and `FromChronix2grid` are not supported at the moment.
53+
- [ADDED] an "Handler" (`JSONInitStateHandler`) that can set the grid to an initial state (so as to make
54+
compatible the `FromHandlers` time series class with this new feature)
55+
- [ADDED] some more type hints in the `GridObject` class
56+
- [ADDED] Possibility to deactive the support of shunts if subclassing `PandaPowerBackend`
57+
(and add some basic tests)
58+
- [FIXED] a small issue that could lead to having
59+
"redispatching_unit_commitment_availble" flag set even if the redispatching
60+
data was not loaded correctly
61+
- [FIXED] EducPandaPowerBackend now properly sends numpy array in the class attributes
62+
(instead of pandas series)
63+
- [FIXED] an issue when loading back data (with `EpisodeData`): when there were no storage units
64+
on the grid it did not set properly the "storage relevant" class attributes
65+
- [FIXED] a bug in the "gridobj.generate_classes()" function which crashes when no
66+
grid layout was set
67+
- [FIXED] notebook 5 on loading back data with `EpisodeData`.
68+
- [FIXED] converter between backends (could not handle more than 2 busbars)
69+
- [FIXED] a bug in `BaseMultiProcessEnvironment`: set_filter had no impact
70+
- [FIXED] an issue in the `Runner` (`self.chronics_handler` was sometimes used, sometimes not
71+
and most of the time incorrectly)
72+
- [FIXED] on `RemoteEnv` class (impact all multi process environment): the kwargs used to build then backend
73+
where not used which could lead to"wrong" backends being used in the sub processes.
74+
- [FIXED] a bug when the name of the times series and the names of the elements in the backend were
75+
different: it was not possible to set `names_chronics_to_grid` correctly when calling `env.make`
76+
- [IMPROVED] documentation about `obs.simulate` to make it clearer the
77+
difference between env.step and obs.simulate on some cases
78+
- [IMPROVED] type hints on some methods of `GridObjects`
79+
- [IMPROVED] replace `np.nonzero(arr)` calls with `arr.nonzero()` which could
80+
save up a bit of computation time.
81+
- [IMPROVED] force class attributes to be numpy arrays of proper types when the
82+
classes are initialized from the backend.
83+
- [IMPROVED] some (slight) speed improvments when comparing actions or deep copying objects
84+
- [IMPROVED] the way the "grid2op compat" mode is handled
85+
- [IMPROVED] the coverage of the tests in the "test_basic_env_ls.py" to test more in depth lightsim2grid
86+
(creation of multiple environments, grid2op compatibility mode)
87+
- [IMPROVED] the function to test the backend interface in case when shunts are not supported
88+
(improved test `AAATestBackendAPI.test_01load_grid`)
89+
3490
[1.10.1] - 2024-03-xx
3591
----------------------
3692
- [FIXED] issue https://github.com/rte-france/Grid2Op/issues/593

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ WORKDIR /Grid2Op
3535
RUN git pull
3636
RUN git remote update
3737
RUN git fetch --all --tags
38-
RUN git checkout "tags/v1.10.0" -b "v1.10.0-branch"
38+
RUN git checkout "tags/v1.10.1" -b "v1.10.1-branch"
3939
# Install Dependencies
4040
RUN pip3 install .[optional,challenge]
4141
WORKDIR /

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
author = 'Benjamin Donnot'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '1.10.1.dev0'
25+
release = '1.10.2.dev3'
2626
version = '1.10'
2727

2828

docs/environment.rst

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,58 @@ increase the training time, especially at the beginning. This is due to the fact
104104
`env.reset` is called, the whole chronics is read from the hard drive. If you want to lower this
105105
impact then you might consult the :ref:`environment-module-data-pipeline` page of the doc.
106106

107+
Go to the next scenario
108+
++++++++++++++++++++++++
109+
110+
Starting grid2op 1.9.8 we attempt to make an easier user experience in the
111+
selection of time series, seed, initial state of the grid, etc.
112+
113+
All of the above can be done when calling `env.reset()` function.
114+
115+
For customizing the seed, you can for example do:
116+
117+
.. code-block:: python
118+
119+
import grid2op
120+
env_name = "l2rpn_case14_sandbox"
121+
env = grid2op.make(env_name)
122+
123+
obs = env.reset(seed=0)
124+
125+
For customizing the time series id you want to use:
126+
127+
.. code-block:: python
128+
129+
import grid2op
130+
env_name = "l2rpn_case14_sandbox"
131+
env = grid2op.make(env_name)
132+
133+
obs = env.reset(options={"time serie id": 1}) # time serie by id (sorted alphabetically)
134+
# or
135+
obs = env.reset(options={"time serie id": "0001"}) # time serie by name (folder name)
136+
137+
For customizing the initial state of the grid, for example forcing the
138+
powerline 0 to be disconnected in the initial observation:
139+
140+
.. code-block:: python
141+
142+
import grid2op
143+
env_name = "l2rpn_case14_sandbox"
144+
env = grid2op.make(env_name)
145+
146+
init_state_dict = {"set_line_status": [(0, -1)]}
147+
obs = env.reset(options={"init state": init_state_dict})
148+
149+
150+
Feel free to consult the documentation of the :func:`Environment.reset` function
151+
for more information (this doc might be outdated, the one of the function should
152+
be more up to date with the code).
153+
154+
.. info::
155+
In the near future (next few releases) we will also attempt to make the
156+
customization of the `parameters` or the `skip number of steps`, `maximum duration
157+
of the scenarios` also available in `env.reset()` options.
158+
107159
.. _environment-module-chronics-info:
108160

109161
Time series Customization
@@ -141,10 +193,15 @@ the call to "env.reset". This gives the following code:
141193
# and now the loop starts
142194
for i in range(episode_count):
143195
###################################
144-
env.set_id(THE_CHRONIC_ID)
196+
# with recent grid2op
197+
obs = env.reset(options={"time serie id": THE_CHRONIC_ID})
145198
###################################
146199
147-
obs = env.reset()
200+
###################################
201+
# 'old method (oldest grid2op version)'
202+
# env.set_id(THE_CHRONIC_ID)
203+
# obs = env.reset()
204+
###################################
148205
149206
# now play the episode as usual
150207
while True:

getting_started/05_StudyYourAgent.ipynb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
"outputs": [],
9595
"source": [
9696
"try:\n",
97+
" # use a (way) faster backend to reduce computation time\n",
98+
" # to use it, you need to install `pip install lightsim2grid`\n",
9799
" from lightsim2grid import LightSimBackend\n",
98100
" bk_cls = LightSimBackend\n",
99101
"except ImportError as exc:\n",
@@ -252,13 +254,15 @@
252254
"outputs": [],
253255
"source": [
254256
"id_line_inspected = 13\n",
255-
"actions_on_line_14 = 0\n",
257+
"actions_on_line_13 = 0\n",
256258
"for act in this_episode.actions:\n",
257259
" dict_ = act.effect_on(line_id=id_line_inspected) # which effect has this action action on the substation with given id\n",
258260
" # other objects are: load_id, gen_id, line_id or substation_id\n",
259261
" if dict_['change_line_status'] or dict_[\"set_line_status\"] != 0:\n",
260-
" actions_on_line_14 += 1\n",
261-
"print(f'Total actions on powerline 14 : {actions_on_line_14}')"
262+
" actions_on_line_13 += 1\n",
263+
"print(f\"Total actions on powerline 13 (named \"\n",
264+
" f\"{type(env).name_line[id_line_inspected]}): \"\n",
265+
" f\"{actions_on_line_13}\")\n"
262266
]
263267
},
264268
{

0 commit comments

Comments
 (0)