diff --git a/emmet-api/emmet/api/routes/materials/thermo/query_operators.py b/emmet-api/emmet/api/routes/materials/thermo/query_operators.py index 24a3a21ab4..ea05c2ce49 100644 --- a/emmet-api/emmet/api/routes/materials/thermo/query_operators.py +++ b/emmet-api/emmet/api/routes/materials/thermo/query_operators.py @@ -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} diff --git a/emmet-api/emmet/api/routes/materials/thermo/resources.py b/emmet-api/emmet/api/routes/materials/thermo/resources.py index 676c71f6ca..e714153539 100644 --- a/emmet-api/emmet/api/routes/materials/thermo/resources.py +++ b/emmet-api/emmet/api/routes/materials/thermo/resources.py @@ -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 ( @@ -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, ) diff --git a/emmet-core/emmet/core/dois.py b/emmet-core/emmet/core/dois.py index 3bb06d4e35..9ed9eab3d9 100644 --- a/emmet-core/emmet/core/dois.py +++ b/emmet-core/emmet/core/dois.py @@ -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-******.", ) diff --git a/emmet-core/emmet/core/eos.py b/emmet-core/emmet/core/eos.py index b084b452f8..84f04a67af 100644 --- a/emmet-core/emmet/core/eos.py +++ b/emmet-core/emmet/core/eos.py @@ -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-******.", ) diff --git a/emmet-core/emmet/core/fermi.py b/emmet-core/emmet/core/fermi.py index 80ae606c14..f2f23898d3 100644 --- a/emmet-core/emmet/core/fermi.py +++ b/emmet-core/emmet/core/fermi.py @@ -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-******.", ) diff --git a/emmet-core/emmet/core/grain_boundary.py b/emmet-core/emmet/core/grain_boundary.py index ada3c643d4..75013b8c0c 100644 --- a/emmet-core/emmet/core/grain_boundary.py +++ b/emmet-core/emmet/core/grain_boundary.py @@ -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-******.", ) diff --git a/emmet-core/emmet/core/surface_properties.py b/emmet-core/emmet/core/surface_properties.py index fcee35d53e..d419633d0c 100644 --- a/emmet-core/emmet/core/surface_properties.py +++ b/emmet-core/emmet/core/surface_properties.py @@ -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-******.", )