question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`ReadOnlyDict` not pickleable

See original GitHub issue

Example:

import pickle
import sacred

cfg = sacred.config.custom_containers.ReadOnlyDict({'foo': {'fizz': 'buzz'}})
cfg_pkl = pickle.dumps(cfg)
cfg_depkl = pickle.loads(cfg_pkl)

Error:

Traceback (most recent call last):
  File "sacred_err2.py", line 6, in <module>
    cfg_depkl = pickle.loads(cfg_pkl)
  File ".../lib/python3.6/site-packages/sacred/config/custom_containers.py", line 232, in _readonly
    self.message,
AttributeError: 'ReadOnlyDict' object has no attribute 'message'

I think custom __getstate__ and __setstate__ methods need to be added. I suspect this will also be a problem for some of the other ReadOnlyContainers.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stale[bot]commented, Dec 25, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

0reactions
stale[bot]commented, Aug 28, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - How to make dictionary read-only? - Stack Overflow
Use collections.Mapping e.g. import collections class DictWrapper(collections.Mapping): def __init__(self, data): self.
Read more >
Source code for dagster._utils
I'm not sure that there are other ways to provoke this behavior on Unix other ... ReadOnlyDict") # https://docs.python.org/3/library/pickle.html#object.
Read more >
Is Pickle the best way to save objects in python? - Quora
No, Pickle should be avoided entirely, as well as serialization libraries which use Pickle internally. It's an extremely dangerous method.
Read more >
shelve — Python object persistence — Python 3.11.1 ...
The difference with “dbm” databases is that the values (not the keys!) ... Because the shelve module is backed by pickle , it...
Read more >
Release Notes — rustworkx 0.12.1 documentation - Qiskit
For the retworkx-core crate, there will no longer be any releases under that ... the Python mapping protocol and can be used inplace...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found