From 5e59c47beb32f9a9d7d4b966065c7ab8fbc39077 Mon Sep 17 00:00:00 2001 From: munrojm Date: Mon, 29 Jan 2024 16:19:40 -0800 Subject: [PATCH 01/23] Remove get by key disable --- .../emmet/api/routes/materials/charge_density/resources.py | 1 - .../api/routes/materials/electronic_structure/resources.py | 4 ---- .../emmet/api/routes/materials/grain_boundary/resources.py | 1 - .../emmet/api/routes/materials/materials/resources.py | 7 +++---- .../emmet/api/routes/materials/substrates/resources.py | 1 - emmet-api/emmet/api/routes/materials/tasks/resources.py | 1 - emmet-api/emmet/api/routes/molecules/tasks/resources.py | 1 - 7 files changed, 3 insertions(+), 13 deletions(-) diff --git a/emmet-api/emmet/api/routes/materials/charge_density/resources.py b/emmet-api/emmet/api/routes/materials/charge_density/resources.py index a6d7a4f4e7..31d112671e 100644 --- a/emmet-api/emmet/api/routes/materials/charge_density/resources.py +++ b/emmet-api/emmet/api/routes/materials/charge_density/resources.py @@ -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, ) diff --git a/emmet-api/emmet/api/routes/materials/electronic_structure/resources.py b/emmet-api/emmet/api/routes/materials/electronic_structure/resources.py index 6a32c6052e..bacfe9077c 100644 --- a/emmet-api/emmet/api/routes/materials/electronic_structure/resources.py +++ b/emmet-api/emmet/api/routes/materials/electronic_structure/resources.py @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py b/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py index c4d27ad3a0..29b726ed65 100644 --- a/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py +++ b/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py @@ -32,7 +32,6 @@ def gb_resource(gb_store): header_processor=GlobalHeaderProcessor(), tags=["Materials Grain Boundaries"], sub_path="/grain_boundary/", - enable_get_by_key=False, disable_validation=True, timeout=MAPISettings().TIMEOUT, ) diff --git a/emmet-api/emmet/api/routes/materials/materials/resources.py b/emmet-api/emmet/api/routes/materials/materials/resources.py index 06c0d5560f..de6c2bcea5 100644 --- a/emmet-api/emmet/api/routes/materials/materials/resources.py +++ b/emmet-api/emmet/api/routes/materials/materials/resources.py @@ -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): @@ -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 @@ -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 diff --git a/emmet-api/emmet/api/routes/materials/substrates/resources.py b/emmet-api/emmet/api/routes/materials/substrates/resources.py index 856cc6c47a..16896f1343 100644 --- a/emmet-api/emmet/api/routes/materials/substrates/resources.py +++ b/emmet-api/emmet/api/routes/materials/substrates/resources.py @@ -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, ) diff --git a/emmet-api/emmet/api/routes/materials/tasks/resources.py b/emmet-api/emmet/api/routes/materials/tasks/resources.py index ab90b426f2..b997d6a5ef 100644 --- a/emmet-api/emmet/api/routes/materials/tasks/resources.py +++ b/emmet-api/emmet/api/routes/materials/tasks/resources.py @@ -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(), diff --git a/emmet-api/emmet/api/routes/molecules/tasks/resources.py b/emmet-api/emmet/api/routes/molecules/tasks/resources.py index 48e794c5d9..a65757232d 100644 --- a/emmet-api/emmet/api/routes/molecules/tasks/resources.py +++ b/emmet-api/emmet/api/routes/molecules/tasks/resources.py @@ -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(), From 12cbc5d5740a6c9a7cf0a082b09433d2507e17d7 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 14:21:39 -0800 Subject: [PATCH 02/23] Fix eos --- emmet-api/emmet/api/routes/materials/eos/resources.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emmet-api/emmet/api/routes/materials/eos/resources.py b/emmet-api/emmet/api/routes/materials/eos/resources.py index cfc6aeb93f..7a584ba517 100644 --- a/emmet-api/emmet/api/routes/materials/eos/resources.py +++ b/emmet-api/emmet/api/routes/materials/eos/resources.py @@ -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 @@ -11,6 +12,7 @@ def eos_resource(eos_store): eos_store, EOSDoc, query_operators=[ + MultiMaterialIDQuery(), PaginationQuery(), SparseFieldsQuery(EOSDoc, default_fields=["task_id"]), ], From b672a73c10f4f68ee99beba1b0f2a526200109fd Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 14:21:42 -0800 Subject: [PATCH 03/23] Fix gb --- .../emmet/api/routes/materials/grain_boundary/resources.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py b/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py index 29b726ed65..13aa02f2f8 100644 --- a/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py +++ b/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py @@ -5,6 +5,7 @@ GBStructureQuery, GBTaskIDQuery, ) +from emmet.api.routes.materials.materials.query_operators import MultiMaterialIDQuery from maggma.api.query_operator import ( PaginationQuery, SparseFieldsQuery, @@ -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"] @@ -33,7 +35,7 @@ def gb_resource(gb_store): tags=["Materials Grain Boundaries"], sub_path="/grain_boundary/", disable_validation=True, - timeout=MAPISettings().TIMEOUT, + timeout=MAPISettings().TIMEOUT, # type: ignore ) return resource From 833853da5ab9f0fe5579205731d78acaec447af1 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 14:21:53 -0800 Subject: [PATCH 04/23] Fix similarity --- emmet-api/emmet/api/routes/materials/similarity/resources.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/emmet-api/emmet/api/routes/materials/similarity/resources.py b/emmet-api/emmet/api/routes/materials/similarity/resources.py index c0a4ad4161..cfb9184481 100644 --- a/emmet-api/emmet/api/routes/materials/similarity/resources.py +++ b/emmet-api/emmet/api/routes/materials/similarity/resources.py @@ -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 @@ -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 From 9bd2e1545139d2430d5651b4dcfb38d025fba440 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 14:38:23 -0800 Subject: [PATCH 05/23] Fix dois --- emmet-api/emmet/api/routes/dois/resources.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/emmet-api/emmet/api/routes/dois/resources.py b/emmet-api/emmet/api/routes/dois/resources.py index 60604e9981..19893126d7 100644 --- a/emmet-api/emmet/api/routes/dois/resources.py +++ b/emmet-api/emmet/api/routes/dois/resources.py @@ -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 @@ -10,14 +11,14 @@ def dois_resource(dois_store): dois_store, DOIDoc, query_operators=[ + MultiMaterialIDQuery(), PaginationQuery(), SparseFieldsQuery(DOIDoc, default_fields=["task_id", "doi"]), ], header_processor=GlobalHeaderProcessor(), tags=["DOIs"], - enable_default_search=False, disable_validation=True, - timeout=MAPISettings().TIMEOUT, + timeout=MAPISettings().TIMEOUT, # type: ignore ) return resource From a0e18644074a718ac4c446dc695405c147484887 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 14:38:26 -0800 Subject: [PATCH 06/23] Fix fermi --- emmet-api/emmet/api/routes/materials/fermi/resources.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emmet-api/emmet/api/routes/materials/fermi/resources.py b/emmet-api/emmet/api/routes/materials/fermi/resources.py index de98479b46..c527aadb11 100644 --- a/emmet-api/emmet/api/routes/materials/fermi/resources.py +++ b/emmet-api/emmet/api/routes/materials/fermi/resources.py @@ -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 @@ -9,6 +10,7 @@ def fermi_resource(fermi_store): fermi_store, FermiDoc, query_operators=[ + MultiMaterialIDQuery(), PaginationQuery(), SparseFieldsQuery(FermiDoc, default_fields=["task_id", "last_updated"]), ], From 87262c52ec96d0644761e57914ff6f2b20241d41 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 14:38:32 -0800 Subject: [PATCH 07/23] Fix xas --- .../api/routes/materials/xas/query_operators.py | 16 ++++++++-------- .../emmet/api/routes/materials/xas/resources.py | 8 +++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/emmet-api/emmet/api/routes/materials/xas/query_operators.py b/emmet-api/emmet/api/routes/materials/xas/query_operators.py index 2e94388ab0..ddd394c079 100644 --- a/emmet-api/emmet/api/routes/materials/xas/query_operators.py +++ b/emmet-api/emmet/api/routes/materials/xas/query_operators.py @@ -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(",") ] } } diff --git a/emmet-api/emmet/api/routes/materials/xas/resources.py b/emmet-api/emmet/api/routes/materials/xas/resources.py index 49a2e75d81..811946dcdd 100644 --- a/emmet-api/emmet/api/routes/materials/xas/resources.py +++ b/emmet-api/emmet/api/routes/materials/xas/resources.py @@ -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 @@ -17,11 +18,12 @@ def xas_resource(xas_store): xas_store, XASDoc, query_operators=[ + MultiMaterialIDQuery(), FormulaQuery(), ChemsysQuery(), ElementsQuery(), XASQuery(), - XASTaskIDQuery(), + XASIDQuery(), PaginationQuery(), SparseFieldsQuery( XASDoc, @@ -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 From b2bbaa36d8833a025bf6bb5d90fec1c8c9daea0c Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 15:33:19 -0800 Subject: [PATCH 08/23] Fix phonon --- emmet-api/emmet/api/routes/materials/phonon/resources.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/emmet-api/emmet/api/routes/materials/phonon/resources.py b/emmet-api/emmet/api/routes/materials/phonon/resources.py index 149b8e05d1..79d9d79949 100644 --- a/emmet-api/emmet/api/routes/materials/phonon/resources.py +++ b/emmet-api/emmet/api/routes/materials/phonon/resources.py @@ -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 @@ -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 From 376870da8007333a0398a722c04564240e62c288 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 15:33:30 -0800 Subject: [PATCH 09/23] Fix surface props --- .../api/routes/materials/surface_properties/resources.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/emmet-api/emmet/api/routes/materials/surface_properties/resources.py b/emmet-api/emmet/api/routes/materials/surface_properties/resources.py index 92f57ef6bd..997081f328 100644 --- a/emmet-api/emmet/api/routes/materials/surface_properties/resources.py +++ b/emmet-api/emmet/api/routes/materials/surface_properties/resources.py @@ -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, ) @@ -15,6 +16,7 @@ def surface_props_resource(surface_prop_store): surface_prop_store, SurfacePropDoc, query_operators=[ + MultiMaterialIDQuery(), NumericQuery(model=SurfacePropDoc), ReconstructedQuery(), PaginationQuery(), @@ -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 From 7ff34a96862a118ec285e10c8b2550e520e8dda9 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 15:41:05 -0800 Subject: [PATCH 10/23] Fix electrodes doc position --- emmet-api/emmet/api/core/documentation.py | 5 +++-- emmet-api/material_resources.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/emmet-api/emmet/api/core/documentation.py b/emmet-api/emmet/api/core/documentation.py index 87051e8c1e..b147a004be 100644 --- a/emmet-api/emmet/api/core/documentation.py +++ b/emmet-api/emmet/api/core/documentation.py @@ -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", diff --git a/emmet-api/material_resources.py b/emmet-api/material_resources.py index a0a7e39eee..28ffe6e386 100644 --- a/emmet-api/material_resources.py +++ b/emmet-api/material_resources.py @@ -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 From c08496cc0d3dfb0013126530052b29fb582ecd04 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 15:59:43 -0800 Subject: [PATCH 11/23] Fix robocrys docs --- emmet-api/emmet/api/core/documentation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/emmet-api/emmet/api/core/documentation.py b/emmet-api/emmet/api/core/documentation.py index b147a004be..1d99d77f40 100644 --- a/emmet-api/emmet/api/core/documentation.py +++ b/emmet-api/emmet/api/core/documentation.py @@ -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 \ @@ -239,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 \ From b75ab73f21607c805191a73d68f5a3657fed7146 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 15:59:53 -0800 Subject: [PATCH 12/23] More doc fixes --- emmet-api/emmet/api/routes/materials/robocrys/resources.py | 1 + 1 file changed, 1 insertion(+) diff --git a/emmet-api/emmet/api/routes/materials/robocrys/resources.py b/emmet-api/emmet/api/routes/materials/robocrys/resources.py index 828fc2c3c7..cfca46ed17 100644 --- a/emmet-api/emmet/api/routes/materials/robocrys/resources.py +++ b/emmet-api/emmet/api/routes/materials/robocrys/resources.py @@ -40,6 +40,7 @@ def robo_search_resource(robo_store): tags=["Robocrystallographer"], sub_path="/robocrys/text_search/", header_processor=GlobalHeaderProcessor(), + tags=["Materials Robocrystallographer"], timeout=timeout, ) From d8a7b5a176f96672430f75ef60b2462b9acb509e Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 30 Jan 2024 16:00:29 -0800 Subject: [PATCH 13/23] Fix robocrys tags --- emmet-api/emmet/api/routes/materials/robocrys/resources.py | 1 - 1 file changed, 1 deletion(-) diff --git a/emmet-api/emmet/api/routes/materials/robocrys/resources.py b/emmet-api/emmet/api/routes/materials/robocrys/resources.py index cfca46ed17..8f0afb75f4 100644 --- a/emmet-api/emmet/api/routes/materials/robocrys/resources.py +++ b/emmet-api/emmet/api/routes/materials/robocrys/resources.py @@ -37,7 +37,6 @@ 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"], From 790be30eafd5c27879d02ab71474c27c60d4122c Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 6 Feb 2024 17:02:15 -0800 Subject: [PATCH 14/23] Fix doi endpoint key --- emmet-api/emmet/api/routes/dois/resources.py | 2 +- emmet-api/material_resources.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emmet-api/emmet/api/routes/dois/resources.py b/emmet-api/emmet/api/routes/dois/resources.py index 19893126d7..59ce60a993 100644 --- a/emmet-api/emmet/api/routes/dois/resources.py +++ b/emmet-api/emmet/api/routes/dois/resources.py @@ -13,7 +13,7 @@ def dois_resource(dois_store): query_operators=[ MultiMaterialIDQuery(), PaginationQuery(), - SparseFieldsQuery(DOIDoc, default_fields=["task_id", "doi"]), + SparseFieldsQuery(DOIDoc, default_fields=["material_id", "doi"]), ], header_processor=GlobalHeaderProcessor(), tags=["DOIs"], diff --git a/emmet-api/material_resources.py b/emmet-api/material_resources.py index 28ffe6e386..073dfa499e 100644 --- a/emmet-api/material_resources.py +++ b/emmet-api/material_resources.py @@ -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( From c5161e162c542797fb2a56cf550ad559c636a1d1 Mon Sep 17 00:00:00 2001 From: munrojm Date: Thu, 8 Feb 2024 13:41:16 -0800 Subject: [PATCH 15/23] Rename grain_boundaries --- .../emmet/api/routes/materials/grain_boundary/resources.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py b/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py index 13aa02f2f8..a6f50ff661 100644 --- a/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py +++ b/emmet-api/emmet/api/routes/materials/grain_boundary/resources.py @@ -33,7 +33,7 @@ def gb_resource(gb_store): ], header_processor=GlobalHeaderProcessor(), tags=["Materials Grain Boundaries"], - sub_path="/grain_boundary/", + sub_path="/grain_boundaries/", disable_validation=True, timeout=MAPISettings().TIMEOUT, # type: ignore ) From db5361932870348edbde9634261f7eb81d6f55c8 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 13 Feb 2024 14:25:28 -0800 Subject: [PATCH 16/23] Fix XAS query op test --- .../materials/xas/test_query_operators.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/emmet-api/tests/materials/xas/test_query_operators.py b/emmet-api/tests/materials/xas/test_query_operators.py index 50bff07f2a..9488984fee 100644 --- a/emmet-api/tests/materials/xas/test_query_operators.py +++ b/emmet-api/tests/materials/xas/test_query_operators.py @@ -1,4 +1,4 @@ -from emmet.api.routes.materials.xas.query_operators import XASQuery, XASTaskIDQuery +from emmet.api.routes.materials.xas.query_operators import XASQuery, XASIDQuery from monty.tempfile import ScratchDir from monty.serialization import loadfn, dumpfn @@ -32,16 +32,22 @@ def test_xas_operator(): def test_xas_task_id_operator(): - op = XASTaskIDQuery() + op = XASIDQuery() - assert op.query(material_ids="mp-149, mp-13") == { - "criteria": {"material_id": {"$in": ["mp-149", "mp-13"]}} + assert op.query(spectrum_ids=["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"]) == { + "criteria": { + "spectrum_ids": {"$in": ["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"]} + } } with ScratchDir("."): dumpfn(op, "temp.json") new_op = loadfn("temp.json") - assert new_op.query(material_ids="mp-149, mp-13") == { - "criteria": {"material_id": {"$in": ["mp-149", "mp-13"]}} + assert new_op.query( + spectrum_ids=["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"] + ) == { + "criteria": { + "spectrum_ids": {"$in": ["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"]} + } } From 30317f5ef24a317dc254cb6d645ff66b3d2acc14 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 13 Feb 2024 14:43:26 -0800 Subject: [PATCH 17/23] More xps test fixes --- emmet-api/tests/materials/xas/test_query_operators.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/emmet-api/tests/materials/xas/test_query_operators.py b/emmet-api/tests/materials/xas/test_query_operators.py index 9488984fee..18417a5244 100644 --- a/emmet-api/tests/materials/xas/test_query_operators.py +++ b/emmet-api/tests/materials/xas/test_query_operators.py @@ -34,7 +34,7 @@ def test_xas_operator(): def test_xas_task_id_operator(): op = XASIDQuery() - assert op.query(spectrum_ids=["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"]) == { + assert op.query(spectrum_ids="mp-149-XANES-Pd-K, mp-8951-XANES-Pd-K") == { "criteria": { "spectrum_ids": {"$in": ["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"]} } @@ -44,9 +44,7 @@ def test_xas_task_id_operator(): dumpfn(op, "temp.json") new_op = loadfn("temp.json") - assert new_op.query( - spectrum_ids=["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"] - ) == { + assert new_op.query(spectrum_ids="mp-149-XANES-Pd-K, mp-8951-XANES-Pd-K") == { "criteria": { "spectrum_ids": {"$in": ["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"]} } From 3150eff17d5d1366f2ecadbecf4909fb9c2bd6aa Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 13 Feb 2024 14:53:33 -0800 Subject: [PATCH 18/23] Typo --- emmet-api/tests/materials/xas/test_query_operators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emmet-api/tests/materials/xas/test_query_operators.py b/emmet-api/tests/materials/xas/test_query_operators.py index 18417a5244..f2300960bb 100644 --- a/emmet-api/tests/materials/xas/test_query_operators.py +++ b/emmet-api/tests/materials/xas/test_query_operators.py @@ -36,7 +36,7 @@ def test_xas_task_id_operator(): assert op.query(spectrum_ids="mp-149-XANES-Pd-K, mp-8951-XANES-Pd-K") == { "criteria": { - "spectrum_ids": {"$in": ["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"]} + "spectrum_id": {"$in": ["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"]} } } @@ -46,6 +46,6 @@ def test_xas_task_id_operator(): assert new_op.query(spectrum_ids="mp-149-XANES-Pd-K, mp-8951-XANES-Pd-K") == { "criteria": { - "spectrum_ids": {"$in": ["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"]} + "spectrum_id": {"$in": ["mp-149-XANES-Pd-K", "mp-8951-XANES-Pd-K"]} } } From 490dfcd5e6ede8ee200ae83e07b8be66f3dc61e3 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 13 Feb 2024 15:04:05 -0800 Subject: [PATCH 19/23] Temp skip matminer related builders tests --- emmet-builders/tests/test_basic_descriptors.py | 1 + emmet-builders/tests/test_similarity.py | 1 + 2 files changed, 2 insertions(+) diff --git a/emmet-builders/tests/test_basic_descriptors.py b/emmet-builders/tests/test_basic_descriptors.py index 486beafd1a..de4339ce87 100644 --- a/emmet-builders/tests/test_basic_descriptors.py +++ b/emmet-builders/tests/test_basic_descriptors.py @@ -18,6 +18,7 @@ def materials_store(tasks_store): return materials_store +@pytest.skip(reason="Waiting on matminer update") def test_basic_descriptions(materials_store): descriptors_store = MemoryStore() builder = BasicDescriptorsBuilder( diff --git a/emmet-builders/tests/test_similarity.py b/emmet-builders/tests/test_similarity.py index cf09b3ca3e..144497a755 100644 --- a/emmet-builders/tests/test_similarity.py +++ b/emmet-builders/tests/test_similarity.py @@ -31,6 +31,7 @@ def descriptors_store(materials_store): return descriptors_store +@pytest.skip(reason="Waiting on matminer update") def test_basic_descriptions(descriptors_store): similarity_store = MemoryStore() builder = StructureSimilarityBuilder( From 4457863d60f56974a0a36da45c6238690cb207b4 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 13 Feb 2024 15:10:42 -0800 Subject: [PATCH 20/23] Fix pytest marks --- emmet-builders/tests/test_basic_descriptors.py | 2 +- emmet-builders/tests/test_similarity.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emmet-builders/tests/test_basic_descriptors.py b/emmet-builders/tests/test_basic_descriptors.py index de4339ce87..8c10a3d355 100644 --- a/emmet-builders/tests/test_basic_descriptors.py +++ b/emmet-builders/tests/test_basic_descriptors.py @@ -18,7 +18,7 @@ def materials_store(tasks_store): return materials_store -@pytest.skip(reason="Waiting on matminer update") +@pytest.mark.skip(reason="Waiting on matminer update") def test_basic_descriptions(materials_store): descriptors_store = MemoryStore() builder = BasicDescriptorsBuilder( diff --git a/emmet-builders/tests/test_similarity.py b/emmet-builders/tests/test_similarity.py index 144497a755..c38a64b983 100644 --- a/emmet-builders/tests/test_similarity.py +++ b/emmet-builders/tests/test_similarity.py @@ -31,7 +31,7 @@ def descriptors_store(materials_store): return descriptors_store -@pytest.skip(reason="Waiting on matminer update") +@pytest.mark.skip(reason="Waiting on matminer update") def test_basic_descriptions(descriptors_store): similarity_store = MemoryStore() builder = StructureSimilarityBuilder( From 1a7f4086ced17dedf7fadf3075ec900b32193f29 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 13 Feb 2024 15:16:53 -0800 Subject: [PATCH 21/23] Comment out tests --- .../tests/test_basic_descriptors.py | 22 +++++++++---------- emmet-builders/tests/test_similarity.py | 18 +++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/emmet-builders/tests/test_basic_descriptors.py b/emmet-builders/tests/test_basic_descriptors.py index 8c10a3d355..b5bd65f2bd 100644 --- a/emmet-builders/tests/test_basic_descriptors.py +++ b/emmet-builders/tests/test_basic_descriptors.py @@ -1,7 +1,7 @@ import pytest from maggma.stores import JSONStore, MemoryStore -from emmet.builders.materials.basic_descriptors import BasicDescriptorsBuilder +# from emmet.builders.materials.basic_descriptors import BasicDescriptorsBuilder from emmet.builders.vasp.materials import MaterialsBuilder @@ -18,13 +18,13 @@ def materials_store(tasks_store): return materials_store -@pytest.mark.skip(reason="Waiting on matminer update") -def test_basic_descriptions(materials_store): - descriptors_store = MemoryStore() - builder = BasicDescriptorsBuilder( - materials=materials_store, descriptors=descriptors_store - ) - builder.run() - - print(descriptors_store.query_one({})) - assert descriptors_store.count() == 1 +# @pytest.mark.skip(reason="Waiting on matminer update") +# def test_basic_descriptions(materials_store): +# descriptors_store = MemoryStore() +# builder = BasicDescriptorsBuilder( +# materials=materials_store, descriptors=descriptors_store +# ) +# builder.run() +# +# print(descriptors_store.query_one({})) +# assert descriptors_store.count() == 1 diff --git a/emmet-builders/tests/test_similarity.py b/emmet-builders/tests/test_similarity.py index c38a64b983..3e3a90a3ff 100644 --- a/emmet-builders/tests/test_similarity.py +++ b/emmet-builders/tests/test_similarity.py @@ -1,7 +1,7 @@ import pytest from maggma.stores import JSONStore, MemoryStore -from emmet.builders.materials.basic_descriptors import BasicDescriptorsBuilder +# from emmet.builders.materials.basic_descriptors import BasicDescriptorsBuilder from emmet.builders.vasp.materials import MaterialsBuilder from emmet.builders.materials.similarity import StructureSimilarityBuilder @@ -21,14 +21,14 @@ def materials_store(tasks_store): return materials_store -@pytest.fixture(scope="session") -def descriptors_store(materials_store): - descriptors_store = MemoryStore(key="task_id") - builder = BasicDescriptorsBuilder( - materials=materials_store, descriptors=descriptors_store - ) - builder.run() - return descriptors_store +# @pytest.fixture(scope="session") +# def descriptors_store(materials_store): +# descriptors_store = MemoryStore(key="task_id") +# builder = BasicDescriptorsBuilder( +# materials=materials_store, descriptors=descriptors_store +# ) +# builder.run() +# return descriptors_store @pytest.mark.skip(reason="Waiting on matminer update") From ff012be6b8a33c4823b94dc59e5abfc5143d2050 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 13 Feb 2024 16:49:49 -0800 Subject: [PATCH 22/23] Fix task_id -> material_id --- emmet-core/emmet/core/dois.py | 2 +- emmet-core/emmet/core/eos.py | 2 +- emmet-core/emmet/core/fermi.py | 2 +- emmet-core/emmet/core/grain_boundary.py | 2 +- emmet-core/emmet/core/surface_properties.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) 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-******.", ) From 335fec161cdac23d967172803ab23546c67f049b Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 13 Feb 2024 17:06:09 -0800 Subject: [PATCH 23/23] Fix thermo --- .../materials/thermo/query_operators.py | 28 +++++++++++++++++++ .../api/routes/materials/thermo/resources.py | 9 +++++- 2 files changed, 36 insertions(+), 1 deletion(-) 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, )