Skip to content
Open
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/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", "3.13", "3.14"]
python-version: ["3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

[![testing](https://github.com/materialsproject/api/actions/workflows/testing.yml/badge.svg?branch=main)](https://github.com/materialsproject/api/actions?query=workflow%3Atesting+branch%3Amain)
[![codecov](https://codecov.io/gh/materialsproject/api/branch/main/graph/badge.svg)](https://codecov.io/gh/materialsproject/api)
![python](https://img.shields.io/badge/Python-3.11+-blue.svg?logo=python&logoColor=white)
![python](https://img.shields.io/badge/Python-3.12+-blue.svg?logo=python&logoColor=white)

This repository is the development environment for the new Materials Project API. A core client implementation will reside here. For information on how to use the API, please see the updated [documentation](https://docs.materialsproject.org/downloading-data/how-do-i-download-the-materials-project-database).
1 change: 0 additions & 1 deletion mp_api/_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def _normalize(doc, field: str):
if k not in ("_page", "_sort_fields", "chunk_size", "fields")
}
for sort_field in [sort_fields] if isinstance(sort_fields, str) else sort_fields:

asc = search_method(
_page=1,
_sort_fields=sort_field,
Expand Down
3 changes: 2 additions & 1 deletion mp_api/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
except PackageNotFoundError: # pragma: no cover
__version__ = os.getenv("SETUPTOOLS_SCM_PRETEND_VERSION", "")

logging.getLogger(__name__).addHandler(logging.NullHandler())
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())
23 changes: 2 additions & 21 deletions mp_api/client/contribs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
from mp_api.client.core.schemas import _convert_to_model

if TYPE_CHECKING:
from collections.abc import Generator, Iterable, Sequence
from collections.abc import Iterable, Sequence
from typing import Any

from mp_api.client.contribs._types import (
Expand Down Expand Up @@ -165,25 +165,6 @@ def validate_url(
bravado_config_dict["bravado"] = bravado_config


# https://stackoverflow.com/a/8991553
def grouper(n: int, iterable: Iterable) -> Generator:
"""Collect data into non-overlapping fixed-length chunks or blocks.

Args:
n (int) : Maximum number of elements per block
iterable (Iterable) : object to divide into blocks

Returns:
Generator of input iterable divided into blocks
"""
it = iter(iterable)
while True:
chunk = tuple(itertools.islice(it, n))
if not chunk:
return
yield chunk


def get_session(session: requests.Session | None = None) -> FuturesSession:
"""Start a futures session.

Expand Down Expand Up @@ -647,7 +628,7 @@ def _split_query(
line_len = len(",".join(vv).encode("utf-8"))

if len(v) > per_page:
for chunk in grouper(per_page, v):
for chunk in itertools.batched(v, per_page):
queries.append({k: list(chunk)})

query["per_page"] = per_page
Expand Down
Loading
Loading