diff --git a/optimade_client/default_parameters.py b/optimade_client/default_parameters.py new file mode 100644 index 00000000..33d9872b --- /dev/null +++ b/optimade_client/default_parameters.py @@ -0,0 +1,51 @@ +"""Default initialization parameters + +The lists are set, based on the status of providers from +https://www.optimade.org/providers-dashboard/. + +If the provider has no available databases, it should be put into the SKIP_PROVIDERS list, +meaning it will not be supported. +Providers in the DISABLE_PROVIDERS list are ones the client should support, +but cannot because of one issue or another. +""" + +SKIP_PROVIDERS = [ + "exmpl", + "optimade", + "aiida", + "ccpnc", + "matcloud", + "necro", + "httk", + "pcod", +] + +DISABLE_PROVIDERS = [ + "cod", + "tcod", + "nmd", + "oqmd", + "aflow", + "mpds", + "jarvis", +] + +PROVIDER_DATABASE_GROUPINGS = { + "Materials Cloud": { + "Main Projects": ["mc3d", "mc2d"], + "Contributed Projects": [ + "2dtopo", + "pyrene-mofs", + "scdm", + "stoceriaitf", + "tc-applicability", + "tin-antimony-sulfoiodide", + "curated-cofs", + ], + } +} + + +SKIP_DATABASE = { + "Materials Cloud": ["optimade-sample", "li-ion-conductors", "sssp"], +} diff --git a/optimade_client/query_provider.py b/optimade_client/query_provider.py index 0f1b8ee9..5fdb0b87 100644 --- a/optimade_client/query_provider.py +++ b/optimade_client/query_provider.py @@ -1,4 +1,4 @@ -from typing import Union, Tuple, List +from typing import Union, Tuple, List, Dict, Optional import warnings import ipywidgets as ipw @@ -11,6 +11,12 @@ ProviderImplementationSummary, ) from optimade_client.warnings import OptimadeClientWarning +from optimade_client.default_parameters import ( + PROVIDER_DATABASE_GROUPINGS, + SKIP_DATABASE, + SKIP_PROVIDERS, + DISABLE_PROVIDERS, +) class OptimadeQueryProviderWidget(ipw.GridspecLayout): @@ -28,9 +34,13 @@ class OptimadeQueryProviderWidget(ipw.GridspecLayout): def __init__( self, embedded: bool = False, - database_limit: int = None, - width_ratio: Union[Tuple[int, int], List[int]] = None, - width_space: int = None, + database_limit: Optional[int] = None, + width_ratio: Optional[Union[Tuple[int, int], List[int]]] = None, + width_space: Optional[int] = None, + disable_providers: Optional[List[str]] = None, + skip_providers: Optional[List[str]] = None, + skip_databases: Optional[List[str]] = None, + provider_database_groupings: Optional[Dict[str, Dict[str, List[str]]]] = None, **kwargs, ): # At the moment, the pagination does not work properly as each database is not tested for @@ -39,11 +49,22 @@ def __init__( database_limit = ( database_limit if database_limit and database_limit > 0 else 100 ) + disable_providers = disable_providers or DISABLE_PROVIDERS + skip_providers = skip_providers or SKIP_PROVIDERS + skip_databases = skip_databases or SKIP_DATABASE + provider_database_groupings = ( + provider_database_groupings or PROVIDER_DATABASE_GROUPINGS + ) layout = ipw.Layout(width="100%", height="auto") self.chooser = ProviderImplementationChooser( - child_db_limit=database_limit, **kwargs + child_db_limit=database_limit, + disable_providers=disable_providers, + skip_providers=skip_providers, + skip_databases=skip_databases, + provider_database_groupings=provider_database_groupings, + **kwargs, ) self.summary = ProviderImplementationSummary(**kwargs) if not embedded else None diff --git a/optimade_client/subwidgets/provider_database.py b/optimade_client/subwidgets/provider_database.py index 42f16dc0..b9c7b068 100644 --- a/optimade_client/subwidgets/provider_database.py +++ b/optimade_client/subwidgets/provider_database.py @@ -36,25 +36,6 @@ __all__ = ("ProviderImplementationChooser", "ProviderImplementationSummary") -PROVIDER_DATABASE_GROUPINGS = { - "Materials Cloud": { - "General": sorted(["2dstructures", "curated-cofs"]), - "Projects": sorted( - [ - "sssp", - "2dtopo", - "tc-applicability", - "threedd", - "scdm", - "stoceriaitf", - "pyrene-mofs", - "li-ion-conductors", - ] - ), - "Other": ["optimade-sample"], - } -} - class ProviderImplementationChooser( # pylint: disable=too-many-instance-attributes ipw.VBox @@ -84,11 +65,7 @@ def __init__( child_db_limit if child_db_limit and child_db_limit > 0 else 10 ) self.skip_child_dbs = skip_databases or {} - self.child_db_groupings = ( - provider_database_groupings - if provider_database_groupings is not None - else PROVIDER_DATABASE_GROUPINGS - ) + self.child_db_groupings = provider_database_groupings or {} self.offset = 0 self.number = 1 self.__perform_query = True