Skip to content

Commit

Permalink
Merge branch 'main' into added_dataset_size
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyansjainn authored Oct 24, 2023
2 parents 8268a00 + dd8406e commit 8106840
Show file tree
Hide file tree
Showing 24 changed files with 1,045 additions and 1,056 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Save time, add code.

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

Expand All @@ -23,4 +23,4 @@ Add any other context about the problem here.

### Checklist

- [ ] I have checked that there is no similar [issue](https://github.com/Farama-Foundation/PettingZoo/issues) in the repo (**required**)
- [ ] I have checked that there is no similar [issue](https://github.com/Farama-Foundation/Minari/issues) in the repo (**required**)
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/proposal.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Proposal
about: Propose changes that are not fixes bugs
about: Propose changes that do not fix bugs
title: "[Proposal] Proposal title"
---

Expand Down Expand Up @@ -28,4 +28,4 @@ Add any other context or screenshots about the feature request here.

### Checklist

- [ ] I have checked that there is no similar [issue](https://github.com/Farama-Foundation/PettingZoo/issues) in the repo (**required**)
- [ ] I have checked that there is no similar [issue](https://github.com/Farama-Foundation/Minari/issues) in the repo (**required**)
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
hooks:
- id: flake8
args:
- '--per-file-ignores=*/__init__.py:F401 test/all_parameter_combs_test.py:F405 pettingzoo/classic/go/go.py:W605'
- '--per-file-ignores=*/__init__.py:F401'
- --extend-ignore=E203
- --max-complexity=205
- --max-line-length=300
Expand Down Expand Up @@ -48,7 +48,7 @@ repos:
- --count
# TODO: Remove ignoring rules D101, D102, D103, D105
- --add-ignore=D100,D107,D101,D102,D103,D105
exclude: "__init__.py$|^pettingzoo.test|^docs"
exclude: "__init__.py$|^docs"
additional_dependencies: ["toml"]
- repo: local
hooks:
Expand Down
2 changes: 1 addition & 1 deletion minari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"get_normalized_score",
]

__version__ = "0.4.1"
__version__ = "0.4.2"
23 changes: 12 additions & 11 deletions minari/data_collector/callbacks/episode_metadata.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import h5py
from typing import Dict

import numpy as np


class EpisodeMetadataCallback:
"""Callback to full episode after saving to hdf5 file as a group.
This callback can be overridden to add extra metadata attributes or statistics to
each HDF5 episode group in the Minari dataset. The custom callback can then be
each episode in the Minari dataset. The custom callback can then be
passed to the DataCollectorV0 wrapper to the `episode_metadata_callback` argument.
TODO: add more default statistics to episode datasets
"""

def __call__(self, eps_group: h5py.Group):
def __call__(self, episode: Dict):
"""Callback method.
Override this method to add custom attribute metadata to the episode group.
Args:
eps_group (h5py.Group): the HDF5 group that contains an episode's datasets
episode (dict): the dict that contains an episode's data
"""
eps_group["rewards"].attrs["sum"] = np.sum(eps_group["rewards"])
eps_group["rewards"].attrs["mean"] = np.mean(eps_group["rewards"])
eps_group["rewards"].attrs["std"] = np.std(eps_group["rewards"])
eps_group["rewards"].attrs["max"] = np.max(eps_group["rewards"])
eps_group["rewards"].attrs["min"] = np.min(eps_group["rewards"])

eps_group.attrs["total_steps"] = eps_group["rewards"].shape[0]
return {
"rewards_sum": np.sum(episode["rewards"]),
"rewards_mean": np.mean(episode["rewards"]),
"rewards_std": np.std(episode["rewards"]),
"rewards_max": np.max(episode["rewards"]),
"rewards_min": np.min(episode["rewards"]),
}
8 changes: 4 additions & 4 deletions minari/data_collector/callbacks/step_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Any, Dict, Optional
from typing_extensions import TypedDict
from typing import Any, Dict, Optional, TypedDict

import gymnasium as gym

Expand All @@ -19,6 +18,7 @@ class StepData(TypedDict):
"rewards",
"truncations",
"terminations",
"infos",
}


Expand Down Expand Up @@ -58,8 +58,8 @@ def __call__(self, env, **kwargs):
return step_data
The episode groups in the HDF5 file of this Minari dataset will contain a subgroup called `environment_states` with dataset `velocity` and another subgroup called `pose`
with datasets `position` and `orientation`
The Minari dataset will contain a dictionary called `environment_states` with `velocity` value and another dictionary `pose`
with `position` and `orientation`
Args:
env (gym.Env): current Gymnasium environment.
Expand Down
Loading

0 comments on commit 8106840

Please sign in to comment.