Skip to content

Conversation

@jxtrbtk
Copy link

@jxtrbtk jxtrbtk commented Feb 27, 2023

I came across this bug from gym: openai/gym#2752
When time limit is triggered, the output is a bool instead of a dict like {'player_0': False, 'player_1': False}

This produces the following error randomly. It appears sooner or later during the training.

~/.conda/envs/lux_ai_s2/lib/python3.7/site-packages/gym/wrappers/time_limit.py in step(self, action)
16 self._elapsed_steps is not None
17 ), "Cannot call env.step() before calling reset()"
---> 18 observation, reward, done, info = self.env.step(action)
19 self._elapsed_steps += 1
20 if self._elapsed_steps >= self._max_episode_steps:

/tmp/ipykernel_13436/3060603165.py in step(self, action)
57 obs, _, done, info = self.env.step(action)
58 obs = obs[agent]
---> 59 done = done[agent]
60 # if type(done) == type({}): done = done[agent]
61 # elif type(done) == type(True): done = {agent: done, opp_agent: False}

TypeError: 'bool' object is not subscriptable

I sugest this patch to avoid that.

I came across this bug in gym: openai/gym#2752
When time limit is triggered, the output is a bool instead of a dict like {'player_0': False, 'player_1': False}

This produces the following error randomly. It appears sooner or later during the training.

~/.conda/envs/lux_ai_s2/lib/python3.7/site-packages/gym/wrappers/time_limit.py in step(self, action)
     16             self._elapsed_steps is not None
     17         ), "Cannot call env.step() before calling reset()"
---> 18         observation, reward, done, info = self.env.step(action)
     19         self._elapsed_steps += 1
     20         if self._elapsed_steps >= self._max_episode_steps:

/tmp/ipykernel_13436/3060603165.py in step(self, action)
     57         obs, _, done, info = self.env.step(action)
     58         obs = obs[agent]
---> 59         done = done[agent]
     60 #         if type(done) == type({}): done = done[agent]
     61 #         elif type(done) == type(True): done = {agent: done, opp_agent: False}

TypeError: 'bool' object is not subscriptable

I sugest this patch to avoid that.
Patch for gym version 0.21.0 bug
@netlify
Copy link

netlify bot commented Feb 27, 2023

Deploy Preview for lux-eye-s2 canceled.

Name Link
🔨 Latest commit 84e5058
🔍 Latest deploy log https://app.netlify.com/sites/lux-eye-s2/deploys/63fc85767b70520008bde07f

@StoneT2000
Copy link
Member

This is fixed in the latest version of Lux actually. The bug is that the time limit wrapper was around the inner most env instead of outer.

What version of lux are you on?

@jxtrbtk
Copy link
Author

jxtrbtk commented Feb 27, 2023

2.1.0
-> to me seems unchanged on that part since that version

@StoneT2000
Copy link
Member

@jxtrbtk please update to v2.1.9

@jxtrbtk
Copy link
Author

jxtrbtk commented Feb 28, 2023

It seems to be fixed after updating to 2.1.9. Can't be 100% sure as it was sometimes happening after a full night of training and millions of steps. But I have some settings where it was triggering always after only a dozen of minutes and that I used to reproduce this easily. And for this one, it's now passing OK.
Thanks !

@StoneT2000 StoneT2000 closed this Feb 28, 2023
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.

2 participants