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

examples now support gym 0.26 #215

Merged
merged 7 commits into from
Oct 31, 2022
Merged

examples now support gym 0.26 #215

merged 7 commits into from
Oct 31, 2022

Conversation

51616
Copy link
Contributor

@51616 51616 commented Oct 30, 2022

Description

Handle interface changes from gym >= 0.26 based on #205 .

Motivation and Context

Some of the examples break with gym >= 0.26

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Example (update in the folder of example)

Implemented Tasks

  • update files in examples: xla_step.py, acme_examples/, cleanrl_examples/ and ppo_atari/

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.
  • I have reformatted the code using make format (required)
  • I have checked the code using make lint (required)
  • I have ensured make bazel-test pass. (required)

examples/xla_step.py Outdated Show resolved Hide resolved
@Trinkle23897
Copy link
Collaborator

Trinkle23897 commented Oct 31, 2022

I believe there should be some changes to sb3_examples, and not sure if cleanrl_examples can run successfully.
@51616 Please run the training command with both gym>=0.26 and gym<0.26 for all your modified scripts (just for a little while, let's say 3 mins for each with any runnable hyper-parameters), and report the status here (a table, see below).
cc @vwxyzjn

Status gym>=0.26 gym<0.26 library version
acme_examples
sb3_examples
cleanrl_examples
tianshou_examples 0.4.10
ppo_atari /

@Trinkle23897
Copy link
Collaborator

@araffin does sb3 support gym>=0.26 now?

@51616
Copy link
Contributor Author

51616 commented Oct 31, 2022

@Trinkle23897 In sb3 script, the reset() and step() calls are handled by sb3 itself. So, I didn't update the scripts unless we want implement a wrapper on top. I will test and fill the table later today.

@araffin
Copy link
Contributor

araffin commented Oct 31, 2022

@araffin does sb3 support gym>=0.26 now?

we have a branch for that (DLR-RM/stable-baselines3#780) but as we use a wrapper anyway, we can support gym 0.26.
I'm also working on having the wrapper directly in the RL Zoo: DLR-RM/rl-baselines3-zoo#307

@51616
Copy link
Contributor Author

51616 commented Oct 31, 2022

I have tested all examples with gym=0.26 and gym=0.21. Also, the sb3 example can now handle gym=0.26.

Status gym>=0.26 gym<0.26 (gym=0.21) library version
acme_examples ✔️ ✔️ acme=0.4.0 (acme.git@84e0923)
sb3_examples ✔️ ✔️ sb3=1.6.2
cleanrl_examples ✔️ ✔️ N/A
tianshou_examples ✔️ ✔️ tianshou=0.4.10
ppo_atari ✔️ ✔️ envpool=0.6.5

env.step = legacy_step
return env

test_env = legacy_wrap(gym.make(env_id))
Copy link
Collaborator

Choose a reason for hiding this comment

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

btw is it possible to work out-of-box if we don't add legacy_wrap?

Copy link
Contributor Author

@51616 51616 Oct 31, 2022

Choose a reason for hiding this comment

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

Without the wrap, it wouldn't work with gym=0.26 using the latest version of sb3 on pip.

if is_legacy_gym:
handle1, (new_states, rew, done, info) = step(handle0, action)
else:
handle1, (new_states, rew, term, trunc, info) = step(handle0, action)
Copy link
Collaborator

Choose a reason for hiding this comment

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

have you tested this for new gym version?

Copy link
Contributor Author

@51616 51616 Oct 31, 2022

Choose a reason for hiding this comment

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

Yes. It works with both gym=0.26 and gym=0.21.

@Trinkle23897 Trinkle23897 merged commit e384d09 into sail-sg:main Oct 31, 2022
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.

None yet

4 participants