-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[create-pull-request] automated change
- Loading branch information
Showing
24 changed files
with
5,791 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
OPTIMADE Client | ||
Voilà/Jupyter client for searching through OPTIMADE databases. | ||
""" | ||
from .informational import OptimadeClientFAQ, HeaderDescription, OptimadeLog | ||
from .query_provider import OptimadeQueryProviderWidget | ||
from .query_filter import OptimadeQueryFilterWidget | ||
from .summary import OptimadeSummaryWidget | ||
|
||
|
||
__version__ = "2022.9.19" | ||
__all__ = ( | ||
"HeaderDescription", | ||
"OptimadeClientFAQ", | ||
"OptimadeLog", | ||
"OptimadeQueryProviderWidget", | ||
"OptimadeQueryFilterWidget", | ||
"OptimadeSummaryWidget", | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import argparse | ||
import logging | ||
import os | ||
from pathlib import Path | ||
import subprocess | ||
import sys | ||
|
||
try: | ||
from voila.app import main as voila | ||
except ImportError: | ||
voila = None | ||
|
||
|
||
LOGGING_LEVELS = [logging.getLevelName(level).lower() for level in range(0, 51, 10)] | ||
VERSION = "2022.9.19" # Avoid importing optimade-client package | ||
|
||
|
||
def main(args: list = None): | ||
"""Run the OPTIMADE Client.""" | ||
parser = argparse.ArgumentParser( | ||
description=main.__doc__, | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter, | ||
) | ||
parser.add_argument( | ||
"--version", | ||
action="version", | ||
help="Show the version and exit.", | ||
version=f"OPTIMADE Client version {VERSION}", | ||
) | ||
parser.add_argument( | ||
"--log-level", | ||
type=str, | ||
help="Set the log-level of the server.", | ||
choices=LOGGING_LEVELS, | ||
default="info", | ||
) | ||
parser.add_argument( | ||
"--debug", | ||
action="store_true", | ||
help="Will overrule log-level option and set the log-level to 'debug'.", | ||
) | ||
parser.add_argument( | ||
"--open-browser", | ||
action="store_true", | ||
help="Attempt to open a browser upon starting the Voilà tornado server.", | ||
) | ||
parser.add_argument( | ||
"--template", | ||
type=str, | ||
help="Use another template than the default.", | ||
) | ||
parser.add_argument( | ||
"--dev", | ||
action="store_true", | ||
help="Use development servers where applicable.", | ||
) | ||
|
||
args = parser.parse_args(args) | ||
log_level = args.log_level | ||
debug = args.debug | ||
open_browser = args.open_browser | ||
template = args.template | ||
dev = args.dev | ||
|
||
# Make sure Voilà is installed | ||
if voila is None: | ||
sys.exit( | ||
"Voilà is not installed.\nPlease run:\n\n pip install optimade-client[server]\n\n" | ||
"Or the equivalent, matching the installation in your environment, to install Voilà " | ||
"(and ASE for a larger download format selection)." | ||
) | ||
|
||
notebook = str( | ||
Path(__file__).parent.joinpath("static/OPTIMADE-Client.ipynb").resolve() | ||
) | ||
config_path = str(Path(__file__).parent.joinpath("static").resolve()) | ||
|
||
# "Trust" notebook | ||
subprocess.run(["jupyter", "trust", notebook], check=False) | ||
|
||
argv = [notebook] | ||
|
||
argv.append(f"--Voila.config_file_paths={config_path}") | ||
|
||
if debug: | ||
if log_level not in ("debug", "info"): | ||
print("[OPTIMADE-Client] Overwriting requested log-level to: 'debug'") | ||
os.environ["OPTIMADE_CLIENT_DEBUG"] = "True" | ||
argv.append("--debug") | ||
argv.append("--show_tracebacks=True") | ||
else: | ||
os.environ.pop("OPTIMADE_CLIENT_DEBUG", None) | ||
|
||
os.environ["OPTIMADE_CLIENT_DEVELOPMENT_MODE"] = "1" if dev else "0" | ||
|
||
if not open_browser: | ||
argv.append("--no-browser") | ||
|
||
if "--debug" not in argv: | ||
argv.append(f"--Voila.log_level={getattr(logging, log_level.upper())}") | ||
|
||
if template: | ||
argv.append(f"--template={template}") | ||
|
||
voila(argv) |
131 changes: 131 additions & 0 deletions
131
build/lib/optimade_client/cli/static/OPTIMADE-Client.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"source": [ | ||
"# import os\n", | ||
"\n", | ||
"# This line will include DEBUG level log messages from the start of the app,\n", | ||
"# as well as include a \"Local server\" as provider (at http://localhost:5000/optimade/v<MAJOR>),\n", | ||
"# where <MAJOR> is the major version number of the currently supported OPTIMADE spec version.\n", | ||
"#os.environ[\"OPTIMADE_CLIENT_DEBUG\"] = \"True\"" | ||
], | ||
"outputs": [], | ||
"metadata": {} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"source": [ | ||
"from optimade_client import (\n", | ||
" HeaderDescription,\n", | ||
" OptimadeClientFAQ,\n", | ||
" OptimadeLog,\n", | ||
" OptimadeQueryProviderWidget,\n", | ||
" OptimadeQueryFilterWidget,\n", | ||
" OptimadeSummaryWidget,\n", | ||
")\n", | ||
"from ipywidgets import dlink, HTML\n", | ||
"from IPython.display import display\n", | ||
"\n", | ||
"# NOTE: Temporarily disable providers NOT properly satisfying the OPTIMADE specification\n", | ||
"# Follow issue #206: https://github.com/CasperWA/voila-optimade-client/issues/206\n", | ||
"# For omdb: Follow issue #246: https://github.com/CasperWA/voila-optimade-client/issues/246\n", | ||
"disable_providers = [\n", | ||
" \"cod\",\n", | ||
" \"tcod\",\n", | ||
" \"nmd\",\n", | ||
" \"oqmd\",\n", | ||
" \"aflow\",\n", | ||
" \"matcloud\",\n", | ||
" \"mpds\",\n", | ||
" \"necro\",\n", | ||
" \"jarvis\",\n", | ||
"]\n", | ||
"# Curate and group Materials Cloud databases\n", | ||
"skip_databases = {\"Materials Cloud\": [\"li-ion-conductors\"]}\n", | ||
"database_grouping = {\n", | ||
" \"Materials Cloud\": {\n", | ||
" \"General\": [\"curated-cofs\"],\n", | ||
" \"Projects\": [\n", | ||
" \"2dstructures\",\n", | ||
" \"2dtopo\",\n", | ||
" \"pyrene-mofs\",\n", | ||
" \"scdm\",\n", | ||
" \"sssp\",\n", | ||
" \"stoceriaitf\",\n", | ||
" \"tc-applicability\",\n", | ||
" \"threedd\",\n", | ||
" ]}\n", | ||
"}\n", | ||
"\n", | ||
"selector = OptimadeQueryProviderWidget(\n", | ||
" disable_providers=disable_providers,\n", | ||
" skip_providers=[\"exmpl\", \"optimade\", \"aiida\"],\n", | ||
" skip_databases=skip_databases,\n", | ||
" provider_database_groupings=database_grouping,\n", | ||
")\n", | ||
"filters = OptimadeQueryFilterWidget()\n", | ||
"summary = OptimadeSummaryWidget(direction=\"horizontal\")\n", | ||
"\n", | ||
"_ = dlink((selector, 'database'), (filters, 'database'))\n", | ||
"_ = dlink((filters, 'structure'), (summary, 'entity'))\n", | ||
"\n", | ||
"HeaderDescription()" | ||
], | ||
"outputs": [], | ||
"metadata": {} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"source": [ | ||
"OptimadeClientFAQ()" | ||
], | ||
"outputs": [], | ||
"metadata": {} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"source": [ | ||
"OptimadeLog()" | ||
], | ||
"outputs": [], | ||
"metadata": {} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"source": [ | ||
"display(HTML('<h2 style=\"margin-below:0px;padding-below:0px;\">Query a provider\\'s database</h2>'))\n", | ||
"\n", | ||
"display(selector, filters, summary)" | ||
], | ||
"outputs": [], | ||
"metadata": {} | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"VoilaConfiguration": { | ||
"enable_nbextensions": true | ||
}, | ||
"VoilaExecutePreprocessor": { | ||
"timeout": 180 | ||
}, | ||
"MappingKernelManager": { | ||
"cull_idle_timeout": 900, | ||
"cull_interval": 60 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"], | ||
} |
Oops, something went wrong.