Kaggle / Kaggle/kaggle-environments
Bug for version 1.7.3: 'str' object has no attribute 'action'
- Dominant language
- JavaScript
- Stars
- 452
- Forks
- 190
- Avg merge
- 31m
- Merged PRs (30d)
- 2
Description
With version 1.7.3 installed via pip the following code
```python
from kaggle_environments import make, evaluate
import random
def random_agent(obs, conf):
return random.randrange(conf.banditCount)
env = make("mab", debug=True)
env.run([random_agent, random_agent])
res = env.render(mode="ansi")
```
leads to a `str' object has no attribute 'action'`-error.
There are two options to fix the problem.
Either change in core.py line 279 to `args = [self.steps, self]` (don't know how that would interact for the other environments)
or use `env.steps[i]` in line 135 of mab.py. I will create a PR with the latter option, although I think the first option, if done correctly would lead to a better implementation. Also interesting, that the argument of the `renderer` function is called `steps` but effectively gets the `env.state` object.
Contributor guide
Research direction
Reproduce the error with the provided Python example using version 1.7.3, then inspect core.py line 279 and mab.py line 135. Compare the renderer's steps argument with the environment state and determine which proposed call site is consistent with the other environments. Done means the mab example renders in ansi mode without the 'str' object has no attribute 'action' error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100