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

Gym-Gymnasium compatibility converter #61

Merged
merged 16 commits into from
Oct 20, 2022

Conversation

RedTachyon
Copy link
Member

@RedTachyon RedTachyon commented Oct 18, 2022

Based on many external discussions, this implements a way to use gym environments inside gymnasium.

They can be created in two ways -- either pass it by name with optional arguments to create an env from the gym registry:

import gymnasium as gym
gym.make("GymV26Environment-v0", env_id="CartPole-v0", make_kwargs={...})

or use an arbitrary instantiated gym env

import gymnasium
import gym
env = gym.make(...)
gymnasium.make("GymV26Environment-v0", env=env)

At the moment it only supports the modern API used in gym 0.26, in the future we might add support for the old API, though at that point it might enter a dependency hell. We'll see.

Copy link
Member

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of initial comments

gymnasium/envs/external/gym_env.py Outdated Show resolved Hide resolved
gymnasium/envs/external/gym_env.py Outdated Show resolved Hide resolved
gymnasium/envs/external/gym_env.py Show resolved Hide resolved
Copy link
Member

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is all good, could you update the PR top comment from "WiP" to be more descriptive and provide a short description of the PR rational over the prior ideas

Copy link
Member

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a __get_attr__ function to get attributes from the gym environment

@RedTachyon
Copy link
Member Author

Do we want a __get_attr__ function to get attributes from the gym environment

I'd rather not do that, I'm already slightly uneasy with the way getattr is handled in wrappers. If users need to access something from the backend environment, they can just do env.gym_env.something and it's clear where it comes from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants