Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewcarbone committed Aug 4, 2023
1 parent ec825d0 commit 1e76bb1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lightshow/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ def _fetch_from_MP(job):
Parameters
----------
job : list
A list containing the parameters of the function, see below.
Notes
-----
For each element of ``job``, we have the following, in order:
mpr : pymatgen.ext.matproj.MPRester
Interface to the Materials Project REST API.
mpid : str
Expand Down Expand Up @@ -85,7 +92,7 @@ def _from_mpids_list(
):
"""Makes one large API call to the Materials Project database and pulls the
relevant structural files given a list of Materials Project ID's (mpids).
Parameters
----------
mpids : list of str
Expand All @@ -98,21 +105,19 @@ def _from_mpids_list(
If True, will use tqdm to print a progress bar.
concurrent_threads : int, optional
The number of concurrent threads used in the ThreadPoolExecutor.
Returns
-------
dict
A dictionary containing the structures (with keys as the mpids) and
metadata (with the same keys).
"""

# Safely fetch all of the Materials Project structures matching the query

with MPRester(api_key) as mpr:
jobs = [[mpr, mpid, metadata_keys] for mpid in mpids]
with ThreadPoolExecutor(max_workers=concurrent_threads) as executor:
results = list(tqdm(executor.map(
_fetch_from_MP, jobs), total=len(jobs))
results = list(
tqdm(executor.map(_fetch_from_MP, jobs), total=len(jobs))
)

structures = {
Expand Down Expand Up @@ -230,6 +235,7 @@ def from_materials_project(
"diel",
],
verbose=True,
concurrent_threads=2,
):
"""Constructs the :class:`.Database` object by pulling structures and
metadata directly from the Materials Project. The following query types
Expand Down Expand Up @@ -317,6 +323,7 @@ def from_materials_project(
api_key,
metadata_keys,
verbose=verbose,
concurrent_threads=concurrent_threads,
)

return cls(
Expand Down

0 comments on commit 1e76bb1

Please sign in to comment.