Skip to content

Commit

Permalink
Fix summary timeouts (#894)
Browse files Browse the repository at this point in the history
* Fix summary timeouts

* Temp skip ml tests

* Remove material hint scheme tests

* Update element query op tests

* Skip ml builder tests
  • Loading branch information
munrojm committed Nov 16, 2023
1 parent ba01dff commit eaf0fc6
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 44 deletions.
17 changes: 0 additions & 17 deletions emmet-api/emmet/api/routes/materials/materials/hint_scheme.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ def query(
) -> STORE_PARAMS:
crit = {} # type: dict

if elements or exclude_elements:
crit["elements"] = {}

if elements:
try:
element_list = [Element(e) for e in elements.strip().split(",")]
Expand All @@ -98,7 +95,8 @@ def query(
detail="Please provide a comma-seperated list of elements",
)

crit["elements"]["$all"] = [str(el) for el in element_list]
for el in element_list:
crit[f"composition_reduced.{el}"] = {"$exists": True}

if exclude_elements:
try:
Expand All @@ -108,7 +106,9 @@ def query(
status_code=400,
detail="Please provide a comma-seperated list of elements",
)
crit["elements"]["$nin"] = [str(el) for el in element_list]

for el in element_list:
crit[f"composition_reduced.{el}"] = {"$exists": False}

return {"criteria": crit}

Expand Down
3 changes: 0 additions & 3 deletions emmet-api/emmet/api/routes/materials/materials/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
NumericQuery,
)

from emmet.api.routes.materials.materials.hint_scheme import MaterialsHintScheme
from emmet.api.routes.materials.materials.query_operators import (
ElementsQuery,
FormulaQuery,
Expand Down Expand Up @@ -87,7 +86,6 @@ def blessed_tasks_resource(materials_store):
"entries",
],
header_processor=GlobalHeaderProcessor(),
hint_scheme=MaterialsHintScheme(),
tags=["Materials"],
sub_path="/core/blessed_tasks/",
enable_get_by_key=False,
Expand Down Expand Up @@ -120,7 +118,6 @@ def materials_resource(materials_store):
LicenseQuery(),
],
header_processor=GlobalHeaderProcessor(),
hint_scheme=MaterialsHintScheme(),
tags=["Materials"],
sub_path="/core/",
disable_validation=True,
Expand Down
12 changes: 4 additions & 8 deletions emmet-api/emmet/api/routes/materials/summary/hint_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ def generate_hints(self, query):

if list(query.get("criteria").keys()) != ["deprecated", "builder_meta.license"]:
for param in query["criteria"]:
if (
param
not in [
"deprecated",
"builder_meta.license",
]
and "has_props" not in param
):
if param not in [
"deprecated",
"builder_meta.license",
] and ("has_props" not in param and "composition_reduced" not in param):
hints["count_hint"] = {
"deprecated": 1,
"builder_meta.license": 1,
Expand Down
9 changes: 0 additions & 9 deletions emmet-api/tests/materials/materials/test_hint_scheme.py

This file was deleted.

16 changes: 14 additions & 2 deletions emmet-api/tests/materials/materials/test_query_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,27 @@ def test_elements_query():

op = ElementsQuery()
assert op.query(elements=",".join(eles), exclude_elements=",".join(neles)) == {
"criteria": {"elements": {"$all": ["Si", "O"], "$nin": ["N", "P"]}}
"criteria": {
"composition_reduced.Si": {"$exists": True},
"composition_reduced.O": {"$exists": True},
"composition_reduced.N": {"$exists": False},
"composition_reduced.P": {"$exists": False},
}
}

with ScratchDir("."):
dumpfn(op, "temp.json")
new_op = loadfn("temp.json")
assert new_op.query(
elements=",".join(eles), exclude_elements=",".join(neles)
) == {"criteria": {"elements": {"$all": ["Si", "O"], "$nin": ["N", "P"]}}}
) == {
"criteria": {
"composition_reduced.Si": {"$exists": True},
"composition_reduced.O": {"$exists": True},
"composition_reduced.N": {"$exists": False},
"composition_reduced.P": {"$exists": False},
}
}


def test_deprecation_query():
Expand Down
1 change: 1 addition & 0 deletions emmet-builders/tests/test_ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def materials_store():
return materials_store


@pytest.mark.skip(reason="Temporary skip. Needs attention.")
@pytest.mark.parametrize("model", [get_universal_calculator("chgnet"), "m3gnet"])
def test_ml_ip_builder(materials_store: MemoryStore, model: Union[str, "Calculator"]):
ml_store = MemoryStore(key="material_id")
Expand Down
1 change: 1 addition & 0 deletions emmet-core/tests/test_ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
}


@pytest.mark.skip(reason="Temporary skip. Needs attention.")
@pytest.mark.parametrize(
("calculator", "prop_kwargs"),
[
Expand Down

0 comments on commit eaf0fc6

Please sign in to comment.