Skip to content

Commit

Permalink
Add MLBuilder and MLDoc to record machine learning property predi…
Browse files Browse the repository at this point in the history
…ctions (#806)

* add pydantic models MLIPElasticityDoc, MLIPPhononDoc, MLIPEosDoc, MLIPRelaxationDoc

for interatomic potential predictions

* add class MLIPBuilder

runs CHGNet and MEGNet over all structures in the materials store and with every matcalc PropCalc class

* wip test_mlip_builder.py

* MLIPBuilder add args model: Union[str, "Calculator"] and prop_kwargs: dict = None

* update MLIPDoc with provenance

just model name and package version for now

* merge MLIPElasticityDoc MLIPPhononDoc MLIPEosDoc MLIPRelaxationDoc into MLIPDoc

* run MLIPBuilder with chgnet and m3gnet in test_ml_ip_builder

* deduplicate test_structures

* remove magnetism_test_data fixture

just adds verbosity

* mv emmet-core/tests/test_structure{,_}metadata.py

mv emmet-core/tests/test_molecule{,_}metadata.py

* add test_mlip_doc

* refactor MLIPDoc.__init__

* rename MLIPBuilder keyword calc_kwargs to model_kwargs

* EOS->eos

* test only one structure in test_mlip_doc() for speed

* mv emmet-core/tests/test_{ml_potential.py,ml.py} and split chgnet and m3gnet into separate test functions

* mv emmet-builders/emmet/builders/materials/{ml_potential,ml}.py emmet-core/emmet/core/{ml_potential,ml}.py

convert numpy arrays to lists and fix doc str

* fix typos compatability->compatibility

* MLIPDoc add structure, calculator, version metadata fields

* working MLIPDoc tests

starting with test_mlip_doc_with_calc_as_(str|model)

* setup.cfg add pytest option -p no:warnings

set isort known_local_folder=emmet

* fix names in MLIPDoc Attributes doc string section

* fix MLIPBuilder provenance

matcalc version
model name
model version

* test_ml_ip_builder() 1st working version

* ThermodynamicProperties.cv add alias heat_capacity

* merge both MLIPDoc tests using @pytest.mark.parametrize

* MLIPDoc rename field version to matcalc_version

* MLIPBuilder add kwarg provenance for extra custom data

* test_ml_ip_builder() parametrize model

* add matcalc to emmet-core extras_require 'all'

* fix test type hint Union[str, "Calculator"]

* make all MLIPDoc fields optional

* young_modulus add alias youngs_modulus

* MLIPDoc inherit from ElasticityDoc

add bulk_modulus and shear_modulus pydantic validators

* fix emmet-core/tests/test_ml.py

* update MLIPDoc doc string with correct elasticity types

* map (bulk|shear)_modulus_vrh which matcalc returns to (bulk|shear)_modulus which ElasticityDoc expects

* test prop_kwargs keyword of MLIPDoc

* Automated dependency upgrades (#827)

* update dependencies for emmet-api (ubuntu-latest/py3.10)

* update dependencies for emmet-api (ubuntu-latest/py3.11)

* update dependencies for emmet-api (ubuntu-latest/py3.8)

* update dependencies for emmet-api (ubuntu-latest/py3.9)

* update dependencies for emmet-builders (ubuntu-latest/py3.10)

* update dependencies for emmet-builders (ubuntu-latest/py3.11)

* update dependencies for emmet-builders (ubuntu-latest/py3.8)

* update dependencies for emmet-builders (ubuntu-latest/py3.9)

* update dependencies for emmet-core (ubuntu-latest/py3.10)

* update dependencies for emmet-core (ubuntu-latest/py3.11)

* update dependencies for emmet-core (ubuntu-latest/py3.8)

* update dependencies for emmet-core (ubuntu-latest/py3.9)

---------

Co-authored-by: github-actions <github-actions@github.com>

* rename MLIPBuilder to MLBuilder and MLIPDoc to MLDoc

* Matcalc dep added to req files

* Remove repeat req entry

* Bump matcalc

---------

Co-authored-by: Patrick Huck <phuck@lbl.gov>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Jason Munro <jason.munro@gmail.com>
  • Loading branch information
4 people committed Sep 26, 2023
1 parent e4bb49f commit ff4b452
Show file tree
Hide file tree
Showing 47 changed files with 526 additions and 306 deletions.
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2608,7 +2608,7 @@
- Working Thermo Builder [\#170](https://github.com/materialsproject/emmet/pull/170) ([jmmshn](https://github.com/jmmshn))
- Add SCF gradient and Manual deprecation to VASP validation [\#169](https://github.com/materialsproject/emmet/pull/169) ([shyamd](https://github.com/shyamd))
- Create MPID Type [\#167](https://github.com/materialsproject/emmet/pull/167) ([shyamd](https://github.com/shyamd))
- Remove stubs in favor of monty pydantic compatability [\#165](https://github.com/materialsproject/emmet/pull/165) ([shyamd](https://github.com/shyamd))
- Remove stubs in favor of monty pydantic compatibility [\#165](https://github.com/materialsproject/emmet/pull/165) ([shyamd](https://github.com/shyamd))
- made structure grouper work with material\_ids [\#163](https://github.com/materialsproject/emmet/pull/163) ([jmmshn](https://github.com/jmmshn))
- minor changes to get material builder working on non-production databases. [\#162](https://github.com/materialsproject/emmet/pull/162) ([jmmshn](https://github.com/jmmshn))
- Electrode Doc [\#149](https://github.com/materialsproject/emmet/pull/149) ([jmmshn](https://github.com/jmmshn))
Expand Down
4 changes: 0 additions & 4 deletions emmet-api/requirements/ubuntu-latest_py3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ monty==2023.9.25
# emmet-core
# maggma
# matminer
# mp-api
# pymatgen
# robocrys
mp-api==0.36.1
Expand Down Expand Up @@ -215,7 +214,6 @@ pymatgen==2023.9.10
# emmet-api (setup.py)
# emmet-core
# matminer
# mp-api
# pymatgen-analysis-alloys
# pymatgen-analysis-diffusion
# robocrys
Expand Down Expand Up @@ -252,7 +250,6 @@ requests==2.31.0
# via
# matminer
# mongogrant
# mp-api
# pymatgen
robocrys==0.2.8
# via emmet-core
Expand Down Expand Up @@ -327,7 +324,6 @@ typing-extensions==4.8.0
# emmet-core
# fastapi
# inflect
# mp-api
# pydantic
# pydash
# uvicorn
Expand Down
4 changes: 0 additions & 4 deletions emmet-api/requirements/ubuntu-latest_py3.10_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ monty==2023.9.25
# emmet-core
# maggma
# matminer
# mp-api
# pymatgen
# robocrys
mp-api==0.36.1
Expand Down Expand Up @@ -326,7 +325,6 @@ pymatgen==2023.9.10
# emmet-api (setup.py)
# emmet-core
# matminer
# mp-api
# pymatgen-analysis-alloys
# pymatgen-analysis-diffusion
# robocrys
Expand Down Expand Up @@ -382,7 +380,6 @@ requests==2.31.0
# via
# matminer
# mongogrant
# mp-api
# pymatgen
robocrys==0.2.8
# via emmet-core
Expand Down Expand Up @@ -473,7 +470,6 @@ typing-extensions==4.8.0
# emmet-core
# fastapi
# inflect
# mp-api
# mypy
# pydantic
# pydash
Expand Down
4 changes: 0 additions & 4 deletions emmet-api/requirements/ubuntu-latest_py3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ monty==2023.9.25
# emmet-core
# maggma
# matminer
# mp-api
# pymatgen
# robocrys
mp-api==0.36.1
Expand Down Expand Up @@ -211,7 +210,6 @@ pymatgen==2023.9.10
# emmet-api (setup.py)
# emmet-core
# matminer
# mp-api
# pymatgen-analysis-alloys
# pymatgen-analysis-diffusion
# robocrys
Expand Down Expand Up @@ -248,7 +246,6 @@ requests==2.31.0
# via
# matminer
# mongogrant
# mp-api
# pymatgen
robocrys==0.2.8
# via emmet-core
Expand Down Expand Up @@ -322,7 +319,6 @@ typing-extensions==4.8.0
# emmet-core
# fastapi
# inflect
# mp-api
# pydantic
# pydash
uncertainties==3.1.7
Expand Down
4 changes: 0 additions & 4 deletions emmet-api/requirements/ubuntu-latest_py3.11_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ monty==2023.9.25
# emmet-core
# maggma
# matminer
# mp-api
# pymatgen
# robocrys
mp-api==0.36.1
Expand Down Expand Up @@ -321,7 +320,6 @@ pymatgen==2023.9.10
# emmet-api (setup.py)
# emmet-core
# matminer
# mp-api
# pymatgen-analysis-alloys
# pymatgen-analysis-diffusion
# robocrys
Expand Down Expand Up @@ -377,7 +375,6 @@ requests==2.31.0
# via
# matminer
# mongogrant
# mp-api
# pymatgen
robocrys==0.2.8
# via emmet-core
Expand Down Expand Up @@ -462,7 +459,6 @@ typing-extensions==4.8.0
# emmet-core
# fastapi
# inflect
# mp-api
# mypy
# pydantic
# pydash
Expand Down
12 changes: 6 additions & 6 deletions emmet-api/requirements/ubuntu-latest_py3.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ click==8.1.7
# uvicorn-tschaume
contourpy==1.1.1
# via matplotlib
cryptography==41.0.3
cryptography==41.0.4
# via paramiko
cycler==0.11.0
# via matplotlib
Expand Down Expand Up @@ -98,7 +98,7 @@ importlib-metadata==6.8.0
# via
# flask
# opentelemetry-api
importlib-resources==6.0.1
importlib-resources==6.1.0
# via
# jsonschema
# jsonschema-specifications
Expand All @@ -118,7 +118,7 @@ joblib==1.3.2
# pymatgen
# pymatgen-analysis-diffusion
# scikit-learn
jsonschema==4.19.0
jsonschema==4.19.1
# via maggma
jsonschema-specifications==2023.7.1
# via jsonschema
Expand Down Expand Up @@ -152,7 +152,7 @@ mp-api==0.35.1
# via pymatgen
mpmath==1.3.0
# via sympy
msgpack==1.0.5
msgpack==1.0.6
# via
# maggma
# mp-api
Expand Down Expand Up @@ -278,7 +278,7 @@ ruamel-yaml-clib==0.2.7
# via ruamel-yaml
s3transfer==0.6.2
# via boto3
scikit-learn==1.3.0
scikit-learn==1.3.1
# via matminer
scipy==1.10.1
# via
Expand Down Expand Up @@ -359,7 +359,7 @@ wrapt==1.15.0
# via deprecated
xmltodict==0.13.0
# via ddtrace
zipp==3.16.2
zipp==3.17.0
# via
# importlib-metadata
# importlib-resources
Expand Down
18 changes: 9 additions & 9 deletions emmet-api/requirements/ubuntu-latest_py3.8_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ contourpy==1.1.1
# via matplotlib
coverage[toml]==7.3.1
# via pytest-cov
cryptography==41.0.3
cryptography==41.0.4
# via paramiko
csscompressor==0.9.5
# via mkdocs-minify-plugin
Expand Down Expand Up @@ -127,7 +127,7 @@ importlib-metadata==6.8.0
# mkdocs
# mkdocstrings
# opentelemetry-api
importlib-resources==6.0.1
importlib-resources==6.1.0
# via
# jsonschema
# jsonschema-specifications
Expand Down Expand Up @@ -156,7 +156,7 @@ joblib==1.3.2
# scikit-learn
jsmin==3.0.1
# via mkdocs-minify-plugin
jsonschema==4.19.0
jsonschema==4.19.1
# via maggma
jsonschema-specifications==2023.7.1
# via jsonschema
Expand Down Expand Up @@ -189,7 +189,7 @@ mccabe==0.7.0
# via flake8
mergedeep==1.3.4
# via mkdocs
mkdocs==1.5.2
mkdocs==1.5.3
# via
# emmet-api (setup.py)
# mkdocs-autorefs
Expand All @@ -206,7 +206,7 @@ mkdocs-markdownextradata-plugin==0.2.5
# via emmet-api (setup.py)
mkdocs-material==8.2.16
# via emmet-api (setup.py)
mkdocs-material-extensions==1.1.1
mkdocs-material-extensions==1.2
# via
# emmet-api (setup.py)
# mkdocs-material
Expand Down Expand Up @@ -234,7 +234,7 @@ mp-api==0.35.1
# via pymatgen
mpmath==1.3.0
# via sympy
msgpack==1.0.5
msgpack==1.0.6
# via
# maggma
# mp-api
Expand Down Expand Up @@ -411,7 +411,7 @@ ruamel-yaml-clib==0.2.7
# via ruamel-yaml
s3transfer==0.6.2
# via boto3
scikit-learn==1.3.0
scikit-learn==1.3.1
# via matminer
scipy==1.10.1
# via
Expand Down Expand Up @@ -472,7 +472,7 @@ tqdm==4.66.1
# maggma
# matminer
# pymatgen
types-requests==2.31.0.2
types-requests==2.31.0.5
# via emmet-api (setup.py)
types-setuptools==68.2.0.0
# via emmet-api (setup.py)
Expand Down Expand Up @@ -518,7 +518,7 @@ wrapt==1.15.0
# via deprecated
xmltodict==0.13.0
# via ddtrace
zipp==3.16.2
zipp==3.17.0
# via
# importlib-metadata
# importlib-resources
Expand Down
4 changes: 0 additions & 4 deletions emmet-api/requirements/ubuntu-latest_py3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ monty==2023.9.25
# emmet-core
# maggma
# matminer
# mp-api
# pymatgen
# robocrys
mp-api==0.36.1
Expand Down Expand Up @@ -219,7 +218,6 @@ pymatgen==2023.9.10
# emmet-api (setup.py)
# emmet-core
# matminer
# mp-api
# pymatgen-analysis-alloys
# pymatgen-analysis-diffusion
# robocrys
Expand Down Expand Up @@ -256,7 +254,6 @@ requests==2.31.0
# via
# matminer
# mongogrant
# mp-api
# pymatgen
robocrys==0.2.8
# via emmet-core
Expand Down Expand Up @@ -333,7 +330,6 @@ typing-extensions==4.8.0
# emmet-core
# fastapi
# inflect
# mp-api
# pydantic
# pydash
# starlette
Expand Down
4 changes: 0 additions & 4 deletions emmet-api/requirements/ubuntu-latest_py3.9_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ monty==2023.9.25
# emmet-core
# maggma
# matminer
# mp-api
# pymatgen
# robocrys
mp-api==0.36.1
Expand Down Expand Up @@ -333,7 +332,6 @@ pymatgen==2023.9.10
# emmet-api (setup.py)
# emmet-core
# matminer
# mp-api
# pymatgen-analysis-alloys
# pymatgen-analysis-diffusion
# robocrys
Expand Down Expand Up @@ -389,7 +387,6 @@ requests==2.31.0
# via
# matminer
# mongogrant
# mp-api
# pymatgen
robocrys==0.2.8
# via emmet-core
Expand Down Expand Up @@ -483,7 +480,6 @@ typing-extensions==4.8.0
# fastapi
# inflect
# mkdocstrings
# mp-api
# mypy
# pydantic
# pydash
Expand Down
16 changes: 8 additions & 8 deletions emmet-builders/emmet/builders/materials/corrected_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(
corrected_entries (Store): Store to output corrected entry data
oxidation_states (Store): Store of oxidation state data to use in correction scheme application
query (dict): dictionary to limit materials to be analyzed
compatibility ([Compatability]): Compatability module
compatibility ([Compatibility]): Compatibility module
to ensure energies are compatible
chunk_size (int): Size of chemsys chunks to process at any one time.
"""
Expand Down Expand Up @@ -145,12 +145,12 @@ def process_item(self, item):

corrected_entries = {}

for compatability in self.compatibility:
if compatability is not None:
for compatibility in self.compatibility:
if compatibility is not None:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
with HiddenPrints():
if compatability.name == "MP DFT mixing scheme":
if compatibility.name == "MP DFT mixing scheme":
thermo_type = ThermoType.GGA_GGA_U_R2SCAN

if "R2SCAN" in all_entry_types:
Expand All @@ -161,22 +161,22 @@ def process_item(self, item):
]
corrected_entries["R2SCAN"] = only_scan_pd_entries

pd_entries = compatability.process_entries(
pd_entries = compatibility.process_entries(
copy.deepcopy(entries)
)

else:
corrected_entries["R2SCAN"] = None
pd_entries = None

elif compatability.name == "MP2020":
elif compatibility.name == "MP2020":
thermo_type = ThermoType.GGA_GGA_U
pd_entries = compatability.process_entries(
pd_entries = compatibility.process_entries(
copy.deepcopy(entries)
)
else:
thermo_type = ThermoType.UNKNOWN
pd_entries = compatability.process_entries(
pd_entries = compatibility.process_entries(
copy.deepcopy(entries)
)

Expand Down

0 comments on commit ff4b452

Please sign in to comment.