Skip to content

Conversation

nicktbrr
Copy link

Fix: Update Thermo Featurizers for Modern mp-api Client

Description

This PR resolves a series of AttributeError exceptions that occur when using the CohesiveEnergy and CohesiveEnergyMP featurizers with modern versions of pymatgen and mp-api. The errors are caused by matminer calling deprecated and removed functions from the old Materials Project API client.

This fix updates the featurizers to use the new, official mp-api client, restoring their functionality.

Changes Made

  • matminer/featurizers/composition/thermo.py

    • Replaced the legacy from pymatgen.ext.matproj import MPRester with the correct from mp_api.client import MPRester.
    • Rewrote CohesiveEnergy.featurize to use mpr.thermo.search() to correctly fetch formation energies.
    • Rewrote CohesiveEnergyMP.featurize to use the modern two-step workflow: first finding the material_id with mpr.materials.search() and then retrieving the pre-calculated value with mpr.get_cohesive_energy().
  • pyproject.toml

    • Added mp-api as a core dependency, as it is now required for these featurizers to function.

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

Successfully merging this pull request may close these issues.

1 participant