[Feature Request]: pickleable GGA pymatgen.entries.computed_entries.ComputedStructureEntry
Problem
I would like to cache the results of API calls, as documented as point 4 in https://docs.materialsproject.org/downloading-data/using-the-api/tips-for-large-downloads
When I try the call mpr.get_entries(["Si-O"], additional_criteria=dict(energy_above_hull=(None, 0.001)), compatible_only=True) I get a list of 5 pymatgen.entries.computed_entries.ComputedStructureEntry entries. However, when I try to pickle.dump(ret, f) them, I get the error:
AttributeError: Can't pickle local object 'cached_class.<locals>._decorated'
It is the 3rd element that is causing the issue, when printed it gives:
mp-546794-GGA ComputedStructureEntry - Si2 O4 (SiO2)
Energy (Uncorrected) = -47.4976 eV (-7.9163 eV/atom)
Correction = -2.7480 eV (-0.4580 eV/atom)
Energy (Final) = -50.2456 eV (-8.3743 eV/atom)
Energy Adjustments:
MP2020 anion correction (oxide): -2.7480 eV (-0.4580 eV/atom)
Parameters:
potcar_spec = [{'titel': 'PAW_PBE Si 05Jan2001', 'hash': 'b2b0ea6feb62e7cde209616683b8f7f5'}, {'titel': 'PAW_PBE O 08Apr2002', 'hash': '7a25bc5b9a5393f46600a4939d357982'}]
is_hubbard = False
hubbards = {}
run_type = GGA
Data:
oxide_type = oxide
aspherical = True
last_updated = 2022-06-07 19:44:16.964000
task_id = mp-2287344
material_id = mp-546794
oxidation_states = {'Si': 4.0, 'O': -2.0}
run_type = GGA
Proposed Solution
I suggest that we make all API call results pickleable, as they were in the legacy API, and add unit tests to not accidentally make them unpickleable in the future.
Alternatives
No response
PR is welcome on this.
@tschaume this seems like it may have been resolved, I'm able to pickle.dumps() generic ComputedStructureEntry objects using
pymatgen==2024.11.13
mp_api==0.45.0rc2
emmet-core==0.84.4
monty==2024.12.10
Perfect, thanks for confirming @esoteric-ephemera! I'll close this issue for now and if needed we can reopen it. @kalvdans Feel free to let us know if there's anything here that we might have overlooked. Thanks!