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

Fixed batch spaces where the original space's seed was ignored. Issue 2680 #2727

Merged
merged 41 commits into from
Apr 24, 2022

Conversation

pseudo-rnd-thoughts
Copy link
Contributor

Provides a fix for issue 2680 where the SyncVectorEnv ignores the action space seed

This required changes to the batch_space function for each of the spaces to pass the seed for the batched space
The space constructor seed parameter allows a seeding.RandomNumberGenerator that ignores the seed function if passed

Copy link

@lebrice lebrice left a comment

Choose a reason for hiding this comment

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

Interesting stuff @pseudo-rnd-thoughts !

I left some comments here, hopefully they are useful to you.
I'm not a "real" contributor to Gym, so I'm not approving this PR or anything, just commenting.

Have a good one!

tests/vector/test_spaces.py Outdated Show resolved Hide resolved
tests/vector/test_spaces.py Outdated Show resolved Hide resolved
tests/vector/test_spaces.py Outdated Show resolved Hide resolved
gym/spaces/dict.py Outdated Show resolved Hide resolved
gym/spaces/box.py Outdated Show resolved Hide resolved
gym/spaces/box.py Show resolved Hide resolved
gym/spaces/multi_discrete.py Outdated Show resolved Hide resolved
gym/vector/utils/spaces.py Outdated Show resolved Hide resolved
tests/vector/test_sync_vector_env.py Show resolved Hide resolved
tests/vector/utils.py Show resolved Hide resolved
@pseudo-rnd-thoughts
Copy link
Contributor Author

@lebrice I think I have made all of the changes that you requested, could you review again please?

@jkterry1
Copy link
Collaborator

jkterry1 commented Apr 8, 2022

@pseudo-rnd-thoughts can you please fix tests?

@jkterry1
Copy link
Collaborator

jkterry1 commented Apr 8, 2022

merge conflicts*

@pseudo-rnd-thoughts
Copy link
Contributor Author

pseudo-rnd-thoughts commented Apr 8, 2022

@jkterry1 I have fixed the merge conflicts and passed all of the tests.

However, running the tests locally (on mac) then I'm getting an error with tests/vector/test_shared_memory::test_read_from_shared_memory for all the spaces.
But the problem is that Im getting the problem on the master branch so I dont think that I have introduced an issue. Do you want me to solve this issue in this PR or a separate one?

Edit - The solution was much simpler than I thought and is solved in the commit below

…rocess_write function was unpicklable. Making the function a top-level function solves this error
Copy link

@lebrice lebrice left a comment

Choose a reason for hiding this comment

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

Thanks for the changes @pseudo-rnd-thoughts !

gym/spaces/box.py Show resolved Hide resolved
gym/spaces/dict.py Outdated Show resolved Hide resolved
gym/spaces/tuple.py Outdated Show resolved Hide resolved
gym/utils/seeding.py Outdated Show resolved Hide resolved
gym/vector/utils/spaces.py Outdated Show resolved Hide resolved
gym/vector/utils/spaces.py Outdated Show resolved Hide resolved
tests/vector/test_spaces.py Outdated Show resolved Hide resolved
tests/vector/test_spaces.py Outdated Show resolved Hide resolved
tests/vector/test_spaces.py Show resolved Hide resolved
tests/vector/test_sync_vector_env.py Show resolved Hide resolved
Copy link
Contributor

@RedTachyon RedTachyon left a comment

Choose a reason for hiding this comment

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

Added a bunch of comments. Overall this breaks my brain a little bit, but I think the angle of the solution is fine, so I left some nitpicks for the implementation.

And for the ease of clicking for future me: #2680

gym/spaces/dict.py Outdated Show resolved Hide resolved
gym/spaces/dict.py Outdated Show resolved Hide resolved
gym/utils/seeding.py Outdated Show resolved Hide resolved
gym/vector/utils/spaces.py Outdated Show resolved Hide resolved
tests/vector/test_spaces.py Outdated Show resolved Hide resolved
tests/vector/test_spaces.py Outdated Show resolved Hide resolved
tests/vector/test_spaces.py Show resolved Hide resolved
tests/vector/test_sync_vector_env.py Show resolved Hide resolved
tests/vector/utils.py Show resolved Hide resolved
@RedTachyon
Copy link
Contributor

Ah, and please name the PR in some more descriptive way.

@lebrice
Copy link

lebrice commented Apr 10, 2022

Hey @pseudo-rnd-thoughts just a small remark:
I'd rather mark the conversations as resolved myself when reviewing. This makes it easier to see if my comments are addressed.

Also, and this is perhaps a bit "extra", but I personally like to leave a comment with the hash of the commit that addresses the feedback, something like "fixed in abcdef123", and GitHub will automatically create a link to view the diff for that commit.

This makes the reviewing experience much better. Also, could you please un-resolve the discussions where I left a comment? I don't believe I can do it myself atm.

@pseudo-rnd-thoughts
Copy link
Contributor Author

Thanks, this is my first time working on a project of this size so thanks for the recommendations, I will try to do all of them.

@pseudo-rnd-thoughts pseudo-rnd-thoughts changed the title Issue 2680 Fixed batch spaces where the original space's seed was ignored. Issue 2680 Apr 11, 2022
@pseudo-rnd-thoughts
Copy link
Contributor Author

@lebrice I think that you have made all of the changes necessary.
Would you be able to resolve all of the questions that you think have been solved?

tests/vector/test_spaces.py Outdated Show resolved Hide resolved
tests/vector/test_sync_vector_env.py Show resolved Hide resolved
tests/vector/utils.py Show resolved Hide resolved
@pseudo-rnd-thoughts
Copy link
Contributor Author

@lebrice Sorry I messed up, I have responded to all of your messages but had them as a review and pending and thought they had gone through but they hadn't. Just did that now, I hope my "old" answers are helpful

@RedTachyon
Copy link
Contributor

Looks good now

@jkterry1 jkterry1 merged commit 3354451 into openai:master Apr 24, 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.

4 participants