From 7f98df9df25120bee22a5edbbe653b7373fcbab2 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Thu, 17 Aug 2023 23:01:59 +0200 Subject: [PATCH] Release v2.1.0 (#395) * Release v2.1.0 * Fix mypy --- CHANGELOG.md | 6 +++++- Makefile | 2 +- docs/conf.py | 18 +----------------- requirements.txt | 8 ++++---- rl_zoo3/gym_patches.py | 2 +- rl_zoo3/plots/plot_from_file.py | 2 +- rl_zoo3/utils.py | 4 ++-- rl_zoo3/version.txt | 2 +- setup.py | 6 +++--- tests/test_hyperparams_opt.py | 2 +- 10 files changed, 20 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47ebcb5b9..029e8d1b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ -## Release 2.1.0a0 (WIP) +## Release 2.1.0 (2023-08-17) ### Breaking Changes - Dropped python 3.7 support - SB3 now requires PyTorch 1.13+ +- Upgraded to SB3 >= 2.1.0 +- Upgraded to Huggingface-SB3 >= 2.3 +- Upgraded to Optuna >= 3.0 +- Upgraded to cloudpickle >= 2.2.1 ### New Features - Added python 3.11 support diff --git a/Makefile b/Makefile index e216d35ed..003480cfc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -LINT_PATHS = *.py tests/ scripts/ rl_zoo3/ hyperparams/python/*.py +LINT_PATHS = *.py tests/ scripts/ rl_zoo3/ hyperparams/python/*.py docs/conf.py # Run pytest and coverage report pytest: diff --git a/docs/conf.py b/docs/conf.py index 3f0348af7..c94251cb1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,8 +13,7 @@ # import os import sys -from typing import Dict, List -from unittest.mock import MagicMock +from typing import Dict # We CANNOT enable 'sphinxcontrib.spelling' because ReadTheDocs.org does not support # PyEnchant. @@ -37,21 +36,6 @@ sys.path.insert(0, os.path.abspath("..")) -class Mock(MagicMock): - __subclasses__ = [] # type: ignore - - @classmethod - def __getattr__(cls, name): - return MagicMock() - - -# Mock modules that requires C modules -# Note: because of that we cannot test examples using CI -# 'torch', 'torch.nn', 'torch.nn.functional', -# DO not mock modules for now, we will need to do that for read the docs later -MOCK_MODULES: List[str] = [] -sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) - # Read version from file version_file = os.path.join(os.path.dirname(__file__), "../rl_zoo3", "version.txt") with open(version_file) as file_handler: diff --git a/requirements.txt b/requirements.txt index 28b49e8a7..73c9904a5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ gym==0.26.2 -stable-baselines3[extra_no_roms,tests,docs]>=2.0.0 -sb3-contrib>=2.0.0 +stable-baselines3[extra_no_roms,tests,docs]>=2.1.0 +sb3-contrib>=2.1.0 box2d-py==2.3.8 pybullet # minigrid @@ -8,13 +8,13 @@ pybullet optuna~=3.0 pytablewriter~=0.64 pyyaml>=5.1 -cloudpickle>=1.5.0 +cloudpickle>=2.2.1 plotly # need to upgrade to gymnasium: # panda-gym~=3.0.1 rliable>=1.0.5 wandb -huggingface_sb3>=2.2.5 +huggingface_sb3>=2.3 seaborn tqdm rich diff --git a/rl_zoo3/gym_patches.py b/rl_zoo3/gym_patches.py index 2d2187577..84d262172 100644 --- a/rl_zoo3/gym_patches.py +++ b/rl_zoo3/gym_patches.py @@ -89,4 +89,4 @@ def step(self, action): # Patch Gymnasium TimeLimit gymnasium.wrappers.TimeLimit = PatchedTimeLimit # type: ignore[misc] gymnasium.wrappers.time_limit.TimeLimit = PatchedTimeLimit # type: ignore[misc] -gymnasium.envs.registration.TimeLimit = PatchedTimeLimit # type: ignore[misc] +gymnasium.envs.registration.TimeLimit = PatchedTimeLimit # type: ignore[misc,attr-defined] diff --git a/rl_zoo3/plots/plot_from_file.py b/rl_zoo3/plots/plot_from_file.py index 1af98cc47..9c007cc23 100644 --- a/rl_zoo3/plots/plot_from_file.py +++ b/rl_zoo3/plots/plot_from_file.py @@ -98,7 +98,7 @@ def plot_from_file(): # noqa: C901 for new_key in results_2[key].keys(): results[key][new_key] = results_2[key][new_key] - keys = [key for key in results[list(results.keys())[0]].keys() if key not in args.skip_keys] + keys = [key for key in results[next(iter(results.keys()))].keys() if key not in args.skip_keys] print(f"keys: {keys}") if len(args.keep_keys) > 0: keys = [key for key in keys if key in args.keep_keys] diff --git a/rl_zoo3/utils.py b/rl_zoo3/utils.py index 720aad08f..42563d859 100644 --- a/rl_zoo3/utils.py +++ b/rl_zoo3/utils.py @@ -95,7 +95,7 @@ def get_class_name(wrapper_name): "You should check the indentation." ) wrapper_dict = wrapper_name - wrapper_name = list(wrapper_dict.keys())[0] + wrapper_name = next(iter(wrapper_dict.keys())) kwargs = wrapper_dict[wrapper_name] else: kwargs = {} @@ -178,7 +178,7 @@ def get_callback_list(hyperparams: Dict[str, Any]) -> List[BaseCallback]: "You should check the indentation." ) callback_dict = callback_name - callback_name = list(callback_dict.keys())[0] + callback_name = next(iter(callback_dict.keys())) kwargs = callback_dict[callback_name] else: kwargs = {} diff --git a/rl_zoo3/version.txt b/rl_zoo3/version.txt index ecaf4eea7..7ec1d6db4 100644 --- a/rl_zoo3/version.txt +++ b/rl_zoo3/version.txt @@ -1 +1 @@ -2.1.0a0 +2.1.0 diff --git a/setup.py b/setup.py index c82de4bd6..bc7b58ba2 100644 --- a/setup.py +++ b/setup.py @@ -27,12 +27,12 @@ }, entry_points={"console_scripts": ["rl_zoo3=rl_zoo3.cli:main"]}, install_requires=[ - "sb3_contrib>=2.0.0", + "sb3_contrib>=2.1.0", "gym==0.26.2", # for patches to make gym backward compat - "huggingface_sb3>=2.2.5", + "huggingface_sb3>=2.3", "tqdm", "rich", - "optuna", + "optuna>=3.0", "pyyaml>=5.1", "pytablewriter~=0.64", # TODO: add test dependencies diff --git a/tests/test_hyperparams_opt.py b/tests/test_hyperparams_opt.py index d4d42b686..1cebf637d 100644 --- a/tests/test_hyperparams_opt.py +++ b/tests/test_hyperparams_opt.py @@ -108,7 +108,7 @@ def test_optimize_log_path(tmp_path): assert os.path.isdir(os.path.join(optimization_log_path, "trial_1")) assert os.path.isfile(os.path.join(optimization_log_path, "trial_1", "evaluations.npz")) - study_path = list(glob.glob(str(tmp_path / algo / "report_*.pkl")))[0] + study_path = next(iter(glob.glob(str(tmp_path / algo / "report_*.pkl")))) print(study_path) # Test reading best trials args = [