Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pre-commit to check for all things gymnasium/pettingzoo does #157

Merged
merged 10 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ title: "[Bug Report] Bug title"
A clear and concise description of what the bug is.

**Code example**
Bug reports without minimal code examples take 5-10x longer to solve.
Bug reports without minimal code examples take 5-10x longer to solve.
We'll give you a cookie if you add the stack trace too!
Save time, add code.

**System Info**
Describe the characteristic of your environment:
* Describe how Minari was installed (pip, docker, source, ...)
* Operating system:
* Operating system:
* Python version:

**Additional context**
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-docs-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Build Datasets Docs
run: python docs/_scripts/gen_dataset_md.py

- name: Build
run: sphinx-build -b dirhtml -v docs _build

Expand All @@ -56,4 +56,4 @@ jobs:
folder: _build
clean-exclude: |
*.*.*/
main
main
2 changes: 1 addition & 1 deletion .github/workflows/manual-build-docs-version copy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:
folder: _build
clean-exclude: |
*.*.*/
main
main
36 changes: 29 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-symlinks
- id: destroyed-symlinks
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-ast
- id: check-added-large-files
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: detect-private-key
- id: debug-statements
- id: mixed-line-ending
args: [ --fix=lf ]
- repo: https://github.com/python/black
rev: 22.8.0
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.2.1
rev: v2.2.6
hooks:
- id: codespell
args:
- --skip=*.css,*.js,*.map,*.scss,*svg
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 6.1.0
hooks:
- id: flake8
args:
Expand All @@ -29,18 +47,18 @@ repos:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.38.0
rev: v3.15.0
hooks:
- id: pyupgrade
# TODO: remove `--keep-runtime-typing` option
args: ["--py37-plus", "--keep-runtime-typing"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
rev: 6.3.0
hooks:
- id: pydocstyle
args:
Expand All @@ -62,4 +80,8 @@ repos:
types: [python]
additional_dependencies: ["[email protected]"]
args:
- --project=pyproject.toml
- --project=pyproject.toml
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.1
hooks:
- id: check-github-workflows
1 change: 0 additions & 1 deletion CODE_OF_CONDUCT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ Attribution
-----------
This Code of Conduct is adapted from `Python's Code of Conduct <https://www.python.org/psf/conduct/>`_, which is under a `Creative Commons License
<https://creativecommons.org/licenses/by-sa/3.0/>`_.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Tutorials are a crucial way to help people learn how to use Minari and we greatl
- You should make a `.md` file for each tutorial within the above directory.
- Each `.md` file should have an "Environment Setup" section and a "Code" section. The title should be of the format `<TUTORIAL_THEME>: <TUTORIAL_TOPIC>`.
- The Environment Setup section should reference the `requirements.txt` file you created using `literalinclude`.
- The Code section should reference the `.py` file you created using `literalinclude`.
- The Code section should reference the `.py` file you created using `literalinclude`.
- `/docs/index.md` should be modified to include every new tutorial.

### Testing your tutorial
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
This repository is licensed as follows:
All assets in this repository are the copyright of the Farama Foundation, except
All assets in this repository are the copyright of the Farama Foundation, except
where prohibited. Contributors to the repository transfer copyright of their work
to the Farama Foundation.

Some code in this repository has been taken from other open source projects
and was originally released under the MIT or Apache 2.0 licenses, with
copyright held by another party. We've attributed these authors and they
retain their copyright to the extent required by law. Everything else
is owned by the Farama Foundation. The Secret Code font was also released under
is owned by the Farama Foundation. The Secret Code font was also released under
the MIT license by Matthew Welch (http://www.squaregear.net/fonts/).
The MIT and Apache 2.0 licenses are included below.

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://pre-commit.com/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://pre-commit.com/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)


<p align="center">
Expand All @@ -18,7 +18,7 @@ To install Minari from [PyPI](https://pypi.org/project/minari/):
pip install minari
```

Note that currently Minari is under a beta release. If you'd like to start testing or contribute to Minari please install this project from source with:
Note that currently Minari is under a beta release. If you'd like to start testing or contribute to Minari please install this project from source with:

```
git clone https://github.com/Farama-Foundation/Minari.git
Expand All @@ -30,7 +30,7 @@ pip install -e .

For an introduction to Minari, see [Basic Usage](https://minari.farama.org/main/content/basic_usage/). To create new datasets using Minari, see our [Pointmaze D4RL Dataset](https://minari.farama.org/main/tutorials/dataset_creation/point_maze_dataset/) tutorial, which re-creates the Maze2D datasets from [D4RL](https://github.com/Farama-Foundation/D4RL).

## API
## API

To check available remote datasets:

Expand Down
2 changes: 1 addition & 1 deletion bin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ WORKDIR /usr/local/minari/

RUN pip install .[testing] --no-cache-dir

ENTRYPOINT ["/usr/local/minari/bin/docker_entrypoint"]
ENTRYPOINT ["/usr/local/minari/bin/docker_entrypoint"]
1 change: 0 additions & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ datasets/pen/*.md
datasets/pointmaze/*.md
datasets/relocate/*.md
datasets/kitchen/*.md

2 changes: 1 addition & 1 deletion docs/404.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# 404 - Page Not Found

## The requested page could not be found.
## The requested page could not be found.
2 changes: 1 addition & 1 deletion docs/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ a.internal-link::after {
to make the mark be on the same line as the link
*/
content: "\00A0↪";
}
}
2 changes: 1 addition & 1 deletion docs/_static/css/directory_tree.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


/* The list style
-------------------------------------------------------------- */
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/img/Minari.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/img/Minari_White.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/img/data-svgrepo-com.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/img/doc_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/img/environment_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/img/file-svgrepo-com.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/img/folder-open-svgrepo-com.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/img/folder-svgrepo-com.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/img/github_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/img/menu_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ function loadVisibleTermynals() {
}
window.addEventListener("scroll", loadVisibleTermynals);
createTermynals();
loadVisibleTermynals();
loadVisibleTermynals();
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

```{eval-rst}
.. autofunction:: minari.EpisodeMetadataCallback.__call__
```
```
2 changes: 1 addition & 1 deletion docs/api/minari_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ minari_dataset/episode_data

```{eval-rst}
.. autofunction:: minari.get_normalized_score
```
```
22 changes: 11 additions & 11 deletions docs/content/basic_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Minari is a standard dataset hosting interface for Offline Reinforcement Learnin

## Installation

To install the most recent version of the Minari library run this command:
To install the most recent version of the Minari library run this command:

```bash
pip install minari
Expand All @@ -30,7 +30,7 @@ We support Python 3.8, 3.9, 3.10 and 3.11 on Linux and macOS.
### Collecting Data

```{eval-rst}
Minari can abstract the data collection process. This is achieved by using the :class:`minari.DataCollectorV0` wrapper which stores the environments stepping data in internal memory buffers before saving the dataset into disk. The :class:`minari.DataCollectorV0` wrapper can also perform caching by scheduling the amount of episodes or steps that are stored in-memory before saving the data in a temporary `Minari dataset file </content/dataset_standards>`_ . This wrapper also computes relevant metadata of the dataset while collecting the data.
Minari can abstract the data collection process. This is achieved by using the :class:`minari.DataCollectorV0` wrapper which stores the environments stepping data in internal memory buffers before saving the dataset into disk. The :class:`minari.DataCollectorV0` wrapper can also perform caching by scheduling the amount of episodes or steps that are stored in-memory before saving the data in a temporary `Minari dataset file </content/dataset_standards>`_ . This wrapper also computes relevant metadata of the dataset while collecting the data.

The wrapper is very simple to initialize:
```
Expand Down Expand Up @@ -73,11 +73,11 @@ for _ in range(total_episodes):
# random action policy
action = env.action_space.sample()
obs, rew, terminated, truncated, info = env.step(action)

if terminated or truncated:
break

dataset = minari.create_dataset_from_collector_env(dataset_id="CartPole-v1-test-v0",
dataset = minari.create_dataset_from_collector_env(dataset_id="CartPole-v1-test-v0",
collector_env=env,
algorithm_name="Random-Policy",
code_permalink="https://github.com/Farama-Foundation/Minari",
Expand Down Expand Up @@ -137,15 +137,15 @@ for episode_id in range(total_episodes):
# random action policy
action = env.action_space.sample()
obs, rew, terminated, truncated, info = env.step(action)

if terminated or truncated:
break

if (episode_id + 1) % 10 == 0:
# Update local Minari dataset every 10 episodes.
# This works as a checkpoint to not lose the already collected data
if dataset is None:
dataset = minari.create_dataset_from_collector_env(dataset_id=dataset_name,
dataset = minari.create_dataset_from_collector_env(dataset_id=dataset_name,
collector_env=env,
algorithm_name="Random-Policy",
code_permalink="https://github.com/Farama-Foundation/Minari",
Expand Down Expand Up @@ -216,7 +216,7 @@ for i in range(5):
```

```{eval-rst}
This code will show the following.
This code will show the following.
```

```bash
Expand Down Expand Up @@ -245,7 +245,7 @@ for episode in episodes_generator:
```

```{eval-rst}
This code will show the following.
This code will show the following.
```

```bash
Expand Down Expand Up @@ -340,7 +340,7 @@ for _ in range(100):

.. note::
There are some datasets that provide a different environment for evaluation purposes than the one used for collecting the data. This environment can be recovered by setting to `True` the `eval_env` argument:

.. code-block::

import minari
Expand All @@ -361,10 +361,10 @@ Lastly, in the case of having two or more Minari datasets created with the same
>>> import minari
>>> human_dataset = minari.load_dataset('door-human-v0')
>>> expert_dataset = minari.load_dataset('door-expert-v0')
>>> combine_dataset = minari.combine_datasets(datasets_to_combine=[human_dataset, expert_dataset],
>>> combine_dataset = minari.combine_datasets(datasets_to_combine=[human_dataset, expert_dataset],
new_dataset_id="door-all-v0")
>>> combine_dataset.name
'door-all-v0'
>>> minari.list_local_datasets()
dict_keys(['door-all-v0', 'door-human-v0', 'door-expert-v0'])
```
```
Loading