I have an object (more specifically, a Mujoco environment) that I'm trying to dump with joblib
. However, it seems like whenever I try and reload this object, the object is missing certain property values. For example:
print(env.spec.id)
print(env.data)
joblib.dump({'env': env}, os.path.join('path/to/output', 'vars.pkl'))
state = joblib.load(os.path.join('/path/to/output', 'vars.pkl'))
env2 = state['env']
print(env2.data)
print(env2.spec.id)
produces the following output:
Pitcher-v1
<mujoco._structs.MjData object at 0x7fbd6bbc8cb0>
<mujoco._structs.MjData object at 0x7fbd6bbdb070>
Traceback (most recent call last):
File "path/to/run.py", line 32, in <module>
td3(lambda : gym.make(args.env), actor_critic=MLPActorCritic,
File "path/to/model.py", line 344, in td3
print(env2.spec.id)
AttributeError: 'NoneType' object has no attribute 'id'
Here, I am writing the env
object and reloading it in env2
. env2
is evidently able to produce the correct data
attribute but no longer seems to have the spec.id
attribute.
Is there a reason for this? There was no warning when I ran the script, apart from
WARN: The obs returned by the `step()` method was expecting numpy array dtype to be float32, actual type: float64
UserWarning: WARN: The obs returned by the `step()` method is not within the observation space.
, which I don't think is related here.