Skip to content

Commit

Permalink
Replace gym for gymnasium (#16)
Browse files Browse the repository at this point in the history
* Update version and gymnasium dependency

* Update README

* Update tests

* Update utils

* Update envs

* Migrate MORecordEpisodeStatistics

* Fix imports

* Support for Mario

* Fix reacher render_modes

* Install gymnasium[mujoco]

* Remove wrapper test

* Fix  yml

* test

* Update .toml

* Renaming mo_gym package to mo_gymnasium

* Fix wrapper tests

* Rename to mo-gymnasium in setup stuff too

* Merge main into branch

* Isort

* Remove all deps for gymnasium install in tests

* Skip mujoco tests

* Add skip_render_check=True

* Add imageio dependency

* Include test wrappers

* Modify descriptions for pypi

* Convert highway env observation from gym to gymnasium

* isort

* black

* black

Co-authored-by: Florian Felten <florian.felten@uni.lu>
  • Loading branch information
LucasAlegre and ffelten committed Jan 23, 2023
1 parent f66ecd9 commit 48e3b52
Show file tree
Hide file tree
Showing 76 changed files with 958 additions and 730 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ jobs:
git clone https://github.com/benelot/pybullet-gym.git
pip install -e pybullet-gym
sudo apt-get install libglu1-mesa-dev libgl1-mesa-dev libosmesa6-dev xvfb patchelf ffmpeg cmake swig
pip install gym
pip install gymnasium
pip install -e .[all]
- name: Full Python tests
run: |
pytest tests/
pytest tests/test_envs.py
pytest tests/test_wrappers.py
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ repos:
rev: 6.1.1
hooks:
- id: pydocstyle
exclude: ^(mo_gym/envs/)|(tests/)|(docs/)|(setup.py)
exclude: ^(mo_gymnasium/envs/)|(tests/)|(docs/)|(setup.py)
args:
- --source
- --explain
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ For details on multi-objective MDP's (MOMDP's) and other MORL definitions, see [

Via pip:
```bash
pip install mo-gym
pip install mo-gymnasium
```

Alternatively, you can install the newest unreleased version:
Expand All @@ -30,8 +30,8 @@ pip install -e .
## Usage

```python
import gym
import mo_gym
import gymnasium as gym
import mo_gymnasium as mo_gym

env = mo_gym.make('minecart-v0') # It follows the original gym's API ...

Expand All @@ -42,7 +42,7 @@ next_obs, vector_reward, terminated, truncated, info = env.step(your_agent.act(o
env = mo_gym.LinearReward(env, weight=np.array([0.8, 0.2, 0.2]))
```

[![MO-Gym Demo in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Farama-Foundation/MO-Gymnasium/blob/main/mo_gym_demo.ipynb)
[![MO-Gym Demo in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Farama-Foundation/MO-Gymnasium/blob/main/mo_gymnasium_demo.ipynb)
You can also check more examples in this colab notebook!

[MORL-Baselines](https://github.com/LucasAlegre/morl-baselines) is a repository containing various implementations of multi-objective reinforcement learning algorithms. It relies on the MO-Gymnasium API and shows various examples of the usage of wrappers and environments.
Expand Down
6 changes: 3 additions & 3 deletions docs/api/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ The environments follow the standard [gymnasium's API](https://github.com/Farama

Here is a minimal example of how to create an environment and interact with it.
```python
import gym
import mo_gym
import gymnasium
import mo_gymnasium as mo_gym

env = mo_gym.make('minecart-v0') # It follows the original Gymnasium API ...

Expand All @@ -19,5 +19,5 @@ next_obs, vector_reward, terminated, truncated, info = env.step(your_agent.act(o
env = mo_gym.LinearReward(env, weight=np.array([0.8, 0.2, 0.2]))
```

[![MO-Gym Demo in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/LucasAlegre/mo-gym/blob/main/mo_gym_demo.ipynb)
[![MO-Gym Demo in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/LucasAlegre/mo-gym/blob/main/mo_gymnasium_demo.ipynb)
You can also check more examples in this colab notebook!
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ For details on multi-objective MDP's (MOMDP's) and other MORL definitions, see [

### From Pypi
```bash
pip install mo-gym
pip install mo-gymnasium
```

### From source
Expand Down
12 changes: 6 additions & 6 deletions docs/wrappers/wrappers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ title: "Wrappers"

# Wrappers

A few wrappers inspired from Gymnasium's wrappers are available in MO-Gymnasium. They are all available directly from the `mo_gym` module.
A few wrappers inspired from Gymnasium's wrappers are available in MO-Gymnasium. They are all available directly from the `mo_gymnasium` module.


## `LinearReward`


```{eval-rst}
.. autoclass:: mo_gym.LinearReward
.. autoclass:: mo_gymnasium.LinearReward
```

## `MONormalizeReward`

```{eval-rst}
.. autoclass:: mo_gym.MONormalizeReward
.. autoclass:: mo_gymnasium.MONormalizeReward
```

## `MOClipReward`

```{eval-rst}
.. autoclass:: mo_gym.MOClipReward
.. autoclass:: mo_gymnasium.MOClipReward
```

## `MOSyncVectorEnv`

```{eval-rst}
.. autoclass:: mo_gym.MOSyncVectorEnv
.. autoclass:: mo_gymnasium.MOSyncVectorEnv
```

## `MORecordEpisodeStatistics`

```{eval-rst}
.. autoclass:: mo_gym.MORecordEpisodeStatistics
.. autoclass:: mo_gymnasium.MORecordEpisodeStatistics
```
15 changes: 0 additions & 15 deletions mo_gym/envs/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions mo_gym/envs/breakable_bottles/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions mo_gym/envs/continuous_mountain_car/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions mo_gym/envs/deep_sea_treasure/__init__.py

This file was deleted.

7 changes: 0 additions & 7 deletions mo_gym/envs/fishwood/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions mo_gym/envs/four_room/__init__.py

This file was deleted.

4 changes: 0 additions & 4 deletions mo_gym/envs/fruit_tree/__init__.py

This file was deleted.

6 changes: 0 additions & 6 deletions mo_gym/envs/highway/__init__.py

This file was deleted.

49 changes: 0 additions & 49 deletions mo_gym/envs/highway/highway.py

This file was deleted.

8 changes: 0 additions & 8 deletions mo_gym/envs/mario/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions mo_gym/envs/mountain_car/__init__.py

This file was deleted.

14 changes: 0 additions & 14 deletions mo_gym/envs/mujoco/__init__.py

This file was deleted.

9 changes: 0 additions & 9 deletions mo_gym/envs/reacher/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions mo_gym/envs/resource_gathering/__init__.py

This file was deleted.

4 changes: 0 additions & 4 deletions mo_gym/envs/water_reservoir/__init__.py

This file was deleted.

Loading

0 comments on commit 48e3b52

Please sign in to comment.