Commit graph

92 commits

Author SHA1 Message Date
Antonin RAFFIN
b8b2d30a83
Add has_attr for VecEnv (#2077)
* Add `has_attr` for `VecEnv`

* Add special case for gymnasium<1.0

* Update changelog.rst

* Update black version
2025-02-03 10:43:56 +01:00
Antonin RAFFIN
daaebd0a52
Drop python 3.8 and add python 3.12 support (#2041)
* Drop python 3.8 support, add python 3.12 support

* Upgrade to python 3.9 syntax

* Fixes for Numpy v2

* Fix doc warning
2024-11-18 15:40:36 +01:00
Antonin RAFFIN
e4f4f123e3
Add note about SAC ent coeff optimization (#2037)
* Allow new sphinx version

* Add note about SAC ent coeff and add DQN tutorial link
2024-11-08 11:01:04 +01:00
Mark Towers
8f0b488bc5
Update Gymnasium to v1.0.0 (#1837)
* Update Gymnasium to v1.0.0a1

* Comment out `gymnasium.wrappers.monitor` (todo update to VideoRecord)

* Fix ruff warnings

* Register Atari envs

* Update `getattr` to `Env.get_wrapper_attr`

* Reorder imports

* Fix `seed` order

* Fix collecting `max_steps`

* Copy and paste video recorder to prevent the need to rewrite the vec vide recorder wrapper

* Use `typing.List` rather than list

* Fix env attribute forwarding

* Separate out env attribute collection from its utilisation

* Update for Gymnasium alpha 2

* Remove assert for OrderedDict

* Update setup.py

* Add type: ignore

* Test with Gymnasium main

* Remove `gymnasium.logger.debug/info`

* Fix github CI yaml

* Run gym 0.29.1 on python 3.10

* Update lower bounds

* Integrate video recorder

* Remove ordered dict

* Update changelog

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2024-11-04 12:03:12 +01:00
Dominik Baron
24ebf1a1df
Remove unnecessary SDE resampling in PPO update (#1933)
* Remove unnecessary SDE resampling in PPO update

* Update changelog.rst

* Update version

* Update PyTorch version on CI

* Update ruff

* Limit NumPy version

* Reformat

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2024-06-29 20:07:32 +02:00
Antonin RAFFIN
8b3723c6d8
Update ruff and documentation for hf sb3 (#1866)
* Update ruff

* Only load weights with `torch.load()` to avoid security issues

* Update doc about HF integration and remote code execution

* Fix doc build

* Revert weight_only=True for policies
2024-03-11 13:53:06 +01:00
Antonin RAFFIN
a8e905977f
Update env checker for spaces with non-zero start (#1845)
* Update ruff

* Update env checker for non-zero start
2024-02-19 16:44:02 +01:00
Antonin RAFFIN
1cba1bbd2f
Update to black style v24 (#1834) 2024-02-13 11:36:05 +01:00
Marek Michalik
beee4279eb
Fix example in README.md (#1830)
* Fix example in README.md

* Update changelog

---------

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
2024-02-13 10:47:05 +01:00
Antonin RAFFIN
b413f4c285
Fix VecEnv type hints (#1736)
* Fix VecNormalize type hints

* Fix VecEnv utils type annotations

* Apply suggestions from code review

Co-authored-by: M. Ernestus <maximilian@ernestus.de>

* Remove PyType

---------

Co-authored-by: M. Ernestus <maximilian@ernestus.de>
2023-11-08 09:46:40 +01:00
Antonin Raffin
6c70993c8f
Remove sphinx-autodoc-typehints 2023-10-23 20:26:33 +02:00
Antonin Raffin
80245bccc8
Update dependencies (shimmy, sphinx) 2023-10-23 20:14:09 +02:00
Antonin RAFFIN
99712760c8
Fix render_mode when loading VecNormalize (#1671)
* Fix render_mode when loading VecNormalize

* Switch from isort to ruff, and cap black version

* Add test and update changelog
2023-09-12 11:28:32 +02:00
Mark Towers
61e1060525
Update Gymnasium to v0.29.0 (#1610)
* Update setup.py to v0.29.0

* Remove invalid test

* Loosen version and update changelog

---------

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
2023-07-18 14:22:22 +02:00
Antonin RAFFIN
d68ff2e17f
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>
2023-07-03 12:44:18 +02:00
Antonin Raffin
472ff8edb8
[ci skip] Update README with SBX 2023-06-23 12:38:31 +02:00
Antonin RAFFIN
4fdb65ecf3
Doc fix and add Stable-Baselines3 Jax (SBX) page (#1566)
* Fix custom policy example

* Add RL Zoo doc link

* Add changelog to pypi

* Add SBX doc page

* Fix small mistake in docstring

---------

Co-authored-by: Peter Elmers <peter.elmers@yahoo.com>
2023-06-21 18:54:16 +02:00
Quentin Gallouédec
4eed3e9769
Improve issue templates to provide more guidance (#1563)
* update issue templates

* close bf

* Cap Sphinx version

* Relax sphinx version for python 3.7

* Fix Numpy deprecations

---------

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
2023-06-19 17:42:19 +02:00
Antonin RAFFIN
fd0cd82339
Update outdated custom env doc (#1490)
* Update outdated custom env doc

* fix render_mode and term/trunc/reset_info

* gym -> gymnasium

---------

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
2023-05-08 13:48:26 +02:00
Übertreiber
4f9805eeb8
Fix overly relaxed version requirement on NumPy (#1472)
Since commit 489b1fda, this package has been using
`numpy.typing.DTypeLike`, which was only added in [NumPy 1.20][1].

[1]: https://numpy.org/doc/stable/release/1.20.0-notes.html#numpy-is-now-typed

Co-authored-by: troiganto <troiganto@proton.me>
Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2023-04-27 19:07:53 +02:00
Antonin RAFFIN
40e0b9d2c8
Add Gymnasium support (#1327)
* Fix failing set_env test

* Fix test failiing due to deprectation of env.seed

* Adjust mean reward threshold in failing test

* Fix her test failing due to rng

* Change seed and revert reward threshold to 90

* Pin gym version

* Make VecEnv compatible with gym seeding change

* Revert change to VecEnv reset signature

* Change subprocenv seed cmd to call reset instead

* Fix type check

* Add backward compat

* Add `compat_gym_seed` helper

* Add goal env checks in env_checker

* Add docs on  HER requirements for envs

* Capture user warning in test with inverted box space

* Update ale-py version

* Fix randint

* Allow noop_max to be zero

* Update changelog

* Update docker image

* Update doc conda env and dockerfile

* Custom envs should not have any warnings

* Fix test for numpy >= 1.21

* Add check for vectorized compute reward

* Bump to gym 0.24

* Fix gym default step docstring

* Test downgrading gym

* Revert "Test downgrading gym"

This reverts commit 0072b77156c006ada8a1d6e26ce347ed85a83eeb.

* Fix protobuf error

* Fix in dependencies

* Fix protobuf dep

* Use newest version of cartpole

* Update gym

* Fix warning

* Loosen required scipy version

* Scipy no longer needed

* Try gym 0.25

* Silence warnings from gym

* Filter warnings during tests

* Update doc

* Update requirements

* Add gym 26 compat in vec env

* Fixes in envs and tests for gym 0.26+

* Enforce gym 0.26 api

* format

* Fix formatting

* Fix dependencies

* Fix syntax

* Cleanup doc and warnings

* Faster tests

* Higher budget for HER perf test (revert prev change)

* Fixes and update doc

* Fix doc build

* Fix breaking change

* Fixes for rendering

* Rename variables in monitor

* update render method for gym 0.26 API

backwards compatible (mode argument is allowed) while using the gym 0.26 API (render mode is determined at environment creation)

* update tests and docs to new gym render API

* undo removal of render modes metatadata check

* set rgb_array as default render mode for gym.make

* undo changes & raise warning if not 'rgb_array'

* Fix type check

* Remove recursion and fix type checking

* Remove hacks for protobuf and gym 0.24

* Fix type annotations

* reuse existing render_mode attribute

* return tiled images for 'human' render mode

* Allow to use opencv for human render, fix typos

* Add warning when using non-zero start with Discrete (fixes #1197)

* Fix type checking

* Bug fixes and handle more cases

* Throw proper warnings

* Update test

* Fix new metadata name

* Ignore numpy warnings

* Fixes in vec recorder

* Global ignore

* Filter local warning too

* Monkey patch not needed for gym 26

* Add doc of VecEnv vs Gym API

* Add render test

* Fix return type

* Update VecEnv vs Gym API doc

* Fix for custom render mode

* Fix return type

* Fix type checking

* check test env test_buffer

* skip render check

* check env test_dict_env

* test_env test_gae

* check envs in remaining tests

* Update tests

* Add warning for Discrete action space with non-zero (#1295)

* Fix atari annotation

* ignore get_action_meanings [attr-defined]

* Fix mypy issues

* Add patch for gym/gymnasium transition

* Switch to gymnasium

* Rely on signature instead of version

* More patches

* Type ignore because of https://github.com/Farama-Foundation/Gymnasium/pull/39

* Fix doc build

* Fix pytype errors

* Fix atari requirement

* Update env checker due to change in dtype for Discrete

* Fix type hint

* Convert spaces for saved models

* Ignore pytype

* Remove gitlab CI

* Disable pytype for convert space

* Fix undefined info

* Fix undefined info

* Upgrade shimmy

* Fix wrappers type annotation (need PR from Gymnasium)

* Fix gymnasium dependency

* Fix dependency declaration

* Cap pygame version for python 3.7

* Point to master branch (v0.28.0)

* Fix: use main not master branch

* Rename done to terminated

* Fix pygame dependency for python 3.7

* Rename gym to gymnasium

* Update Gymnasium

* Fix test

* Fix tests

* Forks don't have access to private variables

* Fix linter warnings

* Update read the doc env

* Fix env checker for GoalEnv

* Fix import

* Update env checker (more info) and fix dtype

* Use micromamab for Docker

* Update dependencies

* Clarify VecEnv doc

* Fix Gymnasium version

* Copy file only after mamba install

* [ci skip] Update docker doc

* Polish code

* Reformat

* Remove deprecated features

* Ignore warning

* Update doc

* Update examples and changelog

* Fix type annotation bundle (SAC, TD3, A2C, PPO, base class) (#1436)

* Fix SAC type hints, improve DQN ones

* Fix A2C and TD3 type hints

* Fix PPO type hints

* Fix on-policy type hints

* Fix base class type annotation, do not use defaults

* Update version

* Disable mypy for python 3.7

* Rename Gym26StepReturn

* Update continuous critic type annotation

* Fix pytype complain

---------

Co-authored-by: Carlos Luis <carlos.luisgonc@gmail.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Thomas Lips <37955681+tlpss@users.noreply.github.com>
Co-authored-by: tlips <thomas.lips@ugent.be>
Co-authored-by: tlpss <thomas17.lips@gmail.com>
Co-authored-by: Quentin GALLOUÉDEC <gallouedec.quentin@gmail.com>
2023-04-14 13:13:59 +02:00
Antonin RAFFIN
84f5511e08
Update changelog and cleanup (#1434) 2023-04-08 15:36:55 +02:00
Antonin RAFFIN
470771b5c2
Fix Atari Roms download, enable RUF linting (#1379)
* Add extra no Atari and fix CI for forks

* Enable ruff rules

* Change to no roms
2023-03-12 18:47:52 +01:00
Antonin RAFFIN
10e83865ec
Switch to pyproject.toml and ruff (#1361)
* Switch to `pyproject.toml` and `ruff`

* Fix for Atari ROMs and mypy

* Switch order in CI, lint first
2023-03-11 22:15:26 +01:00
Quentin Gallouédec
69fdf155e1
Downgrade sphinx-autodoc-typehints (#1291)
* Update setup.py

* black

* hotfix pytype
2023-01-23 10:56:45 +01:00
Quentin Gallouédec
9aff1137a9
Add support for Python 3.10 (#1227)
* Add python 3.10 and 3.11

* Update setup

* Fix CI

* Drop 3.11 (because of pytorch)

* Update changelog

* revert unwanted change in setup.cfg

* Remove remark about pytorch
2022-12-21 15:52:48 +01:00
Antonin Raffin
213b06b0c6
Monkey-patch np.bool = bool 2022-12-19 13:20:48 +01:00
Quentin Gallouédec
68a40e0940
Construct tensors directly on GPU (#1218)
* Replace .to(device) when possible

* fix numpy dep

* black

* Add warning for device != cpu and copy=False

* Update changelog

* Remove warning

* Update buffers.py
2022-12-19 12:50:22 +01:00
Quentin Gallouédec
e3b24829a5
Drop gym.GoalEnv and other minor changes initally from #780 (#1184)
* Various changes from #780

* Fix env_checker for goal_env detection
2022-11-28 18:22:31 +01:00
Quentin Gallouédec
abffa16198
Mypy type checking (#1143)
* Install and configure mypy

* Test if github CI uses setup.cfg for mypy

* force color output

* tab to space

* Try to fix regex

* follow_imports silent

* use space as indentation

* fix indentation setup.cfg

* Show error code

* Update doc

* Udate changelog

* Ignore mypy cache files from commit

* Update gitlab CI

* Add pytype and mypy entry in Makefile

* Make mypy happy

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2022-11-16 13:22:57 +01:00
Adam Gleave
4fb8aec215
Update evaluate_policy type annotation to support policies as well as RL algorithms (#1146)
* Add PolicyPredictor protocol and use it in evaluate_policy

* Update changelog

* Move Protocol to type_aliases to avoid circular import

* Add test for evaluate_policy on BasePolicy

* Remove unused import

* Use typing_extensions

* Move typing_extensions to 3rd party

* Add version range (typing_extensions uses SemVer)

* Import Protocol from typing_extensions only on Python<3.8

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>

* Install typing_extensions only on Python<3.8

* Add missing sys import

* Fix import ordering

* Fix observation type hint in predict

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin GALLOUÉDEC <gallouedec.quentin@gmail.com>
2022-11-03 15:36:19 +01:00
Antonin RAFFIN
e2f81bb70b
Release v1.6.2 (#1103)
* Release v1.6.2

* Remove Gitlab CI, no more minutes
2022-10-10 16:37:11 +02:00
Antonin RAFFIN
7c21b79188
Add progress bar callback and argument (#1095)
* Add progress bar callback and argument

* Update doc

* Update changelog

* Upgrade pytype in docker image

* Use tqdm.write in the logger to have cleaner output

* Fix logger test

* Fix when doing multiple calls to learn()

* Address comments from code-review
2022-10-06 18:17:31 +02:00
Quentin Gallouédec
d3eb0e3ed6
Fix importlib dependency (#1088)
* Set requirement ``importlib-metadata~=4.13``

* Update changelog
2022-10-03 12:03:51 +02:00
Timothé
01cc127d32
Support hparams logging to tensorboard (#984)
* create Hparam class & support in all OutputFormats

* add hparams documentation & example

* add hparam tests

* remove unnecessary test & fix name

* format changes

* support hyperparameters logging to tensorboard

* fix HParams class docstring

* use more explicit variable names

* raise error instead of warning

* Unpin protobuf

* Add test for logging hparams

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
2022-08-22 22:06:54 +02:00
Antonin RAFFIN
c1f1c3d3d7
Release v1.6.0 (#958)
* Release v1.6.0 + update doc + add copy button

* Update read the doc conda env

* Update year

* Fix bug in kl divergence check

* Rephrase requirement for envpool and isaac gym
2022-07-12 22:50:23 +02:00
Antonin RAFFIN
4b89fbf283
Fix issues due to newer version of protobuf and sphinx (#924) 2022-05-29 21:09:50 +02:00
Antonin RAFFIN
a6f5049a99
Upgrade code to Python 3.7+ syntax using pyupgrade (#887)
* Upgrade code to Python 3.7+ syntax

* Update changelog
2022-04-25 13:01:38 +03:00
Bryan Collazo
3c468ff558
Update ppo documentation (remove redundant and) (#874)
* Update ppo documentation (remove redundant and)

PTAL, thanks!

* Update changelog

* Pin ale-py version

Co-authored-by: Antonin Raffin <antonin.raffin@dlr.de>
2022-04-19 14:15:51 +02:00
Antonin RAFFIN
248f082cdc
Bump min PyTorch version (#855) 2022-04-11 18:34:15 +02:00
Antonin RAFFIN
7ce4bb8016
Pin gym version (#782)
* Pin gym version

* Cleanup warnings

* Reformat
2022-02-21 23:12:54 +01:00
Carlos Luis
5143cd19f7
Gym fixes - Follow up from #705 (#734)
* fix Atari in CI

* fix dtype and atari extra

* Update setup.py

* remove 3.6

* note about how to install Atari

* pendulum-v1

* atari v5

* black

* fix pendulum capitalization

* add minimum version

* moved things in changelog to breaking changes

* partial v5 fix

* env update to pass tests

* mismatch env version fixed

* Fix tests after merge

* Include autorom in setup.py

* Blacken code

* Fix dtype issue in more robust way

* Fix GitLab CI: switch to Docker container with new black version

* Remove workaround from GitLab. (May need to rebuild Docker for this though.)

* Revert to v4

* Update setup.py

* Apply suggestions from code review

* Remove unnecessary autorom

* Consistent gym versions

Co-authored-by: J K Terry <justinkterry@gmail.com>
Co-authored-by: Anssi <kaneran21@hotmail.com>
Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
Co-authored-by: modanesh <mohamad4danesh@gmail.com>
Co-authored-by: Adam Gleave <adam@gleave.me>
2022-02-04 15:13:57 -08:00
IperGiove
d9e198e04f
Update custom_policy.rst (#711)
* Update custom_policy.rst

Added methods forward_actor and forward_critic in CustomNetwork class.

* Update doc

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
2022-01-03 16:22:58 +01:00
Antonin RAFFIN
77f4f5021d
Drop Python 3.6 support (#685)
* Drop python 3.6 support

* Update doc

* Update gitlab CI

* Update doc env

* Fix gitlab CI
2021-12-06 12:54:43 +01:00
Antonin RAFFIN
e907eca18e
Fix set_env to keep the number of timesteps (#615)
* Fix for `set_env`

* Add test and update changelog

* Use underscores and f-strings

* Add PyPi info

* Update comments
2021-10-23 16:36:40 +02:00
Cyprien
f3a35aa786
Add method predict_values for ActorCriticPolicy (#569)
* feat: add method predict_values for ActorCriticPolicy

* Fixes for new gym version

* Reformat

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
2021-09-15 14:03:04 +02:00
Scott Brownlie
1afc2f3abe
Avoid putting target networks into training mode (#553)
* make sure DQN policy is always in correct mode - train or eval

* make set_training_mode an abstract method of the base policy - safer

* update docstring of _build method to note that the target network is put into eval mode

* use set_training_mode to put the dqn target network into eval mode

* use set_training_mode to set the training model of the q-network

* move set_training_mode abstract method from BasePolicy to BaseModel

* set train and eval mode for TD3

* make sure critic is always in correct mode during train

* set train and eval mode for SAC

* add comment re batch norm and dropout

* set train and eval mode for A2C and PPO

* add tests for collect rollouts with batch norm

* fix formatting

* update change log

* update version

* remove Optional typing for batch size - causing type check to fail

* Fix scipy dependency for toy text envs

* implement set_training_mode method in BaseModel

* move all tests of train/eval mode to test_train_eval_mode

* call learn with learning_starts = total_timesteps to test that collect_rollouts does not update batch norm

* remove extra calls to set_training_mode in train method of TD3 and SAC

* Allow gradient_steps=0

* Refactor tests

* Add comment + use aliases

* Typos

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
2021-08-30 17:42:41 +02:00
Antonin RAFFIN
2fa06ae8d2
Add Python3.9 CI + upgrade min PyTorch version (#503)
* Add Python3.9 CI + upgrade min PyTorch version

* Upgrade min PyTorch version
2021-07-06 09:32:03 +02:00
Antonin RAFFIN
8a08078ea2
Fix default arguments + add bugbear (#363)
* Fix potential bug + add bug bear

* Remove unused variables

* Minor: version bump
2021-03-25 11:35:21 +02:00
Antonin RAFFIN
944dfdafe4
Update doc: SB3-Contrib (#267)
* Fix big when saving/loading q-net alone

* Rename variables to match SB3-contrib

* Update docker image

* Set min version for tensorboard

* Add SB3-Contrib to doc

* Update DQN

* Apply suggestions from code review

Co-authored-by: Adam Gleave <adam@gleave.me>

* Update wording

Co-authored-by: Adam Gleave <adam@gleave.me>
2020-12-21 16:17:24 +01:00