Open srikiran-cpn opened 1 year ago
It seems that when pickling the box, only the outer most box is set to box_dots=True for some reason.
from box import Box
import pickle
b2 = Box(
{
"l1": {
"time_range_selected_utc": {
"left": "2023-03-01 10:00:00",
"right": "2023-06-01 10:00:00",
}
},
},
**{'box_dots': True, 'conversion_box': False, 'frozen_box': False}
)
pickle.dump(b2, open("testpickle", "wb"))
loaded = pickle.load(open("testpickle", "rb"))
print(loaded._box_config)
print(loaded["l1"]) # Works
print(loaded["l1"]._box_config)
print(loaded["l1.time_range_selected_utc"]) # Works
print(loaded["l1.time_range_selected_utc"]._box_config)
print(loaded["l1.time_range_selected_utc.left"]) # Breaks
I have a use case where I want to cache boxes and read them back again. Below is a MWE using
joblib
for caching but I also found it doesn't work Flask caching. I think some metadata is lost when caching the box, so the retrieved box somehow is not a box withbox_dots = True
.Code
Output