From cac60b3f3ef223b9552da4775c15e7f991d578f5 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Wed, 1 Nov 2023 18:28:38 +0000 Subject: [PATCH] Refresh OPTIMADE aliases and update docstrings --- pymatgen/ext/optimade.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/pymatgen/ext/optimade.py b/pymatgen/ext/optimade.py index 9882460b084..da6d64c9176 100644 --- a/pymatgen/ext/optimade.py +++ b/pymatgen/ext/optimade.py @@ -16,9 +16,6 @@ from pymatgen.util.due import Doi, due from pymatgen.util.provenance import StructureNL -# from retrying import retry - - # TODO: importing optimade-python-tool's data structures will make more sense Provider = namedtuple("Provider", ["name", "base_url", "description", "homepage", "prefix"]) @@ -46,7 +43,9 @@ class OptimadeRester: # these aliases are provided as a convenient shortcut for users of the OptimadeRester class aliases = { "aflow": "http://aflow.org/API/optimade/", + "alexandria": "https://alexandria.odbx.science", "cod": "https://www.crystallography.net/cod/optimade", + "cmr": "https://cmr-optimade.fysik.dtu.dk", "mcloud.mc3d": "https://aiida.materialscloud.org/mc3d/optimade", "mcloud.mc2d": "https://aiida.materialscloud.org/mc2d/optimade", "mcloud.2dtopo": "https://aiida.materialscloud.org/2dtopo/optimade", @@ -58,6 +57,7 @@ class OptimadeRester: "mcloud.tin-antimony-sulfoiodide": "https://aiida.materialscloud.org/tin-antimony-sulfoiodide/optimade", "mcloud.optimade-sample": "https://aiida.materialscloud.org/optimade-sample/optimade", "mp": "https://optimade.materialsproject.org", + "mpdd": "http://mpddoptimade.phaseslab.org", "mpds": "https://api.mpds.io", "nmd": "https://nomad-lab.eu/prod/rae/optimade/", "odbx": "https://optimade.odbx.science", @@ -154,11 +154,8 @@ def describe(self): provider_text = "\n".join(map(str, (provider for provider in self._providers.values() if provider))) return f"OptimadeRester connected to:\n{provider_text}" - # @retry(stop_max_attempt_number=3, wait_random_min=1000, wait_random_max=2000) def _get_json(self, url): - """Retrieves JSON, will attempt to (politely) try again on failure subject to a - random delay and a maximum number of attempts. - """ + """Retrieves and returns JSON resource from given url.""" return self.session.get(url, timeout=self._timeout).json() @staticmethod @@ -215,8 +212,11 @@ def get_structures( elements: List of elements nelements: Number of elements, e.g. 4 or [2, 5] for the range >=2 and <=5 nsites: Number of sites, e.g. 4 or [2, 5] for the range >=2 and <=5 - chemical_formula_anonymous: Anonymous chemical formula - chemical_formula_hill: Chemical formula following Hill convention + chemical_formula_anonymous: The desired chemical formula in OPTIMADE anonymous formula format + (NB. The ordering is reversed from the pymatgen format, e.g., pymatgen "ABC2" should become "A2BC"). + chemical_formula_hill: The desired chemical formula in the OPTIMADE take on the Hill formula format. + (NB. Again, this is different from the pymatgen format, as the OPTIMADE version is a reduced chemical + formula simply using the IUPAC/Hill ordering.) Returns: dict[str, Structure]: keyed by that database provider's id system @@ -253,8 +253,11 @@ def get_snls( elements: List of elements nelements: Number of elements, e.g. 4 or [2, 5] for the range >=2 and <=5 nsites: Number of sites, e.g. 4 or [2, 5] for the range >=2 and <=5 - chemical_formula_anonymous: Anonymous chemical formula - chemical_formula_hill: Chemical formula following Hill convention + chemical_formula_anonymous: The desired chemical formula in OPTIMADE anonymous formula format + (NB. The ordering is reversed from the pymatgen format, e.g., pymatgen "ABC2" should become "A2BC"). + chemical_formula_hill: The desired chemical formula in the OPTIMADE take on the Hill formula format. + (NB. Again, this is different from the pymatgen format, as the OPTIMADE version is a reduced chemical + formula simply using the IUPAC/Hill ordering.) additional_response_fields: Any additional fields desired from the OPTIMADE API, these will be stored under the `'_optimade'` key in each `StructureNL.data` dictionary.