Skip to content

Commit

Permalink
Remove single ID endpoints (#935)
Browse files Browse the repository at this point in the history
* Remove get by key disable

* Fix eos

* Fix gb

* Fix similarity

* Fix dois

* Fix fermi

* Fix xas

* Fix phonon

* Fix surface props

* Fix electrodes doc position

* Fix robocrys docs

* More doc fixes

* Fix robocrys tags

* Fix doi endpoint key

* Rename grain_boundaries

* Fix XAS query op test

* More xps test fixes

* Typo

* Temp skip matminer related builders tests

* Fix pytest marks

* Comment out tests
  • Loading branch information
munrojm authored Feb 13, 2024
1 parent 666433f commit 413bb5c
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 66 deletions.
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
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
8 changes: 5 additions & 3 deletions emmet-api/emmet/api/routes/materials/xas/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
from emmet.core.xas import XASDoc

from maggma.api.query_operator import PaginationQuery, SparseFieldsQuery
from emmet.api.routes.materials.materials.query_operators import MultiMaterialIDQuery
from emmet.api.routes.materials.materials.query_operators import (
ElementsQuery,
FormulaQuery,
ChemsysQuery,
)
from emmet.api.core.global_header import GlobalHeaderProcessor
from emmet.api.routes.materials.xas.query_operators import XASQuery, XASTaskIDQuery
from emmet.api.routes.materials.xas.query_operators import XASQuery, XASIDQuery
from emmet.api.core.settings import MAPISettings


Expand All @@ -17,11 +18,12 @@ def xas_resource(xas_store):
xas_store,
XASDoc,
query_operators=[
MultiMaterialIDQuery(),
FormulaQuery(),
ChemsysQuery(),
ElementsQuery(),
XASQuery(),
XASTaskIDQuery(),
XASIDQuery(),
PaginationQuery(),
SparseFieldsQuery(
XASDoc,
Expand All @@ -40,7 +42,7 @@ def xas_resource(xas_store):
tags=["Materials XAS"],
sub_path="/xas/",
disable_validation=True,
timeout=MAPISettings().TIMEOUT,
timeout=MAPISettings().TIMEOUT, # type: ignore
)

return resource
1 change: 0 additions & 1 deletion emmet-api/emmet/api/routes/molecules/tasks/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def task_deprecation_resource(task_store):
DeprecationDoc,
query_operators=[DeprecationQuery(), PaginationQuery()],
tags=["Molecules Tasks"],
enable_get_by_key=False,
enable_default_search=True,
sub_path="/tasks/deprecation/",
header_processor=GlobalHeaderProcessor(),
Expand Down
4 changes: 2 additions & 2 deletions emmet-api/material_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

resources = {}

default_settings = MAPISettings()
default_settings = MAPISettings() # type: ignore

db_uri = os.environ.get("MPCONTRIBS_MONGO_HOST", None)
db_version = default_settings.DB_VERSION
Expand Down Expand Up @@ -136,7 +136,7 @@
)

doi_store = MongoURIStore(
uri=db_uri, database="mp_core", key="task_id", collection_name="dois"
uri=db_uri, database="mp_core", key="material_id", collection_name="dois"
)

substrates_store = MongoURIStore(
Expand Down
Loading

0 comments on commit 413bb5c

Please sign in to comment.