Skip to content

Only serve GNoMe entries of pre-built phase diagrams to API keys with GNoMe access - #1140

Open
kavanase wants to merge 3 commits into
materialsproject:mainfrom
kavanase:fix/served-pd-gnome-access
Open

kavanase wants to merge 3 commits into
materialsproject:mainfrom
kavanase:fix/served-pd-gnome-access

Conversation

@kavanase

@kavanase kavanase commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Spotted this issue when testing out the latest mp-api release and associated MP database release.

Summary

MPRester.get_entries_in_chemsys(..., property_data=[...]) (default mixed thermo type) raises KeyError for any chemical system whose pre-built phase diagram contains a GNoMe entry, for API keys without GNoMe access. E.g. Cu-Se-Si (database v2026.09.28):

MPRester().get_entries_in_chemsys("Cu-Se-Si", property_data=["energy_above_hull"])
# KeyError: 'mp-3336429'

mp-3336429 (Cu3SiSe4, on the hull) is a GNoMe material (gnome_r2scan_statics, license: BY-NC).
The pre-built phase diagrams (S3 objects/phase-diagrams) include GNoMe entries for every API key, but
thermo.search (like all the access-controlled REST collections) does not return GNoMe docs to API keys without GNoMe access, so the property_data decoration fails on the missing doc.

Changes

  • ThermoRester.get_phase_diagram_from_chemsys (used by get_entries_in_chemsys, get_stability,
    the oxygen evolution helper and the MCP phase diagram tool): for keys without GNoMe access, GNoMe entries are ommited and the (mixed) phase diagram is rebuilt.
  • Leaving the entries out alone is not enough: in r2SCAN-anchored systems, MaterialsProjectDFTMixingScheme
    places GGA(+U)-only entries onto the r2SCAN hull including the GNoMe entries, so these are
    re-referenced to the r2SCAN hull without them (_accessible_entries).

Additional details from Claude:

Scope (served GGA_GGA+U_R2SCAN phase diagrams, read from the public S3 Delta tables)

v2026.09.28: 21,694 of 117,172 chemical systems (18.5%) have GNoMe entries in their served phase
diagram (KeyError without access). 29,203 GNoMe materials, 27,977 of them on a hull.

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)

@kavanase

Copy link
Copy Markdown
Contributor Author

From what I can tell, the test failure here is unrelated to the PR (test_mock failing due to my fork not having the MP_API_KEY secret?)

@kavanase

Copy link
Copy Markdown
Contributor Author

Also just noting something that was spotted when investigating this: the v2026.09.28 MP mixed phase-diagram table has 3,536 duplicate chemical-system rows, all identical. mp-api just takes the first, so it makes no difference, just fyi!

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.

1 participant