Skip to content

Commit

Permalink
Move default database providers defaults setup parameters to one file (
Browse files Browse the repository at this point in the history
…#449)

Move default database providers defaults setup
parameters to one file.

- Change the Materials Cloud DB the groupings and the
  sub-DB name.
- Moving providers has no DB to skip list and keep disable list
  for not yet supported providers.

Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
  • Loading branch information
unkcpz and CasperWA authored Sep 19, 2022
1 parent 030421d commit 3527566
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 29 deletions.
51 changes: 51 additions & 0 deletions optimade_client/default_parameters.py
Original file line number Diff line number Diff line change
@@ -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"],
}
31 changes: 26 additions & 5 deletions optimade_client/query_provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Tuple, List
from typing import Union, Tuple, List, Dict, Optional
import warnings

import ipywidgets as ipw
Expand All @@ -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):
Expand All @@ -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
Expand All @@ -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
Expand Down
25 changes: 1 addition & 24 deletions optimade_client/subwidgets/provider_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3527566

Please sign in to comment.