Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
munrojm committed Oct 17, 2023
2 parents f58511d + 9a971c2 commit 1845d1e
Show file tree
Hide file tree
Showing 25 changed files with 3,859 additions and 915 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.284
rev: v0.0.292
hooks:
- id: ruff
args: [--fix, --show-fixes]

- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black

- repo: https://github.com/asottile/blacken-docs
rev: "1.15.0"
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies: [black>=23.7.0]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-symlinks
Expand All @@ -34,7 +34,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.2.6
hooks:
- id: codespell
stages: [commit, commit-msg]
Expand Down
7 changes: 3 additions & 4 deletions mp_api/client/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def _submit_request_and_process(
data_model(
**{
field: value
for field, value in raw_doc.model_dump().items()
for field, value in dict(raw_doc).items()
if field in set_fields
}
)
Expand Down Expand Up @@ -876,9 +876,8 @@ def _submit_request_and_process(
)

def _generate_returned_model(self, doc):
set_fields = [
field for field, _ in doc if field in doc.model_dump(exclude_unset=True)
]
set_fields = doc.model_fields_set

unset_fields = [field for field in doc.model_fields if field not in set_fields]

data_model = create_model(
Expand Down
7 changes: 5 additions & 2 deletions mp_api/client/mprester.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from packaging import version
from pymatgen.analysis.phase_diagram import PhaseDiagram
from pymatgen.analysis.pourbaix_diagram import IonEntry
from pymatgen.core import Element, Structure
from pymatgen.core import SETTINGS, Element, Structure
from pymatgen.core.ion import Ion
from pymatgen.entries.computed_entries import ComputedStructureEntry
from pymatgen.io.vasp import Chgcar
Expand Down Expand Up @@ -165,14 +165,17 @@ def __init__(
headers (dict): Custom headers for localhost connections.
mute_progress_bars (bool): Whether to mute progress bars.
"""
# SETTINGS tries to read API key from ~/.config/.pmgrc.yaml
api_key = api_key or DEFAULT_API_KEY or SETTINGS.get("PMG_MAPI_KEY")

if api_key and len(api_key) != 32:
raise ValueError(
"Please use a new API key from https://materialsproject.org/api "
"Keys for the new API are 32 characters, whereas keys for the legacy "
"API are 16 characters."
)

self.api_key = api_key or DEFAULT_API_KEY
self.api_key = api_key
self.endpoint = endpoint
self.headers = headers or {}
self.session = session or BaseRester._create_session(
Expand Down
3 changes: 2 additions & 1 deletion mp_api/client/routes/_user_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ def patch_user_settings(self, consumer_id, settings): # pragma: no cover
"sector",
"job_role",
"is_email_subscribed",
"agreed_terms",
]:
raise ValueError(
f"Invalid setting key {key}. Must be one of"
"institution, sector, job_role, is_email_subscribed"
"institution, sector, job_role, is_email_subscribed, agreed_terms"
)
body[f"settings.{key}"] = settings[key]

Expand Down
2 changes: 1 addition & 1 deletion mp_api/client/routes/materials/substrates.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def search(
"""Query equations of state docs using a variety of search criteria.
Arguments:
area (Tuple[float,float]): Minimum and maximum volume in Ų to consider for the minimim coincident
area (Tuple[float,float]): Minimum and maximum volume in Ų to consider for the minimum coincident
interface area range.
energy (Tuple[float,float]): Minimum and maximum energy in meV to consider for the elastic energy range.
film_id (str): Materials Project ID of the film material.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers = [
dependencies = [
"setuptools",
"msgpack",
"maggma",
"maggma>=0.57.1",
"pymatgen>=2022.3.7",
"typing-extensions>=3.7.4.1",
"requests>=2.23.0",
Expand Down
Loading

0 comments on commit 1845d1e

Please sign in to comment.