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

Tuple Spaces do not convert to json properly #62

Open
zamorarr opened this issue May 18, 2018 · 3 comments
Open

Tuple Spaces do not convert to json properly #62

zamorarr opened this issue May 18, 2018 · 3 comments

Comments

@zamorarr
Copy link

Hi. Thanks for making gym available to other languages. I'm currently seeing an error when trying to reset the Blackjack-v0 environment. Here's a reproducible example using curl

# start the server
python gym_http_server.py

# create blackjack instance
curl -d '{"env_id":"Blackjack-v0"}' -H "Content-Type: application/json" -X POST http://127.0.0.1:5000/v1/envs/

# reset instance
curl -X POST http://127.0.0.1:5000/v1/envs/<instance_id>/reset/

The issue I believe is caused when calling env.observation_space.to_jsonable(obs) in reset(). The to_jsonable method expects a list of tuples for Blackjack, not a single tuple.

My current workaround is to check to see if the observation is a tuple and if so, wrap it a list first. This works fine for Blackjack but I haven't tested the other environments.

def reset(self, instance_id):
    env = self._lookup_env(instance_id)
    obs = env.reset()
    if (isinstance(obs, tuple)):
        obs = [obs]
    return env.observation_space.to_jsonable(obs)
@markroxor
Copy link

Facing the same issue. I think you should send a PR.

@zamorarr
Copy link
Author

zamorarr commented Sep 5, 2018

Submitted a PR, but I don't even know if this repo is still being maintained...

@masonlr
Copy link

masonlr commented May 11, 2020

Possibly related to openai/gym#1841

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

No branches or pull requests

3 participants