diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 052f2c2..962bef2 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -67,7 +67,7 @@ body: required: true - label: I have read the [documentation](https://stable-baselines3.readthedocs.io/en/master/) required: true - - label: I have provided a minimal working example to reproduce the bug + - label: I have provided a [minimal and working](https://github.com/DLR-RM/stable-baselines3/issues/982#issuecomment-1197044014) example to reproduce the bug required: true - label: I've used the [markdown code blocks](https://help.github.com/en/articles/creating-and-highlighting-code-blocks) for both code and stack traces. required: true diff --git a/.github/ISSUE_TEMPLATE/custom_env.yml b/.github/ISSUE_TEMPLATE/custom_env.yml index 4040d9d..0cb502e 100644 --- a/.github/ISSUE_TEMPLATE/custom_env.yml +++ b/.github/ISSUE_TEMPLATE/custom_env.yml @@ -28,7 +28,7 @@ body: attributes: label: Code example description: | - Please try to provide a minimal example to reproduce the bug. + Please try to provide a [minimal example](https://github.com/DLR-RM/stable-baselines3/issues/982#issuecomment-1197044014) to reproduce the bug. For a custom environment, you need to give at least the observation space, action space, `reset()` and `step()` methods (see working example below). Error messages and stack traces are also helpful. Please use the [markdown code blocks](https://help.github.com/en/articles/creating-and-highlighting-code-blocks) for both code and stack traces. @@ -101,7 +101,7 @@ body: required: true - label: I have read the [documentation](https://stable-baselines3.readthedocs.io/en/master/) required: true - - label: I have provided a minimal working example to reproduce the bug + - label: I have provided a [minimal and working](https://github.com/DLR-RM/stable-baselines3/issues/982#issuecomment-1197044014) example to reproduce the bug required: true - label: I have checked my env using the env checker required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 9e72949..8bc63a9 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -42,3 +42,5 @@ body: options: - label: I have checked that there is no similar [issue](https://github.com/DLR-RM/stable-baselines3/issues) in the repo required: true + - label: If I'm requesting a new feature, I have proposed alternatives + required: true diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 2942068..0b61fb6 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -26,7 +26,7 @@ body: required: true - label: I have read the [documentation](https://stable-baselines3.readthedocs.io/en/master/) required: true - - label: If code there is, it is minimal and working + - label: If code there is, it is [minimal and working](https://github.com/DLR-RM/stable-baselines3/issues/982#issuecomment-1197044014) required: true - label: If code there is, it is formatted using the [markdown code blocks](https://help.github.com/en/articles/creating-and-highlighting-code-blocks) for both code and stack traces. required: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c238cd..634e712 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 @@ -32,7 +32,7 @@ jobs: run: | python -m pip install --upgrade pip # cpu version of pytorch - pip install torch==1.11+cpu -f https://download.pytorch.org/whl/torch_stable.html + pip install torch==1.13+cpu -f https://download.pytorch.org/whl/torch_stable.html # Install Atari Roms pip install autorom @@ -55,8 +55,8 @@ jobs: - name: Type check run: | make type - # skip mypy type check for python3.7 (result is different to all other versions) - if: "!(matrix.python-version == '3.7')" + # skip PyType, doesn't support 3.11 yet + if: "!(matrix.python-version == '3.11')" - name: Test with pytest run: | make pytest diff --git a/README.md b/README.md index 820c363..81f4c6e 100644 --- a/README.md +++ b/README.md @@ -92,10 +92,10 @@ It provides a minimal number of features compared to SB3 but can be much faster ## Installation -**Note:** Stable-Baselines3 supports PyTorch >= 1.11 +**Note:** Stable-Baselines3 supports PyTorch >= 1.13 ### Prerequisites -Stable Baselines3 requires Python 3.7+. +Stable Baselines3 requires Python 3.8+. #### Windows 10 diff --git a/docs/conda_env.yml b/docs/conda_env.yml index 0545eef..8c71fe9 100644 --- a/docs/conda_env.yml +++ b/docs/conda_env.yml @@ -5,8 +5,8 @@ channels: dependencies: - cpuonly=1.0=0 - pip=22.3.1 - - python=3.7 - - pytorch=1.11.0=py3.7_cpu_0 + - python=3.8 + - pytorch=1.13.0=py3.8_cpu_0 - pip: - gymnasium - cloudpickle @@ -15,6 +15,6 @@ dependencies: - numpy - matplotlib - sphinx_autodoc_typehints - - sphinx>=4.2 + - sphinx>=5.3,<7.0 - sphinx_rtd_theme>=1.0 - sphinx_copybutton diff --git a/docs/guide/install.rst b/docs/guide/install.rst index 6e2e0e0..a464496 100644 --- a/docs/guide/install.rst +++ b/docs/guide/install.rst @@ -7,7 +7,7 @@ Installation Prerequisites ------------- -Stable-Baselines3 requires python 3.7+ and PyTorch >= 1.11 +Stable-Baselines3 requires python 3.8+ and PyTorch >= 1.13 Windows 10 ~~~~~~~~~~ diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index ebf27a5..7bb1f16 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -3,6 +3,40 @@ Changelog ========== + +Release 2.1.0a0 (WIP) +-------------------------- + +Breaking Changes: +^^^^^^^^^^^^^^^^^ +- Removed Python 3.7 support +- SB3 now requires PyTorch >= 1.13 + +New Features: +^^^^^^^^^^^^^ +- Added Python 3.11 support + +`SB3-Contrib`_ +^^^^^^^^^^^^^^ + +`RL Zoo`_ +^^^^^^^^^ + +Bug Fixes: +^^^^^^^^^^ + +Deprecations: +^^^^^^^^^^^^^ + +Others: +^^^^^^^ +- Updated GitHub issue templates +- Fix typo in gym patch error message (@lukashass) + +Documentation: +^^^^^^^^^^^^^^ + + Release 2.0.0 (2023-06-22) -------------------------- @@ -1361,4 +1395,4 @@ And all the contributors: @Melanol @qgallouedec @francescoluciano @jlp-ue @burakdmb @timothe-chaumont @honglu2875 @anand-bala @hughperkins @sidney-tio @AlexPasqua @dominicgkerr @Akhilez @Rocamonde @tobirohrer @ZikangXiong @DavyMorgan @luizapozzobon @Bonifatius94 @theSquaredError @harveybellini @DavyMorgan @FieteO @jonasreiher @npit @WeberSamuel @troiganto -@lutogniew @lbergmann1 +@lutogniew @lbergmann1 @lukashass diff --git a/pyproject.toml b/pyproject.toml index fe31b0a..518fd26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [tool.ruff] # Same as Black. line-length = 127 -# Assume Python 3.7 -target-version = "py37" +# Assume Python 3.8 +target-version = "py38" # See https://beta.ruff.rs/docs/rules/ select = ["E", "F", "B", "UP", "C90", "RUF"] # B028: Ignore explicit stacklevel` diff --git a/setup.py b/setup.py index 3e26438..6ddb9b6 100644 --- a/setup.py +++ b/setup.py @@ -76,9 +76,7 @@ model = PPO("MlpPolicy", "CartPole-v1").learn(10_000) extra_no_roms = [ # For render "opencv-python", - 'pygame; python_version >= "3.8.0"', - # See https://github.com/pygame/pygame/issues/3572 - 'pygame>=2.0,<2.1.3; python_version < "3.8.0"', + "pygame", # Tensorboard support "tensorboard>=2.9.1", # Checking memory taken by replay buffer @@ -87,13 +85,13 @@ extra_no_roms = [ "tqdm", "rich", # For atari games, - "shimmy[atari]~=0.2.1", + "shimmy[atari]~=1.1.0", "pillow", ] extra_packages = extra_no_roms + [ # noqa: RUF005 # For atari roms, - "autorom[accept-rom-license]~=0.6.0", + "autorom[accept-rom-license]~=0.6.1", ] @@ -104,8 +102,7 @@ setup( install_requires=[ "gymnasium==0.28.1", "numpy>=1.20", - "torch>=1.11", - 'typing_extensions>=4.0,<5; python_version < "3.8.0"', + "torch>=1.13", # For saving models "cloudpickle", # For reading logs @@ -154,7 +151,7 @@ setup( long_description=long_description, long_description_content_type="text/markdown", version=__version__, - python_requires=">=3.7", + python_requires=">=3.8", # PyPI package information. project_urls={ "Code": "https://github.com/DLR-RM/stable-baselines3", @@ -166,10 +163,10 @@ setup( }, classifiers=[ "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], ) diff --git a/stable_baselines3/common/atari_wrappers.py b/stable_baselines3/common/atari_wrappers.py index ea78c5b..4e0e477 100644 --- a/stable_baselines3/common/atari_wrappers.py +++ b/stable_baselines3/common/atari_wrappers.py @@ -11,7 +11,7 @@ try: cv2.ocl.setUseOpenCL(False) except ImportError: - cv2 = None + cv2 = None # type: ignore[assignment] class StickyActionEnv(gym.Wrapper[np.ndarray, int, np.ndarray, int]): @@ -241,6 +241,7 @@ class WarpFrame(gym.ObservationWrapper[np.ndarray, int, np.ndarray]): :param frame: environment frame :return: the observation """ + assert cv2 is not None, "OpenCV is not installed, you can do `pip install opencv-python`" frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) frame = cv2.resize(frame, (self.width, self.height), interpolation=cv2.INTER_AREA) return frame[:, :, None] diff --git a/stable_baselines3/common/type_aliases.py b/stable_baselines3/common/type_aliases.py index d38d7cf..2f98ee1 100644 --- a/stable_baselines3/common/type_aliases.py +++ b/stable_baselines3/common/type_aliases.py @@ -1,18 +1,12 @@ """Common aliases for type hints""" -import sys from enum import Enum -from typing import Any, Callable, Dict, List, NamedTuple, Optional, SupportsFloat, Tuple, Union +from typing import Any, Callable, Dict, List, NamedTuple, Optional, Protocol, SupportsFloat, Tuple, Union import gymnasium as gym import numpy as np import torch as th -if sys.version_info >= (3, 8): - from typing import Protocol -else: - from typing_extensions import Protocol - from stable_baselines3.common import callbacks, vec_env GymEnv = Union[gym.Env, vec_env.VecEnv] diff --git a/stable_baselines3/common/vec_env/patch_gym.py b/stable_baselines3/common/vec_env/patch_gym.py index b86c522..7b1934b 100644 --- a/stable_baselines3/common/vec_env/patch_gym.py +++ b/stable_baselines3/common/vec_env/patch_gym.py @@ -40,7 +40,7 @@ def _patch_env(env: Union["gym.Env", gymnasium.Env]) -> gymnasium.Env: # pragma import shimmy # pytype: disable=import-error except ImportError as e: raise ImportError( - "Missing shimmy installation. You an OpenAI Gym environment. " + "Missing shimmy installation. You provided an OpenAI Gym environment. " "Stable-Baselines3 (SB3) has transitioned to using Gymnasium internally. " "In order to use OpenAI Gym environments with SB3, you need to " "install shimmy (`pip install 'shimmy>=0.2.1'`)." diff --git a/stable_baselines3/version.txt b/stable_baselines3/version.txt index 227cea2..ecaf4ee 100644 --- a/stable_baselines3/version.txt +++ b/stable_baselines3/version.txt @@ -1 +1 @@ -2.0.0 +2.1.0a0