Skip to content

Make it clear when the observation doesn't match the defined space #460

@fedor-chervinskii

Description

@fedor-chervinskii

I've been implementing my own env wrapper and run into the problem with this traceback:

Traceback (most recent call last):                                                                                                                            
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap                                                
    self.run()                                                                                                                                                
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/multiprocessing/process.py", line 93, in run                                                        
    self._target(*self._args, **self._kwargs)                                                                                                                 
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/catalyst/rl/scripts/run_samplers.py", line 154, in run_sampler                        
    sampler.run()                                                                                                                                             
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/catalyst/rl/core/sampler.py", line 317, in run                                        
    self._start_sample_loop()                                                                                                                                 
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/catalyst/rl/core/sampler.py", line 313, in _start_sample_loop                         
    self._run_sample_loop()                                                                                                                                   
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/catalyst/rl/core/sampler.py", line 291, in _run_sample_loop                           
    trajectory, trajectory_info = self._run_trajectory_loop()                                                                                                 
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 49, in decorate_no_grad                            
    return func(*args, **kwargs)                                                                                                                              
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/catalyst/rl/core/sampler.py", line 264, in _run_trajectory_loop                       
    self.trajectory_sampler.reset(exploration_strategy)                                                                                                       
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 49, in decorate_no_grad                            
    return func(*args, **kwargs)                                                                                                                              
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/catalyst/rl/core/trajectory_sampler.py", line 139, in reset                           
    self._init_with_observation(observation)                                                                                                                  
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/catalyst/rl/core/trajectory_sampler.py", line 77, in _init_with_observation           
    self.observations.append(observation)                                                                                                                     
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/catalyst/utils/dynamic_array.py", line 154, in append                                 
    value = self._as_dtype(value)                                                                                                                             
  File "/Users/fedor/anaconda3/envs/vpg-env/lib/python3.6/site-packages/catalyst/utils/dynamic_array.py", line 140, in _as_dtype                              
    for key in self._dtype.fields.keys():                                                                                                                     
AttributeError: 'NoneType' object has no attribute 'keys'        

Which tells nothing about what actually happened. It happened that I forgot to instantiate my observation space as a gym.spaces.Dict(). So I'm proposing to add a little self-explanatory exception to help if people who will run into the same problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions