From 9fa6eb64c0da296ad63db0e16e2537e935416918 Mon Sep 17 00:00:00 2001 From: DONNOT Benjamin Date: Mon, 19 Jun 2023 11:47:07 +0200 Subject: [PATCH 1/2] fixing some errors / deprecation in the docs and the readme --- README.md | 12 ++++++------ docs/ppo_stable_baselines.rst | 13 +++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 42881c0..3b00171 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ 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) @@ -33,8 +33,8 @@ As no weights are provided for this baselines by default (yet), you will first n ```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) ``` @@ -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 diff --git a/docs/ppo_stable_baselines.rst b/docs/ppo_stable_baselines.rst index 74001a6..d56bc31 100644 --- a/docs/ppo_stable_baselines.rst +++ b/docs/ppo_stable_baselines.rst @@ -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 ++++++++++++++++++++++++ From b5eacde68b3f4e044c5effd8cb71624fa467bb2a Mon Sep 17 00:00:00 2001 From: DONNOT Benjamin Date: Thu, 13 Jul 2023 13:59:28 +0200 Subject: [PATCH 2/2] can version 0.7.0 be released --- CHANGELOG.rst | 5 ++++ docs/conf.py | 4 +-- l2rpn_baselines/__init__.py | 2 +- l2rpn_baselines/test/test_train_eval.py | 38 +++++++++++++++++++++++++ setup.py | 2 +- 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d2fe2a4..b89cc39 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 diff --git a/docs/conf.py b/docs/conf.py index 9bd209a..ba530be 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 --------------------------------------------------- diff --git a/l2rpn_baselines/__init__.py b/l2rpn_baselines/__init__.py index 8ad0191..387404f 100644 --- a/l2rpn_baselines/__init__.py +++ b/l2rpn_baselines/__init__.py @@ -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", diff --git a/l2rpn_baselines/test/test_train_eval.py b/l2rpn_baselines/test/test_train_eval.py index 6534be8..c63f9e9 100644 --- a/l2rpn_baselines/test/test_train_eval.py +++ b/l2rpn_baselines/test/test_train_eval.py @@ -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: @@ -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() diff --git a/setup.py b/setup.py index 18d3412..83327b3 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ import setuptools from setuptools import setup -__version__ = "0.6.0.post1" +__version__ = "0.7.0" pkgs = {