mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-09-16 22:20:26 +00:00
Release v2.0.0 (#1571)
* RUF012: Explicit ClassVar * Prepare v2.0.0 * Update docs/misc/changelog.rst --------- Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
This commit is contained in:
parent
4fdb65ecf3
commit
1036c05680
11 changed files with 39 additions and 37 deletions
19
docs/conf.py
19
docs/conf.py
|
|
@ -13,8 +13,7 @@
|
||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from typing import Dict, List
|
from typing import Dict
|
||||||
from unittest.mock import MagicMock
|
|
||||||
|
|
||||||
# We CANNOT enable 'sphinxcontrib.spelling' because ReadTheDocs.org does not support
|
# We CANNOT enable 'sphinxcontrib.spelling' because ReadTheDocs.org does not support
|
||||||
# PyEnchant.
|
# PyEnchant.
|
||||||
|
|
@ -36,22 +35,6 @@ except ImportError:
|
||||||
# source code directory, relative to this file, for sphinx-autobuild
|
# source code directory, relative to this file, for sphinx-autobuild
|
||||||
sys.path.insert(0, os.path.abspath(".."))
|
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
|
# Read version from file
|
||||||
version_file = os.path.join(os.path.dirname(__file__), "../stable_baselines3", "version.txt")
|
version_file = os.path.join(os.path.dirname(__file__), "../stable_baselines3", "version.txt")
|
||||||
with open(version_file) as file_handler:
|
with open(version_file) as file_handler:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Changelog
|
Changelog
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Release 2.0.0a14 (WIP)
|
Release 2.0.0 (2023-06-22)
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
**Gymnasium support**
|
**Gymnasium support**
|
||||||
|
|
@ -26,13 +26,20 @@ Breaking Changes:
|
||||||
|
|
||||||
New Features:
|
New Features:
|
||||||
^^^^^^^^^^^^^
|
^^^^^^^^^^^^^
|
||||||
|
- Added Gymnasium support (Gym 0.21 and 0.26 are supported via the ``shimmy`` package)
|
||||||
|
|
||||||
`SB3-Contrib`_
|
`SB3-Contrib`_
|
||||||
^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^
|
||||||
|
- Fixed QRDQN update interval for multi envs
|
||||||
|
|
||||||
|
|
||||||
`RL Zoo`_
|
`RL Zoo`_
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
|
- Gym 0.26+ patches to continue working with pybullet and TimeLimit wrapper
|
||||||
|
- Renamed `CarRacing-v1` to `CarRacing-v2` in hyperparameters
|
||||||
|
- Huggingface push to hub now accepts a `--n-timesteps` argument to adjust the length of the video
|
||||||
|
- Fixed `record_video` steps (before it was stepping in a closed env)
|
||||||
|
- Dropped Gym 0.21 support
|
||||||
|
|
||||||
Bug Fixes:
|
Bug Fixes:
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,16 @@ line-length = 127
|
||||||
target-version = "py37"
|
target-version = "py37"
|
||||||
# See https://beta.ruff.rs/docs/rules/
|
# See https://beta.ruff.rs/docs/rules/
|
||||||
select = ["E", "F", "B", "UP", "C90", "RUF"]
|
select = ["E", "F", "B", "UP", "C90", "RUF"]
|
||||||
# Ignore explicit stacklevel`
|
# B028: Ignore explicit stacklevel`
|
||||||
ignore = ["B028"]
|
# RUF013: Too many false positives (implicit optional)
|
||||||
|
ignore = ["B028", "RUF013"]
|
||||||
|
|
||||||
[tool.ruff.per-file-ignores]
|
[tool.ruff.per-file-ignores]
|
||||||
# Default implementation in abstract methods
|
# Default implementation in abstract methods
|
||||||
"./stable_baselines3/common/callbacks.py"= ["B027"]
|
"./stable_baselines3/common/callbacks.py"= ["B027"]
|
||||||
"./stable_baselines3/common/noise.py"= ["B027"]
|
"./stable_baselines3/common/noise.py"= ["B027"]
|
||||||
|
# ClassVar, implicit optional check not needed for tests
|
||||||
|
"./tests/*.py"= ["RUF012", "RUF013"]
|
||||||
|
|
||||||
|
|
||||||
[tool.ruff.mccabe]
|
[tool.ruff.mccabe]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Any, Dict, Optional, Type, TypeVar, Union
|
from typing import Any, ClassVar, Dict, Optional, Type, TypeVar, Union
|
||||||
|
|
||||||
import torch as th
|
import torch as th
|
||||||
from gymnasium import spaces
|
from gymnasium import spaces
|
||||||
|
|
@ -54,7 +54,7 @@ class A2C(OnPolicyAlgorithm):
|
||||||
:param _init_setup_model: Whether or not to build the network at the creation of the instance
|
:param _init_setup_model: Whether or not to build the network at the creation of the instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
policy_aliases: Dict[str, Type[BasePolicy]] = {
|
policy_aliases: ClassVar[Dict[str, Type[BasePolicy]]] = {
|
||||||
"MlpPolicy": ActorCriticPolicy,
|
"MlpPolicy": ActorCriticPolicy,
|
||||||
"CnnPolicy": ActorCriticCnnPolicy,
|
"CnnPolicy": ActorCriticCnnPolicy,
|
||||||
"MultiInputPolicy": MultiInputActorCriticPolicy,
|
"MultiInputPolicy": MultiInputActorCriticPolicy,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import time
|
||||||
import warnings
|
import warnings
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from typing import Any, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union
|
from typing import Any, ClassVar, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union
|
||||||
|
|
||||||
import gymnasium as gym
|
import gymnasium as gym
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
@ -94,7 +94,7 @@ class BaseAlgorithm(ABC):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Policy aliases (see _get_policy_from_name())
|
# Policy aliases (see _get_policy_from_name())
|
||||||
policy_aliases: Dict[str, Type[BasePolicy]] = {}
|
policy_aliases: ClassVar[Dict[str, Type[BasePolicy]]] = {}
|
||||||
policy: BasePolicy
|
policy: BasePolicy
|
||||||
observation_space: spaces.Space
|
observation_space: spaces.Space
|
||||||
action_space: spaces.Space
|
action_space: spaces.Space
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,6 @@ class VecEnv(ABC):
|
||||||
:param action_space: Action space
|
:param action_space: Action space
|
||||||
"""
|
"""
|
||||||
|
|
||||||
metadata = {"render_modes": ["human", "rgb_array"]}
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
num_envs: int,
|
num_envs: int,
|
||||||
|
|
@ -69,6 +67,7 @@ class VecEnv(ABC):
|
||||||
self.reset_infos: List[Dict[str, Any]] = [{} for _ in range(num_envs)]
|
self.reset_infos: List[Dict[str, Any]] = [{} for _ in range(num_envs)]
|
||||||
# seeds to be used in the next call to env.reset()
|
# seeds to be used in the next call to env.reset()
|
||||||
self._seeds: List[Optional[int]] = [None for _ in range(num_envs)]
|
self._seeds: List[Optional[int]] = [None for _ in range(num_envs)]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
render_modes = self.get_attr("render_mode")
|
render_modes = self.get_attr("render_mode")
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
@ -80,6 +79,16 @@ class VecEnv(ABC):
|
||||||
), "render_mode mode should be the same for all environments"
|
), "render_mode mode should be the same for all environments"
|
||||||
self.render_mode = render_modes[0]
|
self.render_mode = render_modes[0]
|
||||||
|
|
||||||
|
render_modes = []
|
||||||
|
if self.render_mode is not None:
|
||||||
|
if self.render_mode == "rgb_array":
|
||||||
|
# SB3 uses OpenCV for the "human" mode
|
||||||
|
render_modes = ["human", "rgb_array"]
|
||||||
|
else:
|
||||||
|
render_modes = [self.render_mode]
|
||||||
|
|
||||||
|
self.metadata = {"render_modes": render_modes}
|
||||||
|
|
||||||
def _reset_seeds(self) -> None:
|
def _reset_seeds(self) -> None:
|
||||||
"""
|
"""
|
||||||
Reset the seeds that are going to be used at the next reset.
|
Reset the seeds that are going to be used at the next reset.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import warnings
|
import warnings
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union
|
from typing import Any, ClassVar, Dict, List, Optional, Tuple, Type, TypeVar, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch as th
|
import torch as th
|
||||||
|
|
@ -62,7 +62,7 @@ class DQN(OffPolicyAlgorithm):
|
||||||
:param _init_setup_model: Whether or not to build the network at the creation of the instance
|
:param _init_setup_model: Whether or not to build the network at the creation of the instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
policy_aliases: Dict[str, Type[BasePolicy]] = {
|
policy_aliases: ClassVar[Dict[str, Type[BasePolicy]]] = {
|
||||||
"MlpPolicy": MlpPolicy,
|
"MlpPolicy": MlpPolicy,
|
||||||
"CnnPolicy": CnnPolicy,
|
"CnnPolicy": CnnPolicy,
|
||||||
"MultiInputPolicy": MultiInputPolicy,
|
"MultiInputPolicy": MultiInputPolicy,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import warnings
|
import warnings
|
||||||
from typing import Any, Dict, Optional, Type, TypeVar, Union
|
from typing import Any, ClassVar, Dict, Optional, Type, TypeVar, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch as th
|
import torch as th
|
||||||
|
|
@ -68,7 +68,7 @@ class PPO(OnPolicyAlgorithm):
|
||||||
:param _init_setup_model: Whether or not to build the network at the creation of the instance
|
:param _init_setup_model: Whether or not to build the network at the creation of the instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
policy_aliases: Dict[str, Type[BasePolicy]] = {
|
policy_aliases: ClassVar[Dict[str, Type[BasePolicy]]] = {
|
||||||
"MlpPolicy": ActorCriticPolicy,
|
"MlpPolicy": ActorCriticPolicy,
|
||||||
"CnnPolicy": ActorCriticCnnPolicy,
|
"CnnPolicy": ActorCriticCnnPolicy,
|
||||||
"MultiInputPolicy": MultiInputActorCriticPolicy,
|
"MultiInputPolicy": MultiInputActorCriticPolicy,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union
|
from typing import Any, ClassVar, Dict, List, Optional, Tuple, Type, TypeVar, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch as th
|
import torch as th
|
||||||
|
|
@ -77,7 +77,7 @@ class SAC(OffPolicyAlgorithm):
|
||||||
:param _init_setup_model: Whether or not to build the network at the creation of the instance
|
:param _init_setup_model: Whether or not to build the network at the creation of the instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
policy_aliases: Dict[str, Type[BasePolicy]] = {
|
policy_aliases: ClassVar[Dict[str, Type[BasePolicy]]] = {
|
||||||
"MlpPolicy": MlpPolicy,
|
"MlpPolicy": MlpPolicy,
|
||||||
"CnnPolicy": CnnPolicy,
|
"CnnPolicy": CnnPolicy,
|
||||||
"MultiInputPolicy": MultiInputPolicy,
|
"MultiInputPolicy": MultiInputPolicy,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union
|
from typing import Any, ClassVar, Dict, List, Optional, Tuple, Type, TypeVar, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch as th
|
import torch as th
|
||||||
|
|
@ -65,7 +65,7 @@ class TD3(OffPolicyAlgorithm):
|
||||||
:param _init_setup_model: Whether or not to build the network at the creation of the instance
|
:param _init_setup_model: Whether or not to build the network at the creation of the instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
policy_aliases: Dict[str, Type[BasePolicy]] = {
|
policy_aliases: ClassVar[Dict[str, Type[BasePolicy]]] = {
|
||||||
"MlpPolicy": MlpPolicy,
|
"MlpPolicy": MlpPolicy,
|
||||||
"CnnPolicy": CnnPolicy,
|
"CnnPolicy": CnnPolicy,
|
||||||
"MultiInputPolicy": MultiInputPolicy,
|
"MultiInputPolicy": MultiInputPolicy,
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
2.0.0a14
|
2.0.0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue