Skip to content

Commit

Permalink
Convert to using HasProps enum for summary client (#445)
Browse files Browse the repository at this point in the history
* Convert to using HasProps enum for summary client

* Emmet bump

* Fix mprester has_props test
  • Loading branch information
Jason Munro authored Nov 29, 2021
1 parent b627f58 commit bac5b28
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ typing-extensions==4.0.0
maggma==0.32.2
requests==2.26.0
monty==2021.8.17
emmet-core==0.17.0
emmet-core==0.18.0
ratelimit==2.2.1
mpcontribs-client>=3.14.3
5 changes: 3 additions & 2 deletions src/mp_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from emmet.core.settings import EmmetSettings
from emmet.core.symmetry import CrystalSystem
from emmet.core.vasp.calc_types import CalcType
from emmet.core.summary import HasProps
from mpcontribs.client import Client
from pymatgen.analysis.magnetism import Ordering
from pymatgen.analysis.phase_diagram import PhaseDiagram
Expand Down Expand Up @@ -845,7 +846,7 @@ def query(
surface_energy_anisotropy: Optional[Tuple[float, float]] = None,
shape_factor: Optional[Tuple[float, float]] = None,
has_reconstructed: Optional[bool] = None,
has_props: Optional[List[str]] = None,
has_props: Optional[List[HasProps]] = None,
theoretical: Optional[bool] = None,
sort_fields: Optional[List[str]] = None,
num_chunks: Optional[int] = None,
Expand Down Expand Up @@ -918,7 +919,7 @@ def query(
consider.
shape_factor (Tuple[float,float]): Minimum and maximum shape factor values to consider.
has_reconstructed (bool): Whether the entry has any reconstructed surfaces.
has_props: (List[str]): The calculated properties available for the material.
has_props: (List[HasProps]): The calculated properties available for the material.
theoretical: (bool): Whether the material is theoretical.
sort_fields (List[str]): Fields used to sort results. Prefixing with '-' will sort in descending order.
num_chunks (int): Maximum number of chunks of data to yield. None will yield all possible.
Expand Down
8 changes: 4 additions & 4 deletions src/mp_api/routes/summary/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import List, Optional, Tuple

from emmet.core.mpid import MPID
from emmet.core.summary import SummaryDoc
from emmet.core.summary import SummaryDoc, HasProps
from emmet.core.symmetry import CrystalSystem
from mp_api.core.client import BaseRester
from pymatgen.analysis.magnetism import Ordering
Expand Down Expand Up @@ -63,7 +63,7 @@ def search_summary_docs(
surface_energy_anisotropy: Optional[Tuple[float, float]] = None,
shape_factor: Optional[Tuple[float, float]] = None,
has_reconstructed: Optional[bool] = None,
has_props: Optional[List[str]] = None,
has_props: Optional[List[HasProps]] = None,
theoretical: Optional[bool] = None,
sort_fields: Optional[List[str]] = None,
num_chunks: Optional[int] = None,
Expand Down Expand Up @@ -136,7 +136,7 @@ def search_summary_docs(
consider.
shape_factor (Tuple[float,float]): Minimum and maximum shape factor values to consider.
has_reconstructed (bool): Whether the entry has any reconstructed surfaces.
has_props: (List[str]): The calculated properties available for the material.
has_props: (List[HasProps]): The calculated properties available for the material.
theoretical: (bool): Whether the material is theoretical.
sort_fields (List[str]): Fields used to sort results. Prefixing with '-' will sort in descending order.
num_chunks (int): Maximum number of chunks of data to yield. None will yield all possible.
Expand Down Expand Up @@ -234,7 +234,7 @@ def search_summary_docs(
query_params.update({"has_reconstructed": has_reconstructed})

if has_props:
query_params.update({"has_props": ",".join(has_props)})
query_params.update({"has_props": ",".join([i.value for i in has_props])})

if theoretical is not None:
query_params.update({"theoretical": theoretical})
Expand Down
3 changes: 2 additions & 1 deletion tests/test_mprester.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from emmet.core.symmetry import CrystalSystem
from emmet.core.vasp.calc_types import CalcType
from emmet.core.summary import HasProps
from mp_api.core.settings import MAPISettings
from mp_api.matproj import MPRester
from mp_api.routes.tasks.models import TaskDoc
Expand Down Expand Up @@ -263,7 +264,7 @@ def test_query(self, mpr):
"crystal_system": CrystalSystem.cubic,
"spacegroup_number": 38,
"spacegroup_symbol": "Amm2",
"has_props": ["dielectric"],
"has_props": [HasProps.dielectric],
"theoretical": True,
"has_reconstructed": False,
"magnetic_ordering": Ordering.FM,
Expand Down

0 comments on commit bac5b28

Please sign in to comment.