Skip to content

Commit

Permalink
Limit parallel queries to 4 threads (#877)
Browse files Browse the repository at this point in the history
* Limit parallel queries to 4 threads

* Reduce test load

* Fix max list

* Fix long list test
  • Loading branch information
Jason Munro authored Dec 8, 2023
1 parent 0a1561a commit 09bdd4f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ concurrency:
jobs:
test:
strategy:
max-parallel: 3
max-parallel: 2
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11"]

runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions mp_api/client/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from mp_api.client import __file__ as root_dir

PMG_SETTINGS = _load_pmg_settings()
_NUM_PARALLEL_REQUESTS = min(PMG_SETTINGS.get("MPRESTER_NUM_PARALLEL_REQUESTS", 8), 8)
_NUM_PARALLEL_REQUESTS = min(PMG_SETTINGS.get("MPRESTER_NUM_PARALLEL_REQUESTS", 4), 4)
_MAX_RETRIES = min(PMG_SETTINGS.get("MPRESTER_MAX_RETRIES", 3), 3)
_MUTE_PROGRESS_BAR = PMG_SETTINGS.get("MPRESTER_MUTE_PROGRESS_BARS", False)
_MAX_HTTP_URL_LENGTH = PMG_SETTINGS.get("MPRESTER_MAX_HTTP_URL_LENGTH", 2000)
_MAX_LIST_LENGTH = min(PMG_SETTINGS.get("MPRESTER_MAX_LIST_LENGTH", 40000), 40000)
_MAX_LIST_LENGTH = min(PMG_SETTINGS.get("MPRESTER_MAX_LIST_LENGTH", 10000), 10000)

try:
CPU_COUNT = cpu_count()
Expand Down
2 changes: 1 addition & 1 deletion mp_api/client/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def validate_ids(id_list: list[str]):
Returns:
id_list: Returns original ID list if everything is formatted correctly.
"""
if len(id_list) >= MAPIClientSettings().MAX_LIST_LENGTH:
if len(id_list) > MAPIClientSettings().MAX_LIST_LENGTH:
raise ValueError(
"List of material/molecule IDs provided is too long. Consider removing the ID filter to automatically pull"
" data for all IDs and filter locally."
Expand Down
4 changes: 2 additions & 2 deletions tests/test_mprester.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,11 @@ def test_large_list(self, mpr):
mpids = [
str(doc.material_id)
for doc in mpr.summary.search(
chunk_size=1000, num_chunks=15, fields=["material_id"]
chunk_size=1000, num_chunks=10, fields=["material_id"]
)
]
docs = mpr.summary.search(material_ids=mpids, fields=["material_ids"])
assert len(docs) == 15000
assert len(docs) == 10000


def test_pmg_api_key(monkeypatch: pytest.MonkeyPatch):
Expand Down

0 comments on commit 09bdd4f

Please sign in to comment.