Skip to content

Commit

Permalink
Merge pull request #260 from rte-france/dev_1.6.4
Browse files Browse the repository at this point in the history
Upgrade to version 1.6.4
  • Loading branch information
BDonnot committed Nov 8, 2021
2 parents e2f8af9 + fa3fa5a commit 52d2a45
Show file tree
Hide file tree
Showing 80 changed files with 1,687 additions and 322 deletions.
41 changes: 40 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ executors:
python39:
docker:
- image: python:3.9-slim-buster
python310:
docker:
- image: python:3.10-slim-buster

jobs:
test:
executor: grid2op-executor
resource_class: medium
parallelism: 4
steps:
- checkout
Expand All @@ -31,6 +35,7 @@ jobs:
python3 -m unittest $(cat /tmp/tests_run)
install36:
executor: python36
resource_class: small
steps:
- checkout
- run: python -m pip install virtualenv
Expand All @@ -50,6 +55,7 @@ jobs:
grid2op.testinstall
install37:
executor: python37
resource_class: small
steps:
- checkout
- run: python -m pip install virtualenv
Expand All @@ -73,8 +79,15 @@ jobs:
pip install -U "numpy>=1.20,<1.21"
pip install -U .[test]
grid2op.testinstall
- run:
command: |
source venv_test/bin/activate
pip install -U "numpy>=1.21,<1.22"
pip install -U .[test]
grid2op.testinstall
install38:
executor: python38
resource_class: small
steps:
- checkout
- run: python -m pip install virtualenv
Expand All @@ -98,8 +111,16 @@ jobs:
pip install -U "numpy>=1.20,<1.21"
pip install -U .[test]
grid2op.testinstall
- run:
command: |
source venv_test/bin/activate
pip install -U "numpy>=1.21,<1.22"
pip install -U .[test]
grid2op.testinstall
install39:
executor: python39
resource_class: small
steps:
- checkout
- run: python -m pip install virtualenv
Expand All @@ -116,6 +137,25 @@ jobs:
pip install -U "numpy>=1.20,<1.21"
pip install -U .[test]
grid2op.testinstall
- run:
command: |
source venv_test/bin/activate
pip install -U "numpy>=1.21,<1.22"
pip install -U .[test]
grid2op.testinstall
install310:
executor: python310
resource_class: small
steps:
- checkout
- run: python -m pip install virtualenv
- run: python -m virtualenv venv_test
- run:
command: |
source venv_test/bin/activate
pip install -U "numpy>=1.21"
pip install -U .[test]
grid2op.testinstall
workflows:
version: 2.1
Expand All @@ -124,7 +164,6 @@ workflows:
- test
install:
jobs:
- install36
- install37
- install38
- install39
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ test_parallel_grid2op_bug
test_grid2op_legalact
parallel_grid2op2.tgz
parallel_grid2op_example.tgz
Idontcare.json
test_json_gamover.py
test_other_reward.py
find_dc_coeff.py
test_hash_windows_linux.py
test_n1_reward.py
test_copy_env_close.py
!grid2op/tests/test_copy_env_close.py

# profiling files
**.prof
27 changes: 27 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,33 @@ Change Log
- [???] "asynch" multienv
- [???] properly model interconnecting powerlines

[1.6.4] - 2021-11-08
---------------------
- [BREAKING] the name of the python file for the "agent" module are now lowercase (complient with PEP). If you
did things like `from grid2op.Agent.BaseAgent import BaseAgent` you need to change it like
`from grid2op.Agent.baseAgent import BaseAgent` or even better, and this is the preferred way to include
them: `from grid2op.Agent import BaseAgent` It should not affect lots of code.
- [FIXED] a bug where the shunt had a voltage when disconnected using pandapower backend
- [FIXED] a bug preventing to print the action space if some "part" of it had no size (empty action space)
- [FIXED] a bug preventing to copy an action properly (especially for the alarm)
- [FIXED] a bug that did not "close" the backend of the observation space when the environment was `closed`. This
might be related to `Issue#245 <https://github.com/rte-france/Grid2Op/issues/255>`_
- [ADDED] serialization of `current_iter` and `max_iter` in the observation.
- [ADDED] the possibility to use the runner only on certain episode id
(see `runner.run(..., episode_id=[xxx, yyy, ...])`)
- [ADDED] a function that returns if an action has any change to modify the grid see `act.can_affect_something()`
- [ADDED] a ttype of agent that performs predefined actions from a given list
- [ADDED] basic support for logging in environment and runner (more coming soon)
- [ADDED] possibility to make an environment with an implementation of a reward, instead of relying on a reward class.
- [ADDED] a possible implementation of a N-1 reward
- [IMPROVED] right time stamp is now set in the observation after the game over.
- [IMPROVED] correct current number of steps when the observation is set to a game over state.
- [IMPROVED] documentation to clearly state that the action_class should not be modified.
- [IMPROVED] possibility to tell which chronics to use with the result of `env.chronics_handler.get_id()` (this is also
compatible in the runner)
- [IMPROVED] it is no more possible to call "env.reset()" or "env.step()" after an environment has been closed: a clean error
is raised in this case.

[1.6.3] - 2021-08-21
--------------------
- [FIXED] a bug that allowed to use wrongly the function `backend.get_action_to_set()` even when the backend
Expand Down
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ Official documentation: the official documentation is available at
* [2 BaseAction Grid Manipulation](getting_started/2_Action_GridManipulation.ipynb)
* [3 Training An BaseAgent](getting_started/3_TrainingAnAgent.ipynb)
* [4 Study Your BaseAgent](getting_started/4_StudyYourAgent.ipynb)
* [4 Documentation](#documentation)
* [5 Test and known issues](#tests-and-known-issues)
* [6 License information](#license-information)
* [4_Citing](#Citing)
* [5 Documentation](#documentation)
* [6 Test and known issues](#tests-and-known-issues)
* [7 License information](#license-information)

# Installation
## Requirements:
Expand Down Expand Up @@ -189,6 +190,20 @@ anything with the help of mybinder:

Or thanks to google colab (all links are provided near the notebook description)

# Citing

If you use this package in one of your work, please cite:
```
@misc{grid2op,
author = {B. Donnot},
title = {{Grid2op- A testbed platform to model sequential decision making in power systems. }},
year = {2020},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://GitHub.com/rte-france/grid2op}},
}
```

# Documentation

The official documentation is available at
Expand Down Expand Up @@ -231,7 +246,6 @@ Grid2op is currently tested on windows, linux and macos.

The unit tests includes testing, on linux machines the correct integration of grid2op with:

- python 3.6
- python 3.7
- python 3.8
- python 3.9
Expand Down
2 changes: 2 additions & 0 deletions binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ dependencies:
- keras
- seaborn
- plotly
- imageio
- ray[rllib, default]
6 changes: 6 additions & 0 deletions docs/makeenv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ context of the L2RPN competition, we don't recommend to modify them.
More information about the "customization" of the environment, especially to optimize the I/O or to manipulate
which data you interact with are available in the :ref:`environment-module` module (:ref:`environment-module-usage` section).


.. warning:: Don't modify the action class

We do not recommend to modify the keyword arguments starting with \*, and especially the action_class.


Detailed Documentation by class
--------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"outputs": [],
"source": [
"import sys\n",
"# !$sys.executable install grid2op[optional] # for use with google colab (grid2Op is not installed by default)\n",
"# !$sys.executable -m pip install grid2op[optional] # for use with google colab (grid2Op is not installed by default)\n",
"# !$sys.executable -m pip install stable-baselines3 'ray[rllib]' tf_agents"
]
},
Expand Down
11 changes: 11 additions & 0 deletions grid2op/Action/ActionSpace.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,14 @@ def copy(self):
res = my_cls.__new__(my_cls)
self._custom_deepcopy_for_copy(res)
return res

def close(self):
"""
INTERNAL
.. warning:: /!\\\\ Internal, do not use unless you know what you are doing /!\\\\
Make sure all references to possible backends are closed. This is not used here in general but might be for some specific cases.
"""
pass
20 changes: 19 additions & 1 deletion grid2op/Action/BaseAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def _aux_copy(self, other):

attr_vect = ["_set_line_status", "_switch_line_status", "_set_topo_vect",
"_change_bus_vect", "_hazards", "_maintenance", "_redispatch",
"_storage_power", "_curtail"]
"_storage_power", "_curtail", "_raise_alarm"]

if self.shunts_data_available:
attr_vect += ["shunt_p", "shunt_q", "shunt_bus"]
Expand Down Expand Up @@ -547,6 +547,24 @@ def _reset_modified_flags(self):
self._modif_curtailment = False
self._modif_alarm = False

def can_affect_something(self):
"""
This functions returns True if the current action has any chance to change the grid.
Notes
-----
This does not say however if the action will indeed modify something somewhere !
"""
return (self._modif_inj or
self._modif_set_bus or
self._modif_change_bus or
self._modif_set_status or
self._modif_change_status or
self._modif_redispatch or
self._modif_storage or
self._modif_curtailment or
self._modif_alarm)

def _get_array_from_attr_name(self, attr_name):
if hasattr(self, attr_name):
res = super()._get_array_from_attr_name(attr_name)
Expand Down
34 changes: 22 additions & 12 deletions grid2op/Agent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Copyright (c) 2019-2020, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
# This file is part of Grid2Game, Grid2Game a gamified platform to interact with grid2op environments.

__all__ = [
"BaseAgent",
"DoNothingAgent",
Expand All @@ -9,17 +17,19 @@
"RandomAgent",
"DeltaRedispatchRandomAgent",
"MLAgent",
"RecoPowerlineAgent"
"RecoPowerlineAgent",
"FromActionsListAgent"
]

from grid2op.Agent.BaseAgent import BaseAgent
from grid2op.Agent.DoNothing import DoNothingAgent
from grid2op.Agent.OneChangeThenNothing import OneChangeThenNothing
from grid2op.Agent.GreedyAgent import GreedyAgent
from grid2op.Agent.PowerlineSwitch import PowerLineSwitch
from grid2op.Agent.TopologyGreedy import TopologyGreedy
from grid2op.Agent.AgentWithConverter import AgentWithConverter
from grid2op.Agent.RandomAgent import RandomAgent
from grid2op.Agent.DeltaRedispatchRandomAgent import DeltaRedispatchRandomAgent
from grid2op.Agent.MLAgent import MLAgent
from grid2op.Agent.RecoPowerlineAgent import RecoPowerlineAgent
from grid2op.Agent.baseAgent import BaseAgent
from grid2op.Agent.doNothing import DoNothingAgent
from grid2op.Agent.oneChangeThenNothing import OneChangeThenNothing
from grid2op.Agent.greedyAgent import GreedyAgent
from grid2op.Agent.powerlineSwitch import PowerLineSwitch
from grid2op.Agent.topologyGreedy import TopologyGreedy
from grid2op.Agent.agentWithConverter import AgentWithConverter
from grid2op.Agent.randomAgent import RandomAgent
from grid2op.Agent.deltaRedispatchRandomAgent import DeltaRedispatchRandomAgent
from grid2op.Agent.mlAgent import MLAgent
from grid2op.Agent.recoPowerlineAgent import RecoPowerlineAgent
from grid2op.Agent.fromActionsListAgent import FromActionsListAgent
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from grid2op.Converter import Converter
from grid2op.Exceptions import Grid2OpException
from grid2op.Agent.BaseAgent import BaseAgent
from grid2op.Agent.baseAgent import BaseAgent


class AgentWithConverter(BaseAgent):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# This file is part of Grid2Op, Grid2Op a testbed platform to model sequential decision making in power systems.

import numpy as np
from grid2op.Agent import BaseAgent
from grid2op.Agent.baseAgent import BaseAgent


class DeltaRedispatchRandomAgent(BaseAgent):
Expand Down
2 changes: 1 addition & 1 deletion grid2op/Agent/DoNothing.py → grid2op/Agent/doNothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# SPDX-License-Identifier: MPL-2.0
# This file is part of Grid2Op, Grid2Op a testbed platform to model sequential decision making in power systems.

from grid2op.Agent.BaseAgent import BaseAgent
from grid2op.Agent.baseAgent import BaseAgent


class DoNothingAgent(BaseAgent):
Expand Down

0 comments on commit 52d2a45

Please sign in to comment.