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

AttributeError: Can't get attribute 'CompleteAction..."env_name"' => update the example notebook #261

Closed
bmanczak opened this issue Nov 19, 2021 · 2 comments · Fixed by #278 or #279
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@bmanczak
Copy link

bmanczak commented Nov 19, 2021

Environment

  • Grid2op version: 1.6.4
  • System: linux, macOs

Bug description

When supplying a wrapped gym environment to RLib, CompleteAction attribute cannot be fetched. This seems to be independent of the chosen environment.

How to reproduce

I reproduce and describe the issue in this notebook.

Current output

The current error message is

AttributeError: Can't get attribute 'CompleteAction_l2rpn_case14_sandbox' on <module 'grid2op.Space.GridObjects' from '/usr/local/lib/python3.7/dist-packages/grid2op/Space/GridObjects.py'>

Expected output

The desired outcome is portrayed in the notebook, ie. RLib can build the gym environment.

@bmanczak bmanczak added the bug Something isn't working label Nov 19, 2021
@bmanczak
Copy link
Author

The issue is most likely related to how Ray pickles and passes around the objects.

The fix is to modify the initialisation of the wrapped gym environment.
One must not feed self.observation_space (analogically self.action_space) the gym environment observation space directly, but first serialise it as a dictionary and then feed in a gym Dict space.

In the example, this bit:

self.action_space = self.env_gym.action_space
self.observation_space = self.env_gym.observation_space

with this bit:

d = {k: v for k, v in self.env_gym.observation_space.spaces.items()}
self.observation_space = gym.spaces.Dict(d)
        
a = {k: v for k, v in self.env_gym.action_space.items()}
self.action_space = gym.spaces.Dict(a)

@BDonnot
Copy link
Collaborator

BDonnot commented Nov 19, 2021

Thanks for the tips, i will re open the issue and rename it to remember to fix the codalab notebook :-)

Benjamin

@BDonnot BDonnot reopened this Nov 19, 2021
@BDonnot BDonnot changed the title AttributeError: Can't get attribute 'CompleteAction..."env_name"' AttributeError: Can't get attribute 'CompleteAction..."env_name"' => update the example notebook Nov 19, 2021
@BDonnot BDonnot added documentation Improvements or additions to documentation enhancement New feature or request and removed bug Something isn't working labels Nov 19, 2021
BDonnot referenced this issue in BDonnot/Grid2Op Jan 18, 2022
@BDonnot BDonnot linked a pull request Jan 19, 2022 that will close this issue
@BDonnot BDonnot linked a pull request Jan 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants