From 98eb360521bb27de380620a02580e05a250a7070 Mon Sep 17 00:00:00 2001 From: Jason Munro Date: Thu, 12 Jan 2023 15:24:31 -0800 Subject: [PATCH] Set default thermo_type in thermo search method (#726) * 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 --- mp_api/client/mprester.py | 2 +- mp_api/client/routes/thermo.py | 4 ++-- requirements.txt | 2 +- setup.py | 4 ++-- tests/test_elasticity.py | 1 - tests/test_mprester.py | 8 ++++---- tests/test_tasks.py | 1 - tests/test_thermo.py | 5 +++-- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/mp_api/client/mprester.py b/mp_api/client/mprester.py index f70c2171..c2610911 100644 --- a/mp_api/client/mprester.py +++ b/mp_api/client/mprester.py @@ -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, diff --git a/mp_api/client/routes/thermo.py b/mp_api/client/routes/thermo.py index d85f82b7..bf4fbcd2 100644 --- a/mp_api/client/routes/thermo.py +++ b/mp_api/client/routes/thermo.py @@ -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 """ @@ -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, diff --git a/requirements.txt b/requirements.txt index 45be3f36..823c746e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.py b/setup.py index c4482be8..ddfbae3c 100644 --- a/setup.py +++ b/setup.py @@ -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" diff --git a/tests/test_elasticity.py b/tests/test_elasticity.py index f1190b1a..64b314e2 100644 --- a/tests/test_elasticity.py +++ b/tests/test_elasticity.py @@ -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." ) diff --git a/tests/test_mprester.py b/tests/test_mprester.py index 35dfe5d4..84587486 100644 --- a/tests/test_mprester.py +++ b/tests/test_mprester.py @@ -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( @@ -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") diff --git a/tests/test_tasks.py b/tests/test_tasks.py index f2bab514..e6708dc9 100644 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -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") diff --git a/tests/test_thermo.py b/tests/test_thermo.py index 715bee73..2a4cd930 100644 --- a/tests/test_thermo.py +++ b/tests/test_thermo.py @@ -22,7 +22,6 @@ def rester(): "all_fields", "fields", "equilibrium_reaction_energy", - "thermo_types", ] sub_doc_fields = [] # type: list @@ -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", @@ -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