Skip to content

Return None rather than KeyError, for property_data without a thermo doc in get_entries_in_chemsys - #1144

Open
kavanase wants to merge 1 commit into
materialsproject:mainfrom
kavanase:fix/property-data-missing-thermo-docs
Open

kavanase wants to merge 1 commit into
materialsproject:mainfrom
kavanase:fix/property-data-missing-thermo-docs

Conversation

@kavanase

@kavanase kavanase commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

(My last PR/issue now! 😅 Was doing some stress testing of the latest MP database with our doped chemical potentials analysis, which flagged these issues)

Summary

Problem:

with MPRester(db_version="2026.04.13") as mpr:
    mpr.get_entries_in_chemsys("Co-O", property_data=["energy_above_hull"])
# KeyError: 'mp-1275385'

With an older db_version, the pre-built phase diagram is read from that version on S3, but property_data is
attached from thermo.search, which the REST API answers from the current version. Materials removed since then have no thermo doc there, so the lookup raises. From the S3 tables, 11 materials in the v2026.04.13 mixed (GGA_GGA+U_R2SCAN) phase diagrams have no v2026.09.28 thermo doc (mp-19849, mp-541843, mp-687301, mp-771003, mp-804341, mp-1073663, mp-1103281, mp-1223474, mp-1237669, mp-1275385, mp-1276506), and they appear in 3,643 of the 117,162 diagrams.

Fix: Entries without a doc get None for each requested field, and one warning names them.

test_get_entries_in_chemsys_decorated_served_pd_missing_docs tests this behaviour using the Co-O case above: the same call raises KeyError: 'mp-1275385' on main, and the test passes with this change.

Checklist

  • Google format doc strings added. Check with ruff.
  • Type annotations included. Check with mypy.
  • Tests added for new features/fixes.
  • If applicable, new classes/functions/modules have duecredit @due.dcite decorators to reference relevant papers by DOI (example)

@tsmathis

Copy link
Copy Markdown
Collaborator

Thanks for bringing all these PRs/issues up @kavanase! will try to get through reviewing them as soon as I can

This branch has not been deployed

No deployments
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.

2 participants