Skip to content

Commit

Permalink
Remove call to deprecated importlib find_loader (#31)
Browse files Browse the repository at this point in the history
* remove call to deprecated importlib find_loader

* bump version for release

* edit readme for mazelib issue and add small example
  • Loading branch information
smorad authored Jan 5, 2024
1 parent 229f70c commit 2cf8f8e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
name: isort (python)
args: ["--profile", "black"]
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 7.0.0
hooks:
- id: flake8
args:
Expand Down
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@ Please see the [documentation](https://popgym.readthedocs.io/en/latest/) for adv
## Quickstart Install

```python
pip install popgym # base environments only, only requires numpy and gymnasium
pip install --use-pep517 "popgym[navigation]" # also include navigation environments, which require mazelib
pip install "popgym[baselines]" # environments and memory baselines
# Install base environments, only requires numpy and gymnasium
pip install popgym
# Also include navigation environments, which require mazelib
# NOTE: navigation envs require python <3.12 due to mazelib not supporting 3.12
pip install "popgym[navigation]"
# Install memory baselines w/ RLlib
pip install "popgym[baselines]"
```

## Quickstart Usage

```python
import popgym
from popgym.wrappers import PreviousAction, Antialias, Flatten, DiscreteAction
env = popgym.envs.position_only_cartpole.PositionOnlyCartPoleEasy()
print(env.reset(seed=0))
wrapped = DiscreteAction(Flatten(PreviousAction(env))) # Append prev action to obs, flatten obs/action spaces, then map the multidiscrete action space to a single discrete action for Q learning
print(wrapped.reset(seed=0))
```

## POPGym Environments
Expand Down
4 changes: 2 additions & 2 deletions popgym/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""

import inspect
from importlib import find_loader
from importlib.util import find_spec
from typing import Any, Dict

import gymnasium as gym
Expand Down Expand Up @@ -255,7 +255,7 @@
#
def has_mazelib(): # noqa: E302
"""Check if mazelib is installed"""
return find_loader("mazelib") is not None
return find_spec("mazelib") is not None


if has_mazelib():
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = A collection of partially-observable procedural gym environments
long_description = file: README.md
long_description_content_type = text/markdown
author = Steven Morad
version = 1.0.4
version = 1.0.5
license = MIT
readme = README.md
requires_python = >=3.7
Expand Down

0 comments on commit 2cf8f8e

Please sign in to comment.