Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small key endpoint related bug fixes #936

Merged
merged 24 commits into from
Feb 14, 2024
Merged
11 changes: 8 additions & 3 deletions emmet-api/emmet/api/core/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
Project database. See the `SurfacePropDoc` schema for a full list of fields returned by this route.",
},
{
"name": "Robocrystallographer",
"name": "Materials Robocrystallographer",
"description": "Route providing a computed text description for a material following the \
methodology discussed by [Ganose *et al.*](https://doi.org/10.1557/mrc.2019.94) \
Note that descriptions may not been calculated for all materials in the Materials \
Expand All @@ -204,11 +204,12 @@
Project database. See the `SynthesisSearchResultModel` schema for a full list of fields returned by this route.",
},
{
"name": "Electrodes",
"name": "Materials Electrodes",
"description": "Route providing computed electrode data for a material following the \
methodology discussed by [Shen *et al.*](https://doi.org/10.1038/s41524-020-00422-3) \
Note that electrode data has not been calculated for all materials in the Materials \
Project database. See the `InsertionElectrodeDoc` schema for a full list of fields returned by this route.",
Project database. See the `InsertionElectrodeDoc` and `ConversionElectrodeDoc` schema \
for a full list of fields returned by this route.",
},
{
"name": "Materials Oxidation States",
Expand Down Expand Up @@ -238,6 +239,10 @@
"belong to, following the methodolgy discussed by "
"[Woods-Robinson, Horton and Persson](https://arxiv.org/pdf/2206.10715).",
},
{
"name": "Materials Bonds",
"description": "Route for retrevial of bonding information for a given material.",
},
{
"name": "MPComplete",
"description": "Route for submitting structures to the Materials Project. If calculations are run with the \
Expand Down
7 changes: 4 additions & 3 deletions emmet-api/emmet/api/routes/dois/resources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from maggma.api.resource import ReadOnlyResource
from emmet.core.dois import DOIDoc
from emmet.api.routes.materials.materials.query_operators import MultiMaterialIDQuery
from emmet.api.core.global_header import GlobalHeaderProcessor
from maggma.api.query_operator import PaginationQuery, SparseFieldsQuery
from emmet.api.core.settings import MAPISettings
Expand All @@ -10,14 +11,14 @@ def dois_resource(dois_store):
dois_store,
DOIDoc,
query_operators=[
MultiMaterialIDQuery(),
PaginationQuery(),
SparseFieldsQuery(DOIDoc, default_fields=["task_id", "doi"]),
SparseFieldsQuery(DOIDoc, default_fields=["material_id", "doi"]),
],
header_processor=GlobalHeaderProcessor(),
tags=["DOIs"],
enable_default_search=False,
disable_validation=True,
timeout=MAPISettings().TIMEOUT,
timeout=MAPISettings().TIMEOUT, # type: ignore
)

return resource
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def charge_density_resource(s3_store):
tags=["Materials Charge Density"],
sub_path="/charge_density/",
enable_default_search=True,
enable_get_by_key=False,
disable_validation=True,
query_disk_use=False,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def bs_resource(es_store):
],
header_processor=GlobalHeaderProcessor(),
tags=["Materials Electronic Structure"],
enable_get_by_key=False,
sub_path="/electronic_structure/bandstructure/",
disable_validation=True,
timeout=timeout,
Expand All @@ -85,7 +84,6 @@ def bs_obj_resource(s3_store):
],
header_processor=GlobalHeaderProcessor(),
tags=["Materials Electronic Structure"],
enable_get_by_key=False,
enable_default_search=True,
sub_path="/electronic_structure/bandstructure/object/",
query_disk_use=False,
Expand All @@ -109,7 +107,6 @@ def dos_resource(es_store):
],
header_processor=GlobalHeaderProcessor(),
tags=["Materials Electronic Structure"],
enable_get_by_key=False,
sub_path="/electronic_structure/dos/",
disable_validation=True,
timeout=timeout,
Expand All @@ -128,7 +125,6 @@ def dos_obj_resource(s3_store):
],
header_processor=GlobalHeaderProcessor(),
tags=["Materials Electronic Structure"],
enable_get_by_key=False,
enable_default_search=True,
sub_path="/electronic_structure/dos/object/",
query_disk_use=False,
Expand Down
2 changes: 2 additions & 0 deletions emmet-api/emmet/api/routes/materials/eos/resources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from maggma.api.resource import ReadOnlyResource
from emmet.core.eos import EOSDoc
from emmet.api.routes.materials.materials.query_operators import MultiMaterialIDQuery

from maggma.api.query_operator import PaginationQuery, SparseFieldsQuery
from emmet.api.core.global_header import GlobalHeaderProcessor
Expand All @@ -11,6 +12,7 @@ def eos_resource(eos_store):
eos_store,
EOSDoc,
query_operators=[
MultiMaterialIDQuery(),
PaginationQuery(),
SparseFieldsQuery(EOSDoc, default_fields=["task_id"]),
],
Expand Down
2 changes: 2 additions & 0 deletions emmet-api/emmet/api/routes/materials/fermi/resources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from maggma.api.resource import ReadOnlyResource
from emmet.core.fermi import FermiDoc
from emmet.api.routes.materials.materials.query_operators import MultiMaterialIDQuery
from emmet.api.core.global_header import GlobalHeaderProcessor
from maggma.api.query_operator import PaginationQuery, SparseFieldsQuery

Expand All @@ -9,6 +10,7 @@ def fermi_resource(fermi_store):
fermi_store,
FermiDoc,
query_operators=[
MultiMaterialIDQuery(),
PaginationQuery(),
SparseFieldsQuery(FermiDoc, default_fields=["task_id", "last_updated"]),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
GBStructureQuery,
GBTaskIDQuery,
)
from emmet.api.routes.materials.materials.query_operators import MultiMaterialIDQuery
from maggma.api.query_operator import (
PaginationQuery,
SparseFieldsQuery,
Expand All @@ -19,6 +20,7 @@ def gb_resource(gb_store):
gb_store,
GrainBoundaryDoc,
query_operators=[
MultiMaterialIDQuery(),
GBTaskIDQuery(),
NumericQuery(
model=GrainBoundaryDoc, excluded_fields=["rotation_axis", "gb_plane"]
Expand All @@ -31,10 +33,9 @@ def gb_resource(gb_store):
],
header_processor=GlobalHeaderProcessor(),
tags=["Materials Grain Boundaries"],
sub_path="/grain_boundary/",
enable_get_by_key=False,
sub_path="/grain_boundaries/",
disable_validation=True,
timeout=MAPISettings().TIMEOUT,
timeout=MAPISettings().TIMEOUT, # type: ignore
)

return resource
7 changes: 3 additions & 4 deletions emmet-api/emmet/api/routes/materials/materials/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from emmet.api.core.global_header import GlobalHeaderProcessor
from emmet.api.core.settings import MAPISettings

timeout = MAPISettings().TIMEOUT
timeout = MAPISettings().TIMEOUT # type: ignore


def find_structure_resource(materials_store):
Expand Down Expand Up @@ -90,9 +90,8 @@ def blessed_tasks_resource(materials_store):
header_processor=GlobalHeaderProcessor(),
tags=["Materials"],
sub_path="/core/blessed_tasks/",
enable_get_by_key=False,
disable_validation=True,
timeout=MAPISettings().TIMEOUT,
timeout=MAPISettings().TIMEOUT, # type: ignore
)

return resource
Expand Down Expand Up @@ -122,7 +121,7 @@ def materials_resource(materials_store):
tags=["Materials"],
sub_path="/core/",
disable_validation=True,
timeout=MAPISettings().TIMEOUT,
timeout=MAPISettings().TIMEOUT, # type: ignore
)

return resource
7 changes: 4 additions & 3 deletions emmet-api/emmet/api/routes/materials/phonon/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from maggma.api.resource import ReadOnlyResource

from emmet.core.phonon import PhononBSDOSDoc
from emmet.api.routes.materials.materials.query_operators import MultiMaterialIDQuery
from emmet.api.core.global_header import GlobalHeaderProcessor
from emmet.api.core.settings import MAPISettings

Expand All @@ -11,17 +12,17 @@ def phonon_bsdos_resource(phonon_bs_store):
phonon_bs_store,
PhononBSDOSDoc,
query_operators=[
MultiMaterialIDQuery(),
PaginationQuery(),
SparseFieldsQuery(
PhononBSDOSDoc, default_fields=["task_id", "last_updated"]
PhononBSDOSDoc, default_fields=["material_id", "last_updated"]
),
],
header_processor=GlobalHeaderProcessor(),
tags=["Materials Phonon"],
sub_path="/phonon/",
enable_default_search=False,
disable_validation=True,
timeout=MAPISettings().TIMEOUT,
timeout=MAPISettings().TIMEOUT, # type: ignore
)

return resource
2 changes: 1 addition & 1 deletion emmet-api/emmet/api/routes/materials/robocrys/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def robo_search_resource(robo_store):
robo_store,
RobocrystallogapherDoc,
pipeline_query_operator=RoboTextSearchQuery(),
tags=["Robocrystallographer"],
sub_path="/robocrys/text_search/",
header_processor=GlobalHeaderProcessor(),
tags=["Materials Robocrystallographer"],
timeout=timeout,
)

Expand Down
5 changes: 3 additions & 2 deletions emmet-api/emmet/api/routes/materials/similarity/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from maggma.api.resource import ReadOnlyResource
from emmet.api.core.global_header import GlobalHeaderProcessor
from emmet.api.core.settings import MAPISettings
from emmet.api.routes.materials.materials.query_operators import MultiMaterialIDQuery

from emmet.core.similarity import SimilarityDoc

Expand All @@ -11,15 +12,15 @@ def similarity_resource(similarity_store):
similarity_store,
SimilarityDoc,
query_operators=[
MultiMaterialIDQuery(),
PaginationQuery(),
SparseFieldsQuery(SimilarityDoc, default_fields=["material_id"]),
],
header_processor=GlobalHeaderProcessor(),
tags=["Materials Similarity"],
sub_path="/similarity/",
enable_default_search=False,
disable_validation=True,
timeout=MAPISettings().TIMEOUT,
timeout=MAPISettings().TIMEOUT, # type: ignore
)

return resource
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def substrates_resource(substrates_store):
header_processor=GlobalHeaderProcessor(),
tags=["Materials Substrates"],
sub_path="/substrates/",
enable_get_by_key=False,
disable_validation=True,
timeout=MAPISettings().TIMEOUT,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from emmet.api.core.settings import MAPISettings

from emmet.api.core.global_header import GlobalHeaderProcessor
from emmet.api.routes.materials.materials.query_operators import MultiMaterialIDQuery
from emmet.api.routes.materials.surface_properties.query_operators import (
ReconstructedQuery,
)
Expand All @@ -15,6 +16,7 @@ def surface_props_resource(surface_prop_store):
surface_prop_store,
SurfacePropDoc,
query_operators=[
MultiMaterialIDQuery(),
NumericQuery(model=SurfacePropDoc),
ReconstructedQuery(),
PaginationQuery(),
Expand All @@ -24,7 +26,7 @@ def surface_props_resource(surface_prop_store):
tags=["Materials Surface Properties"],
sub_path="/surface_properties/",
disable_validation=True,
timeout=MAPISettings().TIMEOUT,
timeout=MAPISettings().TIMEOUT, # type: ignore
)

return resource
1 change: 0 additions & 1 deletion emmet-api/emmet/api/routes/materials/tasks/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def task_deprecation_resource(materials_store):
DeprecationDoc,
query_operators=[DeprecationQuery(), PaginationQuery()],
tags=["Materials Tasks"],
enable_get_by_key=False,
enable_default_search=True,
sub_path="/tasks/deprecation/",
header_processor=GlobalHeaderProcessor(),
Expand Down
28 changes: 28 additions & 0 deletions emmet-api/emmet/api/routes/materials/thermo/query_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,31 @@ def query(
crit.update({"thermo_type": {"$in": thermo_type_list}})

return {"criteria": crit}


class MultiPhaseDiagramIDQuery(QueryOperator):
"""
Method to generate a query for different root-level phase_diagram_id values
"""

def query(
self,
phase_diagram_ids: Optional[str] = Query(
None,
description="Comma-separated list of phase_diagram_id values to query on",
),
) -> STORE_PARAMS:
crit = {} # type: dict

if phase_diagram_ids:
phase_diagram_id_list = [
phase_diagram_id.strip()
for phase_diagram_id in phase_diagram_ids.split(",")
]

if len(phase_diagram_id_list) == 1:
crit.update({"phase_diagram_id": phase_diagram_id_list[0]})
else:
crit.update({"phase_diagram_id": {"$in": phase_diagram_id_list}})

return {"criteria": crit}
9 changes: 8 additions & 1 deletion emmet-api/emmet/api/routes/materials/thermo/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
IsStableQuery,
MultiThermoIDQuery,
MultiThermoTypeQuery,
MultiPhaseDiagramIDQuery,
)
from emmet.api.core.global_header import GlobalHeaderProcessor
from emmet.api.routes.materials.materials.query_operators import (
Expand All @@ -26,10 +27,16 @@ def phase_diagram_resource(phase_diagram_store):
resource = ReadOnlyResource(
phase_diagram_store,
PhaseDiagramDoc,
query_operators=[
MultiPhaseDiagramIDQuery(),
SparseFieldsQuery(
ThermoDoc,
default_fields=["phase_diagram_id"],
),
],
tags=["Materials Thermo"],
sub_path="/thermo/phase_diagram/",
disable_validation=True,
enable_default_search=False,
header_processor=GlobalHeaderProcessor(),
query_disk_use=False,
)
Expand Down
16 changes: 8 additions & 8 deletions emmet-api/emmet/api/routes/materials/xas/query_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@ def ensure_indexes(self): # pragma: no cover
return [(key, False) for key in keys]


class XASTaskIDQuery(QueryOperator):
class XASIDQuery(QueryOperator):
"""
Method to generate a query for XAS data given a list of task_ids
Method to generate a query for XAS data given a list of spectrum_ids
"""

def query(
self,
material_ids: Optional[str] = Query(
None, description="Comma-separated list of material_id to query on"
spectrum_ids: Optional[str] = Query(
None, description="Comma-separated list of spectrum_id to query on"
),
) -> STORE_PARAMS:
crit = {}

if material_ids:
if spectrum_ids:
crit.update(
{
"material_id": {
"spectrum_id": {
"$in": [
material_id.strip()
for material_id in material_ids.split(",")
spectrum_id.strip()
for spectrum_id in spectrum_ids.split(",")
]
}
}
Expand Down
Loading
Loading