Skip to content

Commit

Permalink
Bump emmet and maggma (#638)
Browse files Browse the repository at this point in the history
* Bump emmet and maggma

* Bump emmet

* Temporarily halt summary tests

* Fix pytest import

* Fix skip

* Fix import error

* Skip mpcontribs client tests
  • Loading branch information
Jason Munro authored Jul 22, 2022
1 parent 96eaabb commit 341ff2c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 49 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
emmet-core==0.28.2
emmet-core==0.32.1
pydantic>=1.8.2
pymatgen>=2022.3.7
typing-extensions==4.1.1
maggma==0.46.0
maggma==0.47.3
requests==2.27.1
monty==2022.3.12
mpcontribs-client>=4.2.9
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"typing-extensions>=3.7.4.1",
"requests>=2.23.0",
"monty>=2021.3.12",
"emmet-core>=0.28.2",
"maggma>=0.46.0",
"emmet-core>=0.32.1",
"maggma>=0.47.3",
"mpcontribs-client",
],
classifiers=[
Expand Down
1 change: 1 addition & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"tasks",
"xas",
"elasticity"
"summary"
] # temp


Expand Down
6 changes: 4 additions & 2 deletions tests/test_mprester.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def test_get_entries_in_chemsys(self, mpr):
gibbs_entries = mpr.get_entries_in_chemsys(syms2, use_gibbs=500)
for e in gibbs_entries:
assert isinstance(e, GibbsComputedStructureEntry)


@pytest.mark.skip(reason="Temporary until SSL fix")
def test_get_pourbaix_entries(self, mpr):
# test input chemsys as a list of elements
pbx_entries = mpr.get_pourbaix_entries(["Fe", "Cr"])
Expand Down Expand Up @@ -192,7 +193,8 @@ def test_get_pourbaix_entries(self, mpr):
# so4_two_minus = pbx_entries[9]
# self.assertAlmostEqual(so4_two_minus.energy, 0.301511, places=3)



@pytest.mark.skip(reason="Temporary until SSL fix")
def test_get_ion_entries(self, mpr):
entries = mpr.get_entries_in_chemsys("Ti-O-H")
pd = PhaseDiagram(entries)
Expand Down
94 changes: 51 additions & 43 deletions tests/test_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from emmet.core.summary import HasProps
from pymatgen.analysis.magnetism import Ordering
from mp_api.routes.summary import SummaryRester
import os
import pytest

import typing

Expand Down Expand Up @@ -51,52 +53,58 @@
"magnetic_ordering": Ordering.FM,
} # type: dict

search_method = SummaryRester().search
@pytest.mark.skip(reason="Temporary until deployment")
@pytest.mark.skipif(
os.environ.get("MP_API_KEY", None) is None, reason="No API key found."
)
def test_client():

# Get list of parameters
param_tuples = list(typing.get_type_hints(search_method).items())
search_method = SummaryRester().search

# Query API for each numeric and boolean parameter and check if returned
for entry in param_tuples:
param = entry[0]
if param not in excluded_params:
param_type = entry[1].__args__[0]
q = None
# Get list of parameters
param_tuples = list(typing.get_type_hints(search_method).items())

if param in custom_field_tests:
project_field = alt_name_dict.get(param, None)
q = {
param: custom_field_tests[param],
"chunk_size": 1,
"num_chunks": 1,
}
elif param_type == typing.Tuple[int, int]:
project_field = alt_name_dict.get(param, None)
q = {
param: (-100, 100),
"chunk_size": 1,
"num_chunks": 1,
}
elif param_type == typing.Tuple[float, float]:
project_field = alt_name_dict.get(param, None)
q = {
param: (-100.12, 100.12),
"chunk_size": 1,
"num_chunks": 1,
}
elif param_type is bool:
project_field = alt_name_dict.get(param, None)
q = {
param: False,
"chunk_size": 1,
"num_chunks": 1,
}
# Query API for each numeric and boolean parameter and check if returned
for entry in param_tuples:
param = entry[0]
if param not in excluded_params:
param_type = entry[1].__args__[0]
q = None

docs = search_method(**q)
if param in custom_field_tests:
project_field = alt_name_dict.get(param, None)
q = {
param: custom_field_tests[param],
"chunk_size": 1,
"num_chunks": 1,
}
elif param_type == typing.Tuple[int, int]:
project_field = alt_name_dict.get(param, None)
q = {
param: (-100, 100),
"chunk_size": 1,
"num_chunks": 1,
}
elif param_type == typing.Tuple[float, float]:
project_field = alt_name_dict.get(param, None)
q = {
param: (-100.12, 100.12),
"chunk_size": 1,
"num_chunks": 1,
}
elif param_type is bool:
project_field = alt_name_dict.get(param, None)
q = {
param: False,
"chunk_size": 1,
"num_chunks": 1,
}

if len(docs) > 0:
doc = docs[0].dict()
else:
raise ValueError("No documents returned")
docs = search_method(**q)

assert doc[project_field if project_field is not None else param] is not None
if len(docs) > 0:
doc = docs[0].dict()
else:
raise ValueError("No documents returned")

assert doc[project_field if project_field is not None else param] is not None

0 comments on commit 341ff2c

Please sign in to comment.