Drop python 3.7, add 3.11 and update github templates (#1587)

* Add missing word in patch error message

* Add changelog

* Drop python 3.7, add 3.11 and update github templates

* [ci skip] Update version in doc

* Update minimum PyTorch version

* Update conda env and fix mypy

---------

Co-authored-by: Lukas Hass <lukas@slucky.de>
This commit is contained in:
Antonin RAFFIN 2023-07-03 12:44:18 +02:00 committed by GitHub
parent 472ff8edb8
commit d68ff2e17f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 64 additions and 36 deletions

View file

@ -67,7 +67,7 @@ body:
required: true required: true
- label: I have read the [documentation](https://stable-baselines3.readthedocs.io/en/master/) - label: I have read the [documentation](https://stable-baselines3.readthedocs.io/en/master/)
required: true 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 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. - 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 required: true

View file

@ -28,7 +28,7 @@ body:
attributes: attributes:
label: Code example label: Code example
description: | 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). 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. 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. 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 required: true
- label: I have read the [documentation](https://stable-baselines3.readthedocs.io/en/master/) - label: I have read the [documentation](https://stable-baselines3.readthedocs.io/en/master/)
required: true 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 required: true
- label: I have checked my env using the env checker - label: I have checked my env using the env checker
required: true required: true

View file

@ -42,3 +42,5 @@ body:
options: options:
- label: I have checked that there is no similar [issue](https://github.com/DLR-RM/stable-baselines3/issues) in the repo - label: I have checked that there is no similar [issue](https://github.com/DLR-RM/stable-baselines3/issues) in the repo
required: true required: true
- label: If I'm requesting a new feature, I have proposed alternatives
required: true

View file

@ -26,7 +26,7 @@ body:
required: true required: true
- label: I have read the [documentation](https://stable-baselines3.readthedocs.io/en/master/) - label: I have read the [documentation](https://stable-baselines3.readthedocs.io/en/master/)
required: true 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 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. - 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 required: true

View file

@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"] python-version: ["3.8", "3.9", "3.10", "3.11"]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -32,7 +32,7 @@ jobs:
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
# cpu version of pytorch # 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 # Install Atari Roms
pip install autorom pip install autorom
@ -55,8 +55,8 @@ jobs:
- name: Type check - name: Type check
run: | run: |
make type make type
# skip mypy type check for python3.7 (result is different to all other versions) # skip PyType, doesn't support 3.11 yet
if: "!(matrix.python-version == '3.7')" if: "!(matrix.python-version == '3.11')"
- name: Test with pytest - name: Test with pytest
run: | run: |
make pytest make pytest

View file

@ -92,10 +92,10 @@ It provides a minimal number of features compared to SB3 but can be much faster
## Installation ## Installation
**Note:** Stable-Baselines3 supports PyTorch >= 1.11 **Note:** Stable-Baselines3 supports PyTorch >= 1.13
### Prerequisites ### Prerequisites
Stable Baselines3 requires Python 3.7+. Stable Baselines3 requires Python 3.8+.
#### Windows 10 #### Windows 10

View file

@ -5,8 +5,8 @@ channels:
dependencies: dependencies:
- cpuonly=1.0=0 - cpuonly=1.0=0
- pip=22.3.1 - pip=22.3.1
- python=3.7 - python=3.8
- pytorch=1.11.0=py3.7_cpu_0 - pytorch=1.13.0=py3.8_cpu_0
- pip: - pip:
- gymnasium - gymnasium
- cloudpickle - cloudpickle
@ -15,6 +15,6 @@ dependencies:
- numpy - numpy
- matplotlib - matplotlib
- sphinx_autodoc_typehints - sphinx_autodoc_typehints
- sphinx>=4.2 - sphinx>=5.3,<7.0
- sphinx_rtd_theme>=1.0 - sphinx_rtd_theme>=1.0
- sphinx_copybutton - sphinx_copybutton

View file

@ -7,7 +7,7 @@ Installation
Prerequisites Prerequisites
------------- -------------
Stable-Baselines3 requires python 3.7+ and PyTorch >= 1.11 Stable-Baselines3 requires python 3.8+ and PyTorch >= 1.13
Windows 10 Windows 10
~~~~~~~~~~ ~~~~~~~~~~

View file

@ -3,6 +3,40 @@
Changelog 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) Release 2.0.0 (2023-06-22)
-------------------------- --------------------------
@ -1361,4 +1395,4 @@ And all the contributors:
@Melanol @qgallouedec @francescoluciano @jlp-ue @burakdmb @timothe-chaumont @honglu2875 @Melanol @qgallouedec @francescoluciano @jlp-ue @burakdmb @timothe-chaumont @honglu2875
@anand-bala @hughperkins @sidney-tio @AlexPasqua @dominicgkerr @Akhilez @Rocamonde @tobirohrer @ZikangXiong @anand-bala @hughperkins @sidney-tio @AlexPasqua @dominicgkerr @Akhilez @Rocamonde @tobirohrer @ZikangXiong
@DavyMorgan @luizapozzobon @Bonifatius94 @theSquaredError @harveybellini @DavyMorgan @FieteO @jonasreiher @npit @WeberSamuel @troiganto @DavyMorgan @luizapozzobon @Bonifatius94 @theSquaredError @harveybellini @DavyMorgan @FieteO @jonasreiher @npit @WeberSamuel @troiganto
@lutogniew @lbergmann1 @lutogniew @lbergmann1 @lukashass

View file

@ -1,8 +1,8 @@
[tool.ruff] [tool.ruff]
# Same as Black. # Same as Black.
line-length = 127 line-length = 127
# Assume Python 3.7 # Assume Python 3.8
target-version = "py37" target-version = "py38"
# 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"]
# B028: Ignore explicit stacklevel` # B028: Ignore explicit stacklevel`

View file

@ -76,9 +76,7 @@ model = PPO("MlpPolicy", "CartPole-v1").learn(10_000)
extra_no_roms = [ extra_no_roms = [
# For render # For render
"opencv-python", "opencv-python",
'pygame; python_version >= "3.8.0"', "pygame",
# See https://github.com/pygame/pygame/issues/3572
'pygame>=2.0,<2.1.3; python_version < "3.8.0"',
# Tensorboard support # Tensorboard support
"tensorboard>=2.9.1", "tensorboard>=2.9.1",
# Checking memory taken by replay buffer # Checking memory taken by replay buffer
@ -87,13 +85,13 @@ extra_no_roms = [
"tqdm", "tqdm",
"rich", "rich",
# For atari games, # For atari games,
"shimmy[atari]~=0.2.1", "shimmy[atari]~=1.1.0",
"pillow", "pillow",
] ]
extra_packages = extra_no_roms + [ # noqa: RUF005 extra_packages = extra_no_roms + [ # noqa: RUF005
# For atari roms, # For atari roms,
"autorom[accept-rom-license]~=0.6.0", "autorom[accept-rom-license]~=0.6.1",
] ]
@ -104,8 +102,7 @@ setup(
install_requires=[ install_requires=[
"gymnasium==0.28.1", "gymnasium==0.28.1",
"numpy>=1.20", "numpy>=1.20",
"torch>=1.11", "torch>=1.13",
'typing_extensions>=4.0,<5; python_version < "3.8.0"',
# For saving models # For saving models
"cloudpickle", "cloudpickle",
# For reading logs # For reading logs
@ -154,7 +151,7 @@ setup(
long_description=long_description, long_description=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
version=__version__, version=__version__,
python_requires=">=3.7", python_requires=">=3.8",
# PyPI package information. # PyPI package information.
project_urls={ project_urls={
"Code": "https://github.com/DLR-RM/stable-baselines3", "Code": "https://github.com/DLR-RM/stable-baselines3",
@ -166,10 +163,10 @@ setup(
}, },
classifiers=[ classifiers=[
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
], ],
) )

View file

@ -11,7 +11,7 @@ try:
cv2.ocl.setUseOpenCL(False) cv2.ocl.setUseOpenCL(False)
except ImportError: except ImportError:
cv2 = None cv2 = None # type: ignore[assignment]
class StickyActionEnv(gym.Wrapper[np.ndarray, int, np.ndarray, int]): 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 :param frame: environment frame
:return: the observation :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.cvtColor(frame, cv2.COLOR_RGB2GRAY)
frame = cv2.resize(frame, (self.width, self.height), interpolation=cv2.INTER_AREA) frame = cv2.resize(frame, (self.width, self.height), interpolation=cv2.INTER_AREA)
return frame[:, :, None] return frame[:, :, None]

View file

@ -1,18 +1,12 @@
"""Common aliases for type hints""" """Common aliases for type hints"""
import sys
from enum import Enum 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 gymnasium as gym
import numpy as np import numpy as np
import torch as th 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 from stable_baselines3.common import callbacks, vec_env
GymEnv = Union[gym.Env, vec_env.VecEnv] GymEnv = Union[gym.Env, vec_env.VecEnv]

View file

@ -40,7 +40,7 @@ def _patch_env(env: Union["gym.Env", gymnasium.Env]) -> gymnasium.Env: # pragma
import shimmy # pytype: disable=import-error import shimmy # pytype: disable=import-error
except ImportError as e: except ImportError as e:
raise ImportError( 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. " "Stable-Baselines3 (SB3) has transitioned to using Gymnasium internally. "
"In order to use OpenAI Gym environments with SB3, you need to " "In order to use OpenAI Gym environments with SB3, you need to "
"install shimmy (`pip install 'shimmy>=0.2.1'`)." "install shimmy (`pip install 'shimmy>=0.2.1'`)."

View file

@ -1 +1 @@
2.0.0 2.1.0a0