materialsproject / maggma

MongoDB aggregation machine

Home Page:https://materialsproject.github.io/maggma/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FEATURE: Upgraded MSONable

shyamd opened this issue · comments

MSONable is great but has a couple flaws:

  • support pydantic BaseModel for defining the data model
  • better handling of serializing components
  • Better encapsulation of serialization methods. This is particularly a problem where some classes completely break their as_dict and from_dict.

We should start thinking about a new MSONable defined here and then later if desired moved back into monty.

Better integration with pandas would be nice too.

I've been enjoying using a dataclass that also subclasses MSONable recently, very powerful. Not sure how pydantic would works with data classes currently.

Someone doing a review of MP-critical classes and if/why they have custom as_dict/from_dicts would be helpful too, I'm not convinced these are necessary in a majority of cases.