Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: pickleable GGA pymatgen.entries.computed_entries.ComputedStructureEntry #921

Open
kalvdans opened this issue Jul 12, 2024 · 1 comment

Comments

@kalvdans
Copy link

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

@munrojm
Copy link
Member

munrojm commented Jul 18, 2024

PR is welcome on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants