Comments (5)
So I determined the issue, although I still think this behavior is suboptimal.
The problem is that I was using a wrapper like this
import gym
class BadWrapper(gym.Wrapper):
def __getattr__(self, name):
return getattr(self.env, name)
in order to be able to access protected variables of an environment if necessary. But this doesn't work when you deepcopy; you end up in an infinite recursion because __getattr__
continuously calls itself:
bad_wrapped_env = BadWrapper(gym.make('Pong-v0'))
bad_copied_env = deepcopy(bad_wrapped_env) # This doesn't work
which raises
Traceback (most recent call last):
File "/home/ahalev/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/ahalev/mgrid/dev/garage_sandbox/wrapper_ex.py", line 17, in <module>
bad_copied_env = deepcopy(bad_wrapped_env)
File "/home/ahalev/.conda/envs/remote_env/lib/python3.6/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/home/ahalev/.conda/envs/remote_env/lib/python3.6/copy.py", line 281, in _reconstruct
if hasattr(y, '__setstate__'):
File "/home/ahalev/mgrid/dev/garage_sandbox/wrapper_ex.py", line 10, in __getattr__
return getattr(self.env, name)
File "/home/ahalev/mgrid/dev/garage_sandbox/wrapper_ex.py", line 10, in __getattr__
return getattr(self.env, name)
File "/home/ahalev/mgrid/dev/garage_sandbox/wrapper_ex.py", line 10, in __getattr__
return getattr(self.env, name)
[Previous line repeated 992 more times]
File "/home/ahalev/mgrid/dev/garage_sandbox/wrapper_ex.py", line 5, in __getattr__
def __getattr__(self, name):
RecursionError: maximum recursion depth exceeded
python-BaseException
Traceback (most recent call last):
File "/home/ahalev/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_resolver.py", line 213, in resolve
return dict[key]
KeyError: '__exception__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ahalev/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 1765, in do_it
var_obj = pydevd_vars.getVariable(self.thread_id, self.frame_id, scope, attrs)
File "/home/ahalev/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_vars.py", line 240, in getVariable
var = resolver.resolve(var, k)
File "/home/ahalev/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_resolver.py", line 215, in resolve
return getattr(dict, key)
AttributeError: 'dict' object has no attribute '__exception__'
I guess this is why the original __getattr__
is written the way that it is, but it seems a little hack-y to me. Maybe even changing __getattr__
to
def __getattr__(self, name):
if name.startswith("__"): # this allows for deepcopy
raise AttributeError(
"attempted to get missing private attribute '{}'".format(name)
)
return getattr(self.env, name)
would be better.
from acme.
This should be fixed at head now.
from acme.
I am also having this issue, with gym 0.21.0. Is there a fix available in a different version?
from acme.
Can you share a minimal repro of the problem?
from acme.
Yeah, I think we can give your suggestion a try. Thanks
from acme.
Related Issues (20)
- D4PG jax agent computes n-step learning target in reverse? HOT 5
- Converting Tensorflow Dataset to `iterator` does not sync well with client HOT 1
- Missleading errors when using discrete action space with `CanonicalSpecWrapper`
- Error importing `matplotlib`
- examples seem to be broken - examples/baselines/rl_continuous HOT 2
- Use of tf.data.Dataset within tf.function HOT 1
- Library broken HOT 1
- Reverb Replay Buffers + Vectorized/Batched Environments HOT 1
- Is the last layer in distributional critic optimized (jax implementation)? HOT 1
- Reference numbers for `reverb_benchmark.py` HOT 2
- The program always executes behavior clone when running CQLLearner.
- Masked actions in MCTS agent
- Implementing HER with Replay Buffer/Reverb HOT 1
- Issue with ACME's Distributional RL Implementation
- How to launch mutil Actors on different machines?
- Use ACME with Ray Tune ASHAScheduler
- XM Docker distributed experiments don't finish cleanly
- Using Quickstart D4PG tutorial with a gpu
- Is there a num_iterations argument in offline examples? HOT 2
- Gymnasium HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acme.