Skip to content

Commit 09bdd4f

Browse files
author
Jason Munro
authored
Limit parallel queries to 4 threads (#877)
* Limit parallel queries to 4 threads * Reduce test load * Fix max list * Fix long list test
1 parent 0a1561a commit 09bdd4f

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

.github/workflows/testing.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ concurrency:
1414
jobs:
1515
test:
1616
strategy:
17-
max-parallel: 3
17+
max-parallel: 2
1818
matrix:
19-
os: [ubuntu-latest, macos-latest, windows-latest]
19+
os: [ubuntu-latest, windows-latest]
2020
python-version: ["3.9", "3.10", "3.11"]
2121

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

mp_api/client/core/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
from mp_api.client import __file__ as root_dir
1010

1111
PMG_SETTINGS = _load_pmg_settings()
12-
_NUM_PARALLEL_REQUESTS = min(PMG_SETTINGS.get("MPRESTER_NUM_PARALLEL_REQUESTS", 8), 8)
12+
_NUM_PARALLEL_REQUESTS = min(PMG_SETTINGS.get("MPRESTER_NUM_PARALLEL_REQUESTS", 4), 4)
1313
_MAX_RETRIES = min(PMG_SETTINGS.get("MPRESTER_MAX_RETRIES", 3), 3)
1414
_MUTE_PROGRESS_BAR = PMG_SETTINGS.get("MPRESTER_MUTE_PROGRESS_BARS", False)
1515
_MAX_HTTP_URL_LENGTH = PMG_SETTINGS.get("MPRESTER_MAX_HTTP_URL_LENGTH", 2000)
16-
_MAX_LIST_LENGTH = min(PMG_SETTINGS.get("MPRESTER_MAX_LIST_LENGTH", 40000), 40000)
16+
_MAX_LIST_LENGTH = min(PMG_SETTINGS.get("MPRESTER_MAX_LIST_LENGTH", 10000), 10000)
1717

1818
try:
1919
CPU_COUNT = cpu_count()

mp_api/client/core/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def validate_ids(id_list: list[str]):
2525
Returns:
2626
id_list: Returns original ID list if everything is formatted correctly.
2727
"""
28-
if len(id_list) >= MAPIClientSettings().MAX_LIST_LENGTH:
28+
if len(id_list) > MAPIClientSettings().MAX_LIST_LENGTH:
2929
raise ValueError(
3030
"List of material/molecule IDs provided is too long. Consider removing the ID filter to automatically pull"
3131
" data for all IDs and filter locally."

tests/test_mprester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,11 @@ def test_large_list(self, mpr):
316316
mpids = [
317317
str(doc.material_id)
318318
for doc in mpr.summary.search(
319-
chunk_size=1000, num_chunks=15, fields=["material_id"]
319+
chunk_size=1000, num_chunks=10, fields=["material_id"]
320320
)
321321
]
322322
docs = mpr.summary.search(material_ids=mpids, fields=["material_ids"])
323-
assert len(docs) == 15000
323+
assert len(docs) == 10000
324324

325325

326326
def test_pmg_api_key(monkeypatch: pytest.MonkeyPatch):

0 commit comments

Comments
 (0)