-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
Description
Overview
Given a Store.to_json() representation, one would ideally be able to use MontyDecoder to regenerate the Store object. This works for MemoryStore, MongoStore, etc. but does not work for MontyStore for reasons I have not yet understood.
Sidenote: very confusing here that MontyStore refers to MontyDB but MontyDecoder is the monty package 😅
Example
from maggma.stores import MontyStore
from monty.json import MontyDecoder
store = MontyStore("test")
store_json = store.to_json()
store_remade = MontyDecoder().decode(store_json) 3 store = MontyStore("test")
4 store_json = store.to_json()
----> 5 store_remade = MontyDecoder().decode(store_json)
File ~/software/miniconda/envs/quacc/lib/python3.10/site-packages/monty/json.py:497, in
MontyDecoder.decode(self, s)
495 else:
496 d = json.loads(s)
--> 497 return self.process_decoded(d)
File ~/software/miniconda/envs/quacc/lib/python3.10/site-packages/monty/json.py:444, in
MontyDecoder.process_decoded(self, d)
442 if hasattr(cls_, "from_dict"):
443 return cls_.from_dict(data)
--> 444 if pydantic is not None and issubclass(cls_, pydantic.BaseModel): # pylint: disable=E1101
445 return cls_(**data)
446 if (
447 dataclasses is not None
448 and (not issubclass(cls_, MSONable))
449 and dataclasses.is_dataclass(cls_)
450 ):
File ~/software/miniconda/envs/quacc/lib/python3.10/abc.py:123, in ABCMeta.__subclasscheck__(cls, subclass)
121 def __subclasscheck__(cls, subclass):
122 """Override for issubclass(subclass, cls)."""
--> 123 return _abc_subclasscheck(cls, subclass)
TypeError: issubclass() arg 1 must be a classAlternatives
I also tried MontyDecoder().process_decoded(store.as_dict()), but that led to the same error.