Skip to content

Commit

Permalink
Small key endpoint related bug fixes (#936)
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

* Fix task_id -> material_id

* Fix thermo
  • Loading branch information
munrojm authored Feb 14, 2024
1 parent 413bb5c commit 6853ed2
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 6 deletions.
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
2 changes: 1 addition & 1 deletion emmet-core/emmet/core/dois.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DOIDoc(BaseModel):
description="Bibtex reference of the material.",
)

task_id: Optional[str] = Field(
material_id: Optional[str] = Field(
None,
description="The Materials Project ID of the material. This comes in the form: mp-******.",
)
2 changes: 1 addition & 1 deletion emmet-core/emmet/core/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EOSDoc(BaseModel):
description="Data for each type of equation of state.",
)

task_id: Optional[str] = Field(
material_id: Optional[str] = Field(
None,
description="The Materials Project ID of the material. This comes in the form: mp-******.",
)
2 changes: 1 addition & 1 deletion emmet-core/emmet/core/fermi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class FermiDoc(BaseModel):
Is either CBM or VBM for semiconductors, or fermi_surface for metals.",
)

task_id: Optional[str] = Field(
material_id: Optional[str] = Field(
None,
description="The Materials Project ID of the material. This comes in the form: mp-******.",
)
Expand Down
2 changes: 1 addition & 1 deletion emmet-core/emmet/core/grain_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GrainBoundaryDoc(BaseModel):
Grain boundary energies, work of separation...
"""

task_id: Optional[str] = Field(
material_id: Optional[str] = Field(
None,
description="The Materials Project ID of the material. This comes in the form: mp-******.",
)
Expand Down
2 changes: 1 addition & 1 deletion emmet-core/emmet/core/surface_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class SurfacePropDoc(BaseModel):
description="Whether the entry has any reconstructed surfaces.",
)

task_id: Optional[str] = Field(
material_id: Optional[str] = Field(
None,
description="The Materials Project ID of the material. This comes in the form: mp-******.",
)
Expand Down

0 comments on commit 6853ed2

Please sign in to comment.