Skip to content

Commit

Permalink
Drop python 3.7, add 3.11 and update github templates (#1587)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
araffin and lukashass committed Jul 3, 2023
1 parent 472ff8e commit d68ff2e
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/custom_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions docs/conda_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion docs/guide/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~
Expand Down
36 changes: 35 additions & 1 deletion docs/misc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
--------------------------

Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
15 changes: 6 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@
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
Expand All @@ -87,13 +85,13 @@
"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",
]


Expand All @@ -104,8 +102,7 @@
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
Expand Down Expand Up @@ -154,7 +151,7 @@
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",
Expand All @@ -166,10 +163,10 @@
},
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",
],
)

Expand Down
3 changes: 2 additions & 1 deletion stable_baselines3/common/atari_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

cv2.ocl.setUseOpenCL(False)
except ImportError:
cv2 = None
cv2 = None # type: ignore[assignment]


class StickyActionEnv(gym.Wrapper[np.ndarray, int, np.ndarray, int]):
Expand Down Expand Up @@ -241,6 +241,7 @@ def observation(self, frame: np.ndarray) -> 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]
Expand Down
8 changes: 1 addition & 7 deletions stable_baselines3/common/type_aliases.py
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
2 changes: 1 addition & 1 deletion stable_baselines3/common/vec_env/patch_gym.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'`)."
Expand Down
2 changes: 1 addition & 1 deletion stable_baselines3/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.1.0a0

0 comments on commit d68ff2e

Please sign in to comment.