Commit Graph

20 Commits

Author SHA1 Message Date
Mark Towers
1c62d3c6ad Add Pydocstyle to CI (#2785)
* Added pydocstyle to pre-commit

* Added docstrings for tests and updated the tests for autoreset

* Add pydocstyle exclude folder to allow slowly adding new docstrings

* Add docstrings for setup.py and gym/__init__.py, core.py, error.py and logger.py

* Check that all unwrapped environment are of a particular wrapper type

* Reverted back to import gym.spaces.Space to gym.spaces

* Fixed the __init__.py docstring

* Fixed autoreset autoreset test

* Updated gym __init__.py top docstring

* Remove unnecessary import

* Removed "unused error" and make APIerror deprecated at gym 1.0

* Add pydocstyle description to CONTRIBUTING.md

* Added docstrings section to CONTRIBUTING.md

* Added :meth: and :attr: keywords to docstrings

* Added :meth: and :attr: keywords to docstrings

* Update the step docstring placing the return type in the as a note.

* Updated step return type to include each element

* Update maths notation to reward range

* Fixed infinity maths notation
2022-05-10 10:35:45 -04:00
Mark Towers
31e6f23e67 Add pyright to precommit (#2796) 2022-05-09 11:22:49 -04:00
Mark Towers
bf093c6890 Update the flake8 pre-commit ignores (#2778)
* Remove additional ignores from flake8

* Remove all unused imports

* Remove all unused imports

* Update flake8 and pyupgrade

* F841, removed unused variables

* E731, removed lambda assignment to variables

* Remove E731, F403, F405, F524

* Remove E722, bare exceptions

* Remove E712, compare variable == True or == False to is True or is False

* Remove E402, module level import not at top of file

* Added --pre-file-ignores

* Add --per-file-ignores removing E741, E302 and E704

* Add E741, do not use variables named ‘l’, ‘O’, or ‘I’ to ignore issues in classic control

* Fixed issues for pytest==6.2

* Remove unnecessary # noqa

* Edit comment with the removal of E302

* Added warnings and declared module, attr for pyright type hinting

* Remove unused import

* Removed flake8 E302

* Updated flake8 from 3.9.2 to 4.0.1

* Remove unused variable
2022-04-26 11:18:37 -04:00
Andrea PIERRÉ
d653ebf3b7 Remove mandatory version in environment name (#2535)
* refactor: required version in env name

* refactor: rename env_id function

* refactor: regex + function logic

* test: some more edge cases + error

* refactor: version max/comparison

- Move version max/comparison in a method
- Remove type ignore to improve type checking

* fix: failing tests & error introduced in rebasing

* refactor: simplify map and remove type ignore

* refactor: remove _is_lesser_version() method

* refactor: _versions() to return NamedTuples

* chore: remove minor changes

* Refactor registration EnvSpec and EnvSpecTree

* test: move tests from #2513 here

* fix: typing

* test: try to fix unregistered env

* refactor: change InitVar id name for typing

Changed InitVar id name to fix the following typing error:
error: Declaration "id" is obscured by a declaration of the same name

* refactor: return only the first difflib match

* test: improve tear down of added test env

* refactor: dataclass fields

* refactor: compile regex pattern only once

* refactor: `_assert_version_exists()`

`_assert_version_exists()` rewritten from @JesseFarebro:
https://github.com/openai/gym/pull/2535#discussion_r777573839

* refactor: latest_spec -> latest_versioned_spec

* fix: bug + typing + test

* Add default/versioned tests

* Fix Env field defaults

* feat: improve versioned/unversioned env handling

* Disallow versioned/unversioned registration/lookup

* test: remove warning + check default suggestion

Co-authored-by: Jesse Farebrother <jessefarebro@gmail.com>
2022-01-19 13:50:25 -05:00
J K Terry
42a4a09f5b 3.10 support (#2493)
* test again

* typo
2021-11-20 11:41:27 -05:00
Elijah K
a4da53c210 Py36+ syntax in gym/*.py: derived by running pyupgrade --py36-plus gym/*.py and flynt gym --ll 120 (#2473)
Co-authored-by: Ilya Kamen <ilya.kamenshchikov@bosch.com>
2021-11-14 08:50:40 -05:00
J K Terry
78d2b512d8 redo black (#2272) 2021-07-29 15:39:42 -04:00
Justin Terry
e9d2c41f2b redo black 2021-07-29 12:42:48 -04:00
Christian Clauss
bb81e141ea Blacken the codebase (#2265) 2021-07-28 20:26:34 -04:00
Tristan Deleu
58401db97e Allow custom spaces in VectorEnv (#2038)
* Allow custom observation spaces in VectorEnv

* Replace np.copy by deepcopy in reset of SyncVectorEnv

* Add tests for VectorEnv with custom spaces

* Add tests for shared memory and batches of custom spaces

* Remove unused import in VectorEnv test

* Add warning note in the Space class for custom spaces
2020-09-21 13:38:51 -07:00
Tristan Deleu
c6a97e17ee Vectorized environments (#1513)
* Initial version of vectorized environments

* Raise an exception in the main process if child process raises an exception

* Add list of exposed functions in vector module

* Use deepcopy instead of np.copy

* Add documentation for vector utils

* Add tests for copy in AsyncVectorEnv

* Add example in documentation for batch_space

* Add cloudpickle dependency in setup.py

* Fix __del__ in VectorEnv

* Check if all observation spaces are equal in AsyncVectorEnv

* Check if all observation spaces are equal in SyncVectorEnv

* Fix spaces non equality in SyncVectorEnv for Python 2

* Handle None parameter in create_empty_array

* Fix check_observation_space with spaces equality

* Raise an exception when operations are out of order in AsyncVectorEnv

* Add version requirement for cloudpickle

* Use a state instead of binary flags in AsyncVectorEnv

* Use numpy.zeros when initializing observations in vectorized environments

* Remove poll from public API in AsyncVectorEnv

* Remove close_extras from VectorEnv

* Add test between AsyncVectorEnv and SyncVectorEnv

* Remove close in check_observation_space

* Add documentation for seed and close

* Refactor exceptions for AsyncVectorEnv

* Close pipes if the environment raises an error

* Add tests for out of order operations

* Change default argument in create_empty_array to np.zeros

* Add get_attr and set_attr methods to VectorEnv

* Improve consistency in SyncVectorEnv
2019-06-21 14:29:44 -07:00
cclauss
687a65f712 Use feature detection instead of version detection (#846)
https://docs.python.org/3/howto/pyporting.html#use-feature-detection-instead-of-version-detection
2018-02-02 23:02:55 -08:00
Jie Tang
28913dad94 Add retries to benchmark upload 2017-03-06 13:46:37 -08:00
Jie Tang
a81a631b2e Add error when wrapping after configure 2016-12-28 13:08:47 -08:00
Tom Brown
2d44ed4968 Add Monitored wrapper (#434)
* Add WIP Monitored wrapper

* Remove irrelevant render after close monitor test

* py27 compatibility

* Fix test_benchmark

* Move Monitored out of wrappers __init__

* Turn Monitored into a function that returns a Monitor class

* Fix monitor tests

* Remove deprecated test

* Remove deprecated utility

* Prevent duplicate wrapping, add test

* Fix test

* close env in tests to prevent writing to nonexistent file

* Disable semisuper tests

* typo

* Fix failing spec

* Fix monitoring on semisuper tasks

* Allow disabling of duplicate check

* Rename MonitorManager

* Monitored -> Monitor

* Clean up comments

* Remove cruft
2016-12-23 16:21:42 -08:00
Greg Brockman
934b2acbb7 Add benchmark support (#338)
* Warn if seed doesn't return a list

* Add preliminary BenchmarkRun support

* Add experimental benchmark registration

* Flesh out interface

* Add preliminary BenchmarkRun support

* Warn if seed doesn't return a list

* Add experimental benchmark registration

* Flesh out interface

* Make benchmarkrun upload recursive

* Add evaluation episodes

* Add benchmark scoring

* Tweak reward locations

* Tweak scoring

* Clear default metadata in Wrapper

* Improve scoring

* Expose registry; fix test

* Add initial_reset_timestamp

* Add back algorithm; fix tests
2016-09-23 01:04:26 -07:00
Greg Brockman
58e6aa95e5 [WIP] add support for seeding environments (#135)
* Make environments seedable

* Fix monitor bugs

- Set monitor_id before setting the infix. This was a bug that would yield incorrect results with multiple monitors.
- Remove extra pid from stats recorder filename. This should be purely cosmetic.

* Start uploading seeds in episode_batch

* Fix _bigint_from_bytes for python3

* Set seed explicitly in random_agent

* Pass through seed argument

* Also pass through random state to spaces

* Pass random state into the observation/action spaces

* Make all _seed methods return the list of used seeds

* Switch over to np.random where possible

* Start hashing seeds, and also seed doom engine

* Fixup seeding determinism in many cases

* Seed before loading the ROM

* Make seeding more Python3 friendly

* Make the MuJoCo skipping a bit more forgiving

* Remove debugging PDB calls

* Make setInt argument into raw bytes

* Validate and upload seeds

* Skip box2d

* Make seeds smaller, and change representation of seeds in upload

* Handle long seeds

* Fix RandomAgent example to be deterministic

* Handle integer types correctly in Python2 and Python3

* Try caching pip

* Try adding swap

* Add df and free calls

* Bump swap

* Bump swap size

* Try setting overcommit

* Try other sysctls

* Try fixing overcommit

* Try just setting overcommit_memory=1

* Add explanatory comment

* Add what's new section to readme

* BUG: Mark ElevatorAction-ram-v0 as non-deterministic for now

* Document seed

* Move nondetermistic check into spec
2016-05-29 09:07:09 -07:00
Jie Tang
edaf643c57 Remove deprecated env file, report different error for deprecated envs 2016-05-18 17:56:51 -07:00
JKCooper2
3c983b9f1d Set restriction on selected actions for MountainCar-v0 (#47)
* Set restriction on selected actions

* Used self.action_space instead of custom set

* Move action validation to core.py
2016-05-03 21:40:24 -04:00
Greg Brockman
e8f2980603 Initial release. Hello world :). 2016-04-27 08:00:58 -07:00