You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When defining a custom environment using EnvBase and setting run_type_checks=True in the constructor of the base class, you will never get a sanity check check_env_specs() passed. It seems that it is due to an unexpected attempt to invoke a get method on CompositeSpec instance which does not have this method in design.
To Reproduce
Any arbitrary environment based on EnvBase with run_type_checks=True will produce the error when check_env_specs() is invoked:
Traceback (most recent call last):
File "<project-path>/demo.py", line 72, in<module>
check_env_specs(env)
File "<project-path>/venv/lib/python3.11/site-packages/torchrl/envs/utils.py", line 436, in check_env_specs
real_tensordict = env.rollout(3, return_contiguous=return_contiguous)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<project-path>/venv/lib/python3.11/site-packages/torchrl/envs/common.py", line 1585, in rollout
tensordict = self.step(tensordict)
^^^^^^^^^^^^^^^^^^^^^
File "<project-path>/venv/lib/python3.11/site-packages/torchrl/envs/common.py", line 1149, in step
next_tensordict = self._step_proc_data(next_tensordict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<project-path>/venv/lib/python3.11/site-packages/torchrl/envs/common.py", line 1216, in _step_proc_data
is not self.output_spec["full_done_spec"].get(done_key).dtype
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'CompositeSpec' object has no attribute 'get'. Did you mean: 'set'?
Expected behavior
check_env_specs() will pass as normal.
System info
TorchRL version: nightly-2023.9.21
Python version: 3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0]
OS Platform: Linux
Reason and Possible fixes
Here provides a possible and direct fix, but I'm not sure if it is correct:
Describe the bug
When defining a custom environment using
EnvBase
and settingrun_type_checks=True
in the constructor of the base class, you will never get a sanity checkcheck_env_specs()
passed. It seems that it is due to an unexpected attempt to invoke aget
method onCompositeSpec
instance which does not have this method in design.To Reproduce
Any arbitrary environment based on
EnvBase
withrun_type_checks=True
will produce the error whencheck_env_specs()
is invoked:Expected behavior
check_env_specs()
will pass as normal.System info
Reason and Possible fixes
Here provides a possible and direct fix, but I'm not sure if it is correct:
https://github.com/Sefank/rl/commit/3e44b4b32a67a2031b2f73766a9c98f2be9c4b33
Checklist
The text was updated successfully, but these errors were encountered: