Thanks for reaching out! Were you able to resolve this?
While trying to reproduce this, I unfortunately ran into a pydantic validation error and the jsanitize/dumpfn
cycle was very slow. @munrojm and I will have to take a closer look at that.
Disabling document models and monty decoding in MPRester, and going through orjson
for serialization worked well for me, though:
import orjson
import gzip
from mp_api.client import MPRester
with MPRester("api-key", use_document_model=False, monty_decode=False) as mpr:
docs = mpr.materials.summary.search()
option = orjson.OPT_NAIVE_UTC | orjson.OPT_SERIALIZE_NUMPY
dumped = orjson.dumps(docs, option=option)
fn = "mp_docs.json.gz"
with gzip.open(fn, 'wb') as f:
f.write(dumped)
with gzip.open(fn,'rb') as f:
docs = orjson.loads(f.read())
HTH