Skip to content

Error when saving wrapper #132

@fernanqv

Description

@fernanqv

I have created a wrapper that inherits from BaseModelWrapper. After building the model I try to save it into a pickle with this command:

GTSM_wrapper.save_model(model_path="Snellius_GTSM_model.pkl")

And I get this error:

(bluemath-dev) [vfernandez@int4 GTSM_bluemath]$ /home/vfernandez/.conda/envs/bluemath-dev/bin/python /home/vfernandez/repos/GTSM_bluemath/GTSM_create_simulations.py
Traceback (most recent call last):
  File "/home/vfernandez/repos/GTSM_bluemath/GTSM_create_simulations.py", line 26, in <module>
    GTSM_wrapper.save_model(model_path="Snellius_GTSM_model.pkl")
  File "/gpfs/home1/vfernandez/repos/bluemath_tk/bluemath_tk/core/models.py", line 239, in save_model
    pickle.dump(self, f)
TypeError: cannot pickle 'weakref.ReferenceType' object

I have debugged the error and the error is triggered because the self._logger and self._env variables are not serializable. If I exclude them, the save method works.

The error can be reproduced running the script GTSM_create_simulations.py of the GitHub repo https://github.com/fernanqv/GTSM_bluemath

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions