Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"
cache: pip

- name: Install dependencies
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.12

- name: Install dependencies
run: |
Expand All @@ -36,20 +36,24 @@ jobs:

docs:
runs-on: ubuntu-latest

needs:
- deploy

env:
PYTHON_VERSION: 3.12

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/requirements-ubuntu-latest_py3.11_extras.txt
pip install -r requirements/requirements-ubuntu-latest_py${{ env.PYTHON_VERSION }}_extras.txt
pip install -e .

- name: Build
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest"]
python-version: ["3.11", "3.12"]
python-version: ["3.12", "3.13", "3.14"]

runs-on: ${{ matrix.os }}

Expand All @@ -43,24 +43,14 @@ jobs:
if: matrix.os == 'windows-latest'
run: echo "SSL_CERT_FILE=$(python -m certifi)" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append

- name: Format API key name (Linux/MacOS)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
echo "API_KEY_NAME=$(echo ${{ format('MP_API_KEY_{0}_{1}', matrix.os, matrix.python-version) }} | awk '{gsub(/-|\./, "_"); print}' | tr '[:lower:]' '[:upper:]')" >> $GITHUB_ENV

- name: Format API key name (Windows)
if: matrix.os == 'windows-latest'
run: |
echo "API_KEY_NAME=$(echo ${{ format('MP_API_KEY_{0}_{1}', matrix.os, matrix.python-version) }} | awk '{gsub(/-|\./, "_"); print}' | tr '[:lower:]' '[:upper:]')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append

- name: Lint with mypy
shell: bash -l {0}
run: python -m mypy mp_api/

- name: Test with pytest
if: always()
env:
MP_API_KEY: ${{ secrets[env.API_KEY_NAME] }}
MP_API_KEY: ${{ secrets.MP_API_KEY_UBUNTU_LATEST_3_12 }}
# MP_API_ENDPOINT: https://api-preview.materialsproject.org/
run: |
pytest -n auto -x --cov=mp_api --cov-report=xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upgrade_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
os: ['ubuntu-latest']
package: ["mp-api"]
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
needs: upgrade
strategy:
matrix:
python-version: ["3.11"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
with:
Expand Down
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.292
rev: v0.15.12
hooks:
- id: ruff
args: [--fix, --show-fixes]

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

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

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v6.0.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.6
rev: v2.4.2
hooks:
- id: codespell
stages: [pre-commit, commit-msg]
Expand Down
1 change: 1 addition & 0 deletions mp_api/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Primary MAPI module."""

from __future__ import annotations

import logging
Expand Down
2 changes: 1 addition & 1 deletion mp_api/client/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ def _submit_requests(
)

# Paginate through remaining results
skip = chunk_size if "_limit" not in criteria else criteria["_limit"]
skip = criteria.get("_limit") or chunk_size
remaining_docs = total_num_docs - initial_data_length

while total_data_len < num_docs_needed and remaining_docs > 0:
Expand Down
18 changes: 9 additions & 9 deletions mp_api/client/mprester.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,13 @@ def get_entries(
def get_pourbaix_entries(
self,
chemsys: str | list[str] | list[ComputedEntry | ComputedStructureEntry],
solid_compat: Literal[
"MaterialsProjectCompatibility", "MaterialsProject2020Compatibility"
]
| Compatibility
| None = "MaterialsProject2020Compatibility",
solid_compat: (
Literal[
"MaterialsProjectCompatibility", "MaterialsProject2020Compatibility"
]
| Compatibility
| None
) = "MaterialsProject2020Compatibility",
use_gibbs: Literal[300] | None = None,
) -> list[PourbaixEntry]:
"""A helper function to get all entries necessary to generate
Expand Down Expand Up @@ -1389,13 +1391,11 @@ def query(*args, **kwargs):
Note this method also no longer supports direct MongoDB-type queries. For more information,
please see the new documentation.
"""
raise NotImplementedError(
"""
raise NotImplementedError("""
The MPRester().query method has been replaced with the MPRester().summary.search method.
Note this method also no longer supports direct MongoDB-type queries. For more information,
please see the new documentation.
"""
)
""")

def get_cohesive_energy(
self,
Expand Down
1 change: 1 addition & 0 deletions mp_api/client/routes/materials/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Define routes and imports to non-core materials resters."""

from __future__ import annotations

from mp_api.client.core.utils import LazyImport
Expand Down
24 changes: 12 additions & 12 deletions mp_api/client/routes/materials/chemenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ class ChemenvRester(BaseRester):
def search(
self,
material_ids: str | list[str] | None = None,
chemenv_iucr: COORDINATION_GEOMETRIES_IUCR
| list[COORDINATION_GEOMETRIES_IUCR]
| None = None,
chemenv_iupac: COORDINATION_GEOMETRIES_IUPAC
| list[COORDINATION_GEOMETRIES_IUPAC]
| None = None,
chemenv_name: COORDINATION_GEOMETRIES_NAMES
| list[COORDINATION_GEOMETRIES_NAMES]
| None = None,
chemenv_symbol: COORDINATION_GEOMETRIES
| list[COORDINATION_GEOMETRIES]
| None = None,
chemenv_iucr: (
COORDINATION_GEOMETRIES_IUCR | list[COORDINATION_GEOMETRIES_IUCR] | None
) = None,
chemenv_iupac: (
COORDINATION_GEOMETRIES_IUPAC | list[COORDINATION_GEOMETRIES_IUPAC] | None
) = None,
chemenv_name: (
COORDINATION_GEOMETRIES_NAMES | list[COORDINATION_GEOMETRIES_NAMES] | None
) = None,
chemenv_symbol: (
COORDINATION_GEOMETRIES | list[COORDINATION_GEOMETRIES] | None
) = None,
species: str | list[str] | None = None,
elements: str | list[str] | None = None,
exclude_elements: list[str] | None = None,
Expand Down
11 changes: 2 additions & 9 deletions mp_api/client/routes/materials/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,11 @@ def get_trajectory(
storage_options={"AWS_SKIP_SIGNATURE": "true", "AWS_REGION": "us-east-1"},
)

traj_data = pa.table(
QueryBuilder()
.register("traj", traj_tbl)
.execute(
f"""
traj_data = pa.table(QueryBuilder().register("traj", traj_tbl).execute(f"""
SELECT *
FROM traj
{predicate};
"""
)
.read_all()
).to_pylist(maps_as_pydicts="strict")
""").read_all()).to_pylist(maps_as_pydicts="strict")

if not traj_data:
raise MPRestError(f"No trajectory data for {task_id} found")
Expand Down
8 changes: 5 additions & 3 deletions mp_api/client/routes/materials/xas.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ def search(
if absorbing_element:
query_params.update(
{
"absorbing_element": str(absorbing_element.symbol)
if type(absorbing_element) == Element
else absorbing_element
"absorbing_element": (
str(absorbing_element.symbol)
if isinstance(absorbing_element, Element)
else absorbing_element
)
}
)
for k in ("chemsys", "elements", "material_ids", "spectrum_ids"):
Expand Down
1 change: 1 addition & 0 deletions mp_api/client/routes/molecules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Define routes to non-core molecules resters."""

from __future__ import annotations

from mp_api.client.core.utils import LazyImport
Expand Down
1 change: 1 addition & 0 deletions mp_api/mcp/_schemas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Define auxiliary schemas used by some LLMs."""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions mp_api/mcp/mp_mcp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Define custom MCP tools for the Materials Project API."""

from __future__ import annotations

from fastmcp import FastMCP
Expand Down
1 change: 1 addition & 0 deletions mp_api/mcp/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Configure the Materials Project MCP server."""

from __future__ import annotations

from argparse import ArgumentParser
Expand Down
7 changes: 4 additions & 3 deletions mp_api/mcp/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,10 @@ def get_phase_diagram_from_elements(
self,
elements: str,
thermo_type: Literal[ # type: ignore[valid-type]
*[x.value for x in ThermoType.__members__.values() if x.value != "UNKNOWN"]
]
| str = "GGA_GGA+U_R2SCAN",
"GGA_GGA+U",
"GGA_GGA+U_R2SCAN",
"R2SCAN",
] = "GGA_GGA+U_R2SCAN",
) -> plotly_go.Figure:
"""Find a thermodynamic phase diagram in the Materials Project by specified elements.

Expand Down
Loading
Loading