Farama-Foundation / SuperSuit

A collection of wrappers for Gymnasium and PettingZoo environments (being merged into gymnasium.wrappers and pettingzoo.wrappers
Other
446 stars 56 forks source link

Accessing an env attribute from wrappers #199

Closed opocaj92 closed 1 year ago

opocaj92 commented 1 year ago

Hi all, I have a custom PettingZoo ParallelEnv, that is then converted to a SB3VecEnvWrapper through

vec_env = ss.pettingzoo_env_to_vec_env_v1(env)
vec_env = ss.concat_vec_envs_v1(vec_env, num_envs, num_cpus = 4, base_class = "stable_baselines3")

Now, I need to access an attribute of env, and I am trying with vec_env.get_attr(name) (that SB3VecEnvWrapper should inherit from stable_baselines3's VecEnvWrapper), but I get an error:

AttributeError: 'ConcatVecEnv' object has no attribute 'get_attr'

ConcatVecEnv is inheriting from gym VectorEnv, that indeed has a get_attr(name) method. So, what am I doing wrong here?

My setting the following:

elliottower commented 1 year ago

I was getting this error as well when testing with SB3, I believe this line fixes it (I tested a number of different options and this was the only way of fixing it IIRC) https://github.com/Farama-Foundation/SuperSuit/blob/e27b0e1d4ed724d468f41233154487da28671951/supersuit/vector/sb3_vector_wrapper.py#L41