Skip to content

Commit

Permalink
Merge pull request #55 from rte-france/bd-dev
Browse files Browse the repository at this point in the history
Version 0.7.0
  • Loading branch information
BDonnot authored Jul 13, 2023
2 parents 35dafe8 + b5eacde commit 6dfa829
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Change Log
- train sowhere a working baseline (that does better than do nothing)
- show an example of a baseline that uses a GNN

[0.7.0] - 2023-07-13
------------------------
- [ADDED] the "topo oracle agent" (contrib)
- [ADDED] the "curriculumagent" (contrib)

[0.6.0.post1] - 2022-07-05
---------------------------
- [FIXED] issue with the `PPO_SB3` agent when using a runner, particularly when no "heuristic" are
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ We welcome contributions: see the [contribute guide](/CONTRIBUTE.md) for details

# Get started with a baseline

Say you want to know how you compared with the "DoubleDuelingDQN" baseline implementation in this repository (for the
Say you want to know how you compared with the "PPO_SB3" baseline implementation in this repository (for the
sake of this example).

## Train it (optional)
As no weights are provided for this baselines by default (yet), you will first need to train such a baseline:

```python
import grid2op
from l2rpn_baselines.DoubleDuelingDQN import train
env = grid2op.make()
from l2rpn_baselines.PPO_SB3 import train
env = grid2op.make("l2rpn_case14_sandbox")
res = train(env, save_path="THE/PATH/TO/SAVE/IT", iterations=100)
```

Expand All @@ -46,9 +46,9 @@ Once trained, you can reload it and evaluate its performance with the provided "

```python
import grid2op
from l2rpn_baselines.DoubleDuelingDQN import evaluate
env = grid2op.make()
res = evaluate(env, load_path="THE/PATH/TO/LOAD/IT.h5", nb_episode=10)
from l2rpn_baselines.PPO_SB3 import evaluate
env = grid2op.make("l2rpn_case14_sandbox")
res = evaluate(env, load_path="THE/PATH/TO/LOAD/IT", nb_episode=10)
```

You can have more information about extra argument of the "evaluate" function in the
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
author = 'Benjamin DONNOT'

# The full version, including alpha/beta/rc tags
release = '0.6.0.post1'
version = '0.6'
release = '0.7.0'
version = '0.7'

# -- General configuration ---------------------------------------------------

Expand Down
13 changes: 13 additions & 0 deletions docs/ppo_stable_baselines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ For example, to create an agent **from scratch**, with some parameters:
You should probably train it before hand (see the `train` function)


Caveats
+++++++++

Be carefull, at time of writing, there is a migration from all major RL packages
from the legacy "open ai gym" api to the more recent "gymanisium" api.

This transition will happen soon in grid2op too. But for now, and not to
break legacy code that might have worked on previous L2RPN competitions, the
switch from gym to gymanisium is not yet made.

This means that installing stable-baselines3 might cause some issues with grid2op
and l2rpn baselines due to the gym / gymanisium migration.

Detailed documentation
++++++++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion l2rpn_baselines/__init__.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 L2RPN Baselines, L2RPN Baselines a repository to host baselines for l2rpn competitions.

__version__ = "0.6.0.post1"
__version__ = "0.7.0"

all_baselines_li = [
"Template",
Expand Down
38 changes: 38 additions & 0 deletions l2rpn_baselines/test/test_train_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@
except ImportError as exc_:
has_ppo_sb3 = exc_

try:
from l2rpn_baselines.CurriculumAgent import train as train_curiculum_agent
from l2rpn_baselines.CurriculumAgent import evaluate as eval_curiculum_agent
has_curiculum = None
except ImportError as exc_:
has_curiculum = exc_



class TestDeepQSimple(unittest.TestCase):
def setUp(self) -> None:
Expand Down Expand Up @@ -724,5 +732,35 @@ def test_train_eval(self):
assert eval_res is not None


class TestCuriculumAgent(unittest.TestCase):
def test_train_eval(self):
tmp_dir = tempfile.mkdtemp()
if has_curiculum is not None:
raise ImportError(f"CuriculumAgent is not available with error:\n{has_curiculum}")

with warnings.catch_warnings():
warnings.filterwarnings("ignore")
env = grid2op.make("l2rpn_case14_sandbox", test=True)
nm_ = "TestCuriculumAgent"

train_curiculum_agent(env,
name=nm_,
iterations=1,
save_path=tmp_dir,
load_path=None,
learning_rate=1e-4,
verbose=False)

agent, eval_res = eval_curiculum_agent(env,
load_path=tmp_dir,
name=nm_,
logs_path=tmp_dir,
nb_episode=1,
nb_process=1,
max_steps=10,
verbose=False,
save_gif=False)
assert eval_res is not None

if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import setuptools
from setuptools import setup
__version__ = "0.6.0.post1"
__version__ = "0.7.0"


pkgs = {
Expand Down

0 comments on commit 6dfa829

Please sign in to comment.