Skip to content

Commit

Permalink
Merge pull request #611 from rte-france/dev_1.10.2
Browse files Browse the repository at this point in the history
Version 1.10.2
  • Loading branch information
BDonnot authored May 27, 2024
2 parents 31d1eb2 + c9de7aa commit 30e2068
Show file tree
Hide file tree
Showing 203 changed files with 10,275 additions and 1,061 deletions.
22 changes: 11 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
grid2op.testinstall
legacy_lightsim:
executor: python38
executor: python38 # needs to be 38: whl of lightsim were not released for 3.10 at the time
resource_class: small
steps:
- checkout
Expand Down Expand Up @@ -205,13 +205,13 @@ jobs:
command: |
export _GRID2OP_FORCE_TEST=1
source venv_test/bin/activate
python -m pip install -U pip setuptools wheel
python -m pip install chronix2grid>="1.1.0.post1"
python -m pip install -U pip setuptools wheel "numpy>=1.20,<1.21" "pandas<2.2" "scipy==1.10.1" numba
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"
python -m pip uninstall -y grid2op
- run:
command: |
command: | # issue with previous more simple install, so I fix some versions
source venv_test/bin/activate
python -m pip install -U "numpy>=1.20,<1.21" "pandas<2.2" "scipy<1.12" numba .[test]
python -m pip install "numpy>=1.20,<1.21" "pandas<2.2" "scipy==1.10.1" numba .
pip freeze
- run:
command: |
Expand All @@ -222,7 +222,7 @@ jobs:
- run:
command: |
source venv_test/bin/activate
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba .[test]
python -m pip install "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba
pip freeze
- run:
command: |
Expand Down Expand Up @@ -250,7 +250,7 @@ jobs:
- run:
command: |
source venv_test/bin/activate
python -m pip install -U "numpy>=1.21,<1.22" "pandas<2.2" "scipy<1.12" numba .[test]
python -m pip install -U "numpy>=1.21,<1.22" "pandas<2.2" "scipy<1.12" numba .
pip freeze
- run:
command: |
Expand All @@ -261,7 +261,7 @@ jobs:
- run:
command: |
source venv_test/bin/activate
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba .[test]
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba
pip freeze
- run:
command: |
Expand All @@ -288,7 +288,7 @@ jobs:
- run:
command: |
source venv_test/bin/activate
python -m pip install -U "numpy>=1.23,<1.24" "pandas<2.2" "scipy<1.12" numba .[test]
python -m pip install -U "numpy>=1.23,<1.24" "pandas<2.2" "scipy<1.12" numba .
pip freeze
- run:
command: |
Expand All @@ -299,7 +299,7 @@ jobs:
- run:
command: |
source venv_test/bin/activate
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba .[test]
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" numba
pip freeze
- run:
command: |
Expand All @@ -326,7 +326,7 @@ jobs:
- run:
command: |
source venv_test/bin/activate
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" .[test]
python -m pip install -U "numpy>=1.26,<1.27" "pandas<2.2" "scipy<1.12" .
pip freeze
- run:
command: |
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ jobs:
# auditwheel repair dist/*.whl # only for compiled code !
- name: Install wheel
run: pip3 install dist/*.whl --user
run: |
pip3 install dist/*.whl
pip freeze
- name: Check package can be imported
run: |
python3 -c "import grid2op"
python3 -c "from grid2op import *"
python3 -c "from grid2op.Action._backendAction import _BackendAction"
- name: Upload wheel
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -136,13 +138,15 @@ jobs:

- name: Install wheel
shell: bash
run: python -m pip install dist/*.whl --user
run: |
python -m pip install dist/*.whl --user
pip freeze
- name: Check package can be imported
run: |
python3 -c "import grid2op"
python3 -c "from grid2op import *"
python3 -c "from grid2op.Action._backendAction import _BackendAction"
python -c "import grid2op"
python -c "from grid2op import *"
python -c "from grid2op.Action._backendAction import _BackendAction"
- name: Build source archive
if: matrix.config.name == 'darwin' && matrix.python.name == 'cp310'
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,13 @@ grid2op/tests/requirements.txt
grid2op/tests/venv_test_311/
issue_577/
junk.py
grid2op/tests/20240429_failed_tests.txt
grid2op/tests/20240429_failed_tests_small.txt
grid2op/tests/20240429_teq_test.txt
grid2op/tests/req_38_np121
test_make_2_envs.py
getting_started/env_py38_grid2op110_ray110.ipynb
getting_started/env_py38_grid2op110_ray210.ipynb

# profiling files
**.prof
66 changes: 65 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,71 @@ Change Log
- [???] "asynch" multienv
- [???] properly model interconnecting powerlines

[1.10.1] - 2024-03-18
[1.10.2] - 2024-05-27
-------------------------
- [BREAKING] the `runner.run_one_episode` now returns an extra first argument:
`chron_id, chron_name, cum_reward, timestep, max_ts = runner.run_one_episode()` which
is consistant with `runner.run(...)` (previously it returned only
`chron_name, cum_reward, timestep, max_ts = runner.run_one_episode()`)
- [BREAKING] the runner now has no `chronics_handler` attribute (`runner.chronics_handler`
is not defined)
- [BREAKING] now grid2op forces everything to be connected at busbar 1 if
`param.IGNORE_INITIAL_STATE_TIME_SERIE == True` (**NOT** the default) and
no initial state is provided in `env.reset(..., options={"init state": ...})`
- [ADDED] it is now possible to call `change_reward` directly from
an observation (no need to do it from the Observation Space)
- [ADDED] method to change the reward from the observation (observation_space
is not needed anymore): you can use `obs.change_reward`
- [ADDED] a way to automatically set the `experimental_read_from_local_dir` flags
(with automatic class creation). For now it is disable by default, but you can
activate it transparently (see doc)
- [ADDED] possibility to set the grid to an initial state (using an action) when using the
"time series" classes. The supported classes are `GridStateFromFile` - and all its derivative,
`FromOneEpisodeData`, `FromMultiEpisodeData`, `FromNPY` and `FromHandlers`. The classes `ChangeNothing`
and `FromChronix2grid` are not supported at the moment.
- [ADDED] an "Handler" (`JSONInitStateHandler`) that can set the grid to an initial state (so as to make
compatible the `FromHandlers` time series class with this new feature)
- [ADDED] some more type hints in the `GridObject` class
- [ADDED] Possibility to deactive the support of shunts if subclassing `PandaPowerBackend`
(and add some basic tests)
- [ADDED] a parameters (`param.IGNORE_INITIAL_STATE_TIME_SERIE`) which defaults to
`False` that tells the environment whether it should ignore the
initial state of the grid provided in the time series.
By default it is NOT ignored, it is taken into account
(for the environment that supports this feature)
- [FIXED] a small issue that could lead to having
"redispatching_unit_commitment_availble" flag set even if the redispatching
data was not loaded correctly
- [FIXED] EducPandaPowerBackend now properly sends numpy array in the class attributes
(instead of pandas series)
- [FIXED] an issue when loading back data (with `EpisodeData`): when there were no storage units
on the grid it did not set properly the "storage relevant" class attributes
- [FIXED] a bug in the "gridobj.generate_classes()" function which crashes when no
grid layout was set
- [FIXED] notebook 5 on loading back data with `EpisodeData`.
- [FIXED] converter between backends (could not handle more than 2 busbars)
- [FIXED] a bug in `BaseMultiProcessEnvironment`: set_filter had no impact
- [FIXED] an issue in the `Runner` (`self.chronics_handler` was sometimes used, sometimes not
and most of the time incorrectly)
- [FIXED] on `RemoteEnv` class (impact all multi process environment): the kwargs used to build then backend
where not used which could lead to"wrong" backends being used in the sub processes.
- [FIXED] a bug when the name of the times series and the names of the elements in the backend were
different: it was not possible to set `names_chronics_to_grid` correctly when calling `env.make`
- [IMPROVED] documentation about `obs.simulate` to make it clearer the
difference between env.step and obs.simulate on some cases
- [IMPROVED] type hints on some methods of `GridObjects`
- [IMPROVED] replace `np.nonzero(arr)` calls with `arr.nonzero()` which could
save up a bit of computation time.
- [IMPROVED] force class attributes to be numpy arrays of proper types when the
classes are initialized from the backend.
- [IMPROVED] some (slight) speed improvments when comparing actions or deep copying objects
- [IMPROVED] the way the "grid2op compat" mode is handled
- [IMPROVED] the coverage of the tests in the "test_basic_env_ls.py" to test more in depth lightsim2grid
(creation of multiple environments, grid2op compatibility mode)
- [IMPROVED] the function to test the backend interface in case when shunts are not supported
(improved test `AAATestBackendAPI.test_01load_grid`)

[1.10.1] - 2024-03-xx
----------------------
- [FIXED] issue https://github.com/rte-france/Grid2Op/issues/593
- [FIXED] backward compatibility issues with "oldest" lightsim2grid versions
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.1'
release = '1.10.2.dev3'
version = '1.10'


Expand Down
61 changes: 59 additions & 2 deletions docs/environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,58 @@ increase the training time, especially at the beginning. This is due to the fact
`env.reset` is called, the whole chronics is read from the hard drive. If you want to lower this
impact then you might consult the :ref:`environment-module-data-pipeline` page of the doc.

Go to the next scenario
++++++++++++++++++++++++

Starting grid2op 1.9.8 we attempt to make an easier user experience in the
selection of time series, seed, initial state of the grid, etc.

All of the above can be done when calling `env.reset()` function.

For customizing the seed, you can for example do:

.. code-block:: python
import grid2op
env_name = "l2rpn_case14_sandbox"
env = grid2op.make(env_name)
obs = env.reset(seed=0)
For customizing the time series id you want to use:

.. code-block:: python
import grid2op
env_name = "l2rpn_case14_sandbox"
env = grid2op.make(env_name)
obs = env.reset(options={"time serie id": 1}) # time serie by id (sorted alphabetically)
# or
obs = env.reset(options={"time serie id": "0001"}) # time serie by name (folder name)
For customizing the initial state of the grid, for example forcing the
powerline 0 to be disconnected in the initial observation:

.. code-block:: python
import grid2op
env_name = "l2rpn_case14_sandbox"
env = grid2op.make(env_name)
init_state_dict = {"set_line_status": [(0, -1)]}
obs = env.reset(options={"init state": init_state_dict})
Feel free to consult the documentation of the :func:`Environment.reset` function
for more information (this doc might be outdated, the one of the function should
be more up to date with the code).

.. info::
In the near future (next few releases) we will also attempt to make the
customization of the `parameters` or the `skip number of steps`, `maximum duration
of the scenarios` also available in `env.reset()` options.

.. _environment-module-chronics-info:

Time series Customization
Expand Down Expand Up @@ -141,10 +193,15 @@ the call to "env.reset". This gives the following code:
# and now the loop starts
for i in range(episode_count):
###################################
env.set_id(THE_CHRONIC_ID)
# with recent grid2op
obs = env.reset(options={"time serie id": THE_CHRONIC_ID})
###################################
obs = env.reset()
###################################
# 'old method (oldest grid2op version)'
# env.set_id(THE_CHRONIC_ID)
# obs = env.reset()
###################################
# now play the episode as usual
while True:
Expand Down
10 changes: 7 additions & 3 deletions getting_started/05_StudyYourAgent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
"outputs": [],
"source": [
"try:\n",
" # use a (way) faster backend to reduce computation time\n",
" # to use it, you need to install `pip install lightsim2grid`\n",
" from lightsim2grid import LightSimBackend\n",
" bk_cls = LightSimBackend\n",
"except ImportError as exc:\n",
Expand Down Expand Up @@ -252,13 +254,15 @@
"outputs": [],
"source": [
"id_line_inspected = 13\n",
"actions_on_line_14 = 0\n",
"actions_on_line_13 = 0\n",
"for act in this_episode.actions:\n",
" dict_ = act.effect_on(line_id=id_line_inspected) # which effect has this action action on the substation with given id\n",
" # other objects are: load_id, gen_id, line_id or substation_id\n",
" if dict_['change_line_status'] or dict_[\"set_line_status\"] != 0:\n",
" actions_on_line_14 += 1\n",
"print(f'Total actions on powerline 14 : {actions_on_line_14}')"
" actions_on_line_13 += 1\n",
"print(f\"Total actions on powerline 13 (named \"\n",
" f\"{type(env).name_line[id_line_inspected]}): \"\n",
" f\"{actions_on_line_13}\")\n"
]
},
{
Expand Down
Loading

0 comments on commit 30e2068

Please sign in to comment.