Skip to content

Commit

Permalink
Set default thermo_type in thermo search method (#726)
Browse files Browse the repository at this point in the history
* Set default thermo_type in thermo search method

* Mypy

* Update thermo tests

* Fix thermo tests

* More test updates

* Entry test change

* Unmark test

* Change mpid in phonon test

* Bump emmet-core
  • Loading branch information
Jason Munro authored Jan 12, 2023
1 parent 15c378b commit 98eb360
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion mp_api/client/mprester.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class MPRester:

def __init__(
self,
api_key: str = DEFAULT_API_KEY,
api_key: Optional[str] = DEFAULT_API_KEY,
endpoint: str = DEFAULT_ENDPOINT,
notify_db_version: bool = False,
include_user_agent: bool = True,
Expand Down
4 changes: 2 additions & 2 deletions mp_api/client/routes/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ThermoRester(BaseRester[ThermoDoc]):
suffix = "thermo"
document_model = ThermoDoc # type: ignore
supports_versions = True
primary_key = "material_id"
primary_key = "thermo_id"

def search_thermo_docs(self, *args, **kwargs): # pragma: no cover
"""
Expand All @@ -39,7 +39,7 @@ def search(
material_ids: Optional[List[str]] = None,
num_elements: Optional[Tuple[int, int]] = None,
thermo_ids: Optional[List[str]] = None,
thermo_types: Optional[List[ThermoType]] = None,
thermo_types: Optional[List[ThermoType]] = [ThermoType.GGA_GGA_U],
total_energy: Optional[Tuple[float, float]] = None,
uncorrected_energy: Optional[Tuple[float, float]] = None,
sort_fields: Optional[List[str]] = None,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
emmet-core[all]==0.36.4
emmet-core[all]==0.39.8
pydantic>=1.8.2
pymatgen>=2022.3.7
pymatgen-analysis-alloys>=0.0.3
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"typing-extensions>=3.7.4.1",
"requests>=2.23.0",
"monty>=2021.3.12",
"emmet-core>=0.36.4",
"emmet-core>=0.39.8",
],
extras_require={
"all": [
"emmet-core[all]>=0.36.4",
"emmet-core[all]>=0.39.8",
"custodian",
"mpcontribs-client",
"boto3"
Expand Down
1 change: 0 additions & 1 deletion tests/test_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def rester():
custom_field_tests = {} # type: dict


@pytest.mark.xfail(reason="Temporary xfail until deployment")
@pytest.mark.skipif(
os.environ.get("MP_API_KEY", None) is None, reason="No API key found."
)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_mprester.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ def test_get_entries(self, mpr):

s = prim.structure
assert pytest.approx(s.lattice.a) == s.lattice.b
assert pytest.approx(s.lattice.a) == s.lattice.c
assert pytest.approx(s.lattice.a) != s.lattice.c
assert pytest.approx(s.lattice.alpha) == s.lattice.beta
assert pytest.approx(s.lattice.alpha) == s.lattice.gamma
assert pytest.approx(s.lattice.alpha) != s.lattice.gamma

# Additional criteria
entry = mpr.get_entries(
Expand Down Expand Up @@ -294,10 +294,10 @@ def test_get_ion_entries(self, mpr):
assert np.allclose(so4_two_minus.energy, solid_energy + 5.542, atol=1e-3)

def test_get_phonon_data_by_material_id(self, mpr):
bs = mpr.get_phonon_bandstructure_by_material_id("mp-11659")
bs = mpr.get_phonon_bandstructure_by_material_id("mp-2172")
assert isinstance(bs, PhononBandStructureSymmLine)

dos = mpr.get_phonon_dos_by_material_id("mp-11659")
dos = mpr.get_phonon_dos_by_material_id("mp-2172")
assert isinstance(dos, PhononDos)

@pytest.mark.skip(reason="Test needs fixing with ENV variables")
Expand Down
1 change: 0 additions & 1 deletion tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def test_client(rester):
assert doc[project_field if project_field is not None else param] is not None


@pytest.mark.xfail(reason="Temporary until redeploy")
def test_get_trajectories(rester):

trajectories = rester.get_trajectory("mp-149")
Expand Down
5 changes: 3 additions & 2 deletions tests/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def rester():
"all_fields",
"fields",
"equilibrium_reaction_energy",
"thermo_types",
]

sub_doc_fields = [] # type: list
Expand All @@ -31,6 +30,7 @@ def rester():
"formula": "formula_pretty",
"material_ids": "material_id",
"thermo_ids": "thermo_id",
"thermo_types": "thermo_type",
"total_energy": "energy_per_atom",
"formation_energy": "formation_energy_per_atom",
"uncorrected_energy": "uncorrected_energy_per_atom",
Expand All @@ -41,9 +41,10 @@ def rester():

custom_field_tests = {
"material_ids": ["mp-149"],
"thermo_ids": ["mp-149_GGA_GGA+U"],
"thermo_types": [ThermoType.GGA_GGA_U],
"formula": "SiO2",
"chemsys": "Si-O",
"thermo_ids": ["mp-149"],
} # type: dict


Expand Down

0 comments on commit 98eb360

Please sign in to comment.