# New observation and action spaces in Ray 2.0

**URL:** <https://discuss.ray.io/t/new-observation-and-action-spaces-in-ray-2-0/8003>\
**Category:** RLlib\
**Created:** [October 24, 2022, 1:11pm UTC](https://discuss.ray.io/t/new-observation-and-action-spaces-in-ray-2-0/8003 "2022-10-24T13:11:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Username1](https://avatars.discourse-cdn.com/v4/letter/u/ee59a6/32.png) [@Username1](https://discuss.ray.io/u/Username1)\
**Post date:** [October 24, 2022, 1:11pm UTC](https://discuss.ray.io/t/new-observation-and-action-spaces-in-ray-2-0/8003/1 "2022-10-24T13:11:55Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- High: It blocks me to complete my task.

QUESTION: Since the new Ray 2.0 I have experienced errors and warnings that weren’t there before regarding the observation and sample spaces.

**Q1) Can anyone provide a simple working example of how to define these new methods now:**

observation\_space\_sample()  
observation\_space\_contains()  
action\_space\_sample()  
action\_space\_contains()

**Q2) when they are absolutely needed, and when they can be left without implementation)**

Thanks!

---

<div class="post-metadata">

**Author:** ![mgerstgrasser](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mgerstgrasser/32/2728_2.png) [@mgerstgrasser](https://discuss.ray.io/u/mgerstgrasser)\
**Post date:** [October 26, 2022, 1:55am UTC](https://discuss.ray.io/t/new-observation-and-action-spaces-in-ray-2-0/8003/2 "2022-10-26T01:55:18Z")

</div>

If your spaces are `gym.spaces` objects, they should already have those methods. Is it possible you have defined your space as something else instead? E.g. a python Tuple instead of a gym spaces Tuple?

I believe for multiagent envs, this should now be a `gym.spaces.Dict` that maps from agent IDs to their respective spaces. (But not just a python dict, I think.)

Setting `"disable_env_checking": True` in your config might also do the trick, although I’m not 100% sure that there aren’t any other bits of code that use those methods.

---

<div class="post-metadata">

**Author:** ![arturn](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/arturn/32/2096_2.png) [@arturn](https://discuss.ray.io/u/arturn)\
**Post date:** [October 26, 2022, 5:27pm UTC](https://discuss.ray.io/t/new-observation-and-action-spaces-in-ray-2-0/8003/3 "2022-10-26T17:27:30Z")

</div>

We’ve merged [a related PR](https://github.com/ray-project/ray/pull/28737) a couple of weeks back that should now be in Ray 2.0.1. Does this resolve your issue?

---

<div class="post-metadata">

**Author:** ![Username1](https://avatars.discourse-cdn.com/v4/letter/u/ee59a6/32.png) [@Username1](https://discuss.ray.io/u/Username1)\
**Post date:** [October 27, 2022, 8:14am UTC](https://discuss.ray.io/t/new-observation-and-action-spaces-in-ray-2-0/8003/4 "2022-10-27T08:14:05Z")

</div>

Thank you very much.
